[m-rev.] for review: liveness assertion failure with CTGC

Peter Wang novalazy at gmail.com
Wed Jan 30 11:25:36 AEDT 2008


Branches: main

Avoid assertion failures in the liveness detection pass which is called as
part of computing in-use information for structure reuse.  The problem occurs
for procedures containing an if-then-else goal with an `erroneous' condition.
As written, liveness.m expects such goals to have been simplified beforehand.
This is not the case when structure reuse is enabled, as the structure reuse
analysis is run before simplification.

compiler/liveness.m:
	In the first of liveness.m's four passes, replace the offending
	if-then-else goals by their conditions when we see them.


[cvs diff --ignore-space-change]

Index: compiler/liveness.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/liveness.m,v
retrieving revision 1.161
diff -u -b -r1.161 liveness.m
--- compiler/liveness.m	21 Jan 2008 00:32:49 -0000	1.161
+++ compiler/liveness.m	30 Jan 2008 00:24:06 -0000
@@ -443,19 +443,17 @@
         detect_liveness_in_goal(Cond0, Cond, Liveness0, LivenessCond,
             LiveInfo),
 
-        % If the condition cannot succeed, any variables which become live
-        % in the else part should be put in the post-birth set of the then part
-        % by add_liveness_after_goal, and the other sets should be empty.
+        % simplify.m normally simplifies if-then-else goals with `erroneous'
+        % conditions, but liveness detection can be run before simplication to
+        % compute in-use information for CTGC.  Since the rest of this file
+        % doesn't handle such goals, we simplify them here.
         Cond = hlds_goal(_, CondInfo),
         CondDelta = goal_info_get_instmap_delta(CondInfo),
         ( instmap_delta_is_unreachable(CondDelta) ->
-            LivenessThen = LivenessCond,
-            Then1 = Then0
+            Cond = hlds_goal(GoalExpr, _)
         ;
-            detect_liveness_in_goal(Then0, Then1,
-                LivenessCond, LivenessThen, LiveInfo)
-        ),
-
+            detect_liveness_in_goal(Then0, Then1, LivenessCond, LivenessThen,
+                LiveInfo),
         detect_liveness_in_goal(Else0, Else1, Liveness0, LivenessElse,
             LiveInfo),
 
@@ -470,6 +468,7 @@
 
         !:Liveness = Liveness,
         GoalExpr = if_then_else(Vars, Cond, Then, Else)
+        )
     ;
         GoalExpr0 = negation(SubGoal0),
         detect_liveness_in_goal(SubGoal0, SubGoal, !Liveness, LiveInfo),

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list