diff: accurate gc typeinfo variable bug.

Tyson Richard DOWD trd at cs.mu.oz.au
Fri May 9 17:11:19 AEST 1997


Hi,

	Fergus, can you please review this?

===================================================================

Estimated hours taken: 10

Fix a bug in compilation in accurate GC grades.

compiler/polymorphism.m:
	Add any introduced typeinfo variables to the typevar map.
	Without this unbound type variables won't not occur in the 
	typevar map, and the liveness calculations won't be able to
	make sure the typeinfos for the unbound type variables are
	kept live when they should be. (that is, the map lookups would
	fail looking in the typevar map).

Index: liveness.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/liveness.m,v
retrieving revision 1.71
diff -u -r1.71 liveness.m
--- liveness.m	1997/05/05 11:17:13	1.71
+++ liveness.m	1997/05/09 06:07:33
@@ -318,7 +318,7 @@
 			GCmethod = accurate
 		->
 			live_info_get_proc_info(LiveInfo, ProcInfo),
-			proc_info_get_used_typeinfos_setwise(ProcInfo,
+			proc_info_get_typeinfo_vars_setwise(ProcInfo,
 				NonLocals0, TypeInfoVars),
 			set__union(NonLocals0, TypeInfoVars, NonLocals)
 		;
@@ -790,9 +790,30 @@
 		initial_liveness_2(Vars, Modes, Types, ModuleInfo,
 			Liveness0, Liveness1)
 	->
-		Liveness = Liveness1
+		Liveness2 = Liveness1
 	;
 		error("initial_liveness: list length mismatch")
+	),
+		% If a variable is unused in the goal, it shouldn't be
+		% in the initial liveness. (If we allowed it to start
+		% live, it wouldn't ever become dead, because it would
+		% have to be used to be killed).
+		% So we intersect the headvars with the non-locals.
+	proc_info_goal(ProcInfo, _Goal - GoalInfo),
+	goal_info_get_nonlocals(GoalInfo, NonLocals),
+	set__intersect(Liveness2, NonLocals, Liveness3),
+		% If doing accurate garbage collection, the corresponding
+		% typeinfos need to be added to these.
+	module_info_globals(ModuleInfo, Globals),
+	globals__get_gc_method(Globals, GCmethod),
+	(
+		GCmethod = accurate
+	->
+		proc_info_get_typeinfo_vars_setwise(ProcInfo, Liveness3,
+			TypeInfoVars),
+		set__union(Liveness3, TypeInfoVars, Liveness)
+	;
+		Liveness = Liveness3
 	).
 
 :- pred initial_liveness_2(list(var), list(mode), list(type), module_info,
@@ -837,7 +858,7 @@
 	(
 		GCmethod = accurate
 	->
-		proc_info_get_used_typeinfos_setwise(ProcInfo, Deadness2,
+		proc_info_get_typeinfo_vars_setwise(ProcInfo, Deadness2,
 			TypeInfoVars),
 		set__union(Deadness2, TypeInfoVars, Deadness)
 	;
-- 
       Tyson Dowd           #
                            #             Sign on refrigerator:
     trd at cs.mu.oz.au        #           Refrigerate after opening. 
http://www.cs.mu.oz.au/~trd #                  - C. J. Owen.



More information about the developers mailing list