[m-rev.] for review: fix bug in saved_vars.m

Peter Wang wangp at students.cs.mu.OZ.AU
Fri Apr 28 13:22:22 AEST 2006


Estimated hours taken: 1.5
Branches: main, release

compiler/saved_vars.m:
	The saved_vars pass was not pushing unifications that assign
	constants to variables into parallel conjunctions.  Since the
	original unification would be deleted, the parallel conjunction
	would be left referring to an unbound variable.

tests/valid/Mercury.options:
tests/valid/par_saved_const.m:
	Add a test case.


Index: compiler/saved_vars.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/saved_vars.m,v
retrieving revision 1.63
diff -u -r1.63 saved_vars.m
--- compiler/saved_vars.m	29 Mar 2006 08:07:21 -0000	1.63
+++ compiler/saved_vars.m	28 Apr 2006 00:54:45 -0000
@@ -347,17 +347,20 @@
                 IsNonLocal, !SlotInfo),
             Goals = [NewConstruct, Goal1 | Goals1]
         ;
-            Goal0Expr = conj(ConjType, Conj),
+            Goal0Expr = conj(ConjType, Conj0),
             (
                 ConjType = plain_conj,
-                list.append(Conj, Goals0, Goals1),
+                list.append(Conj0, Goals0, Goals1),
                 saved_vars_delay_goal(Goals1, Goals, Construct, Var,
                     IsNonLocal, !SlotInfo)
             ;
                 ConjType = parallel_conj,
+                push_into_goals_rename(Conj0, Conj, Construct, Var,
+                    !SlotInfo),
+                Goal1 = conj(ConjType, Conj) - Goal0Info,
                 saved_vars_delay_goal(Goals0, Goals1, Construct, Var,
                     IsNonLocal, !SlotInfo),
-                Goals = [Goal0 | Goals1]
+                Goals = [Goal1 | Goals1]
             )
         ;
             Goal0Expr = scope(Reason, SomeGoal0),
Index: tests/valid/Mercury.options
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mercury.options,v
retrieving revision 1.30
diff -u -r1.30 Mercury.options
--- tests/valid/Mercury.options	27 Mar 2006 13:25:54 -0000	1.30
+++ tests/valid/Mercury.options	28 Apr 2006 00:59:08 -0000
@@ -93,6 +93,7 @@
 MCFLAGS-mostly_uniq_mode_inf	= --infer-all
 MCFLAGS-mpj6			= --infer-all
 MCFLAGS-no_warn_obsolete	= --no-warn-obsolete
+MCFLAGS-par_saved_const 	= -O3 --optimize-saved-vars-const
 MCFLAGS-pred_with_no_modes	= --infer-all
 MCFLAGS-quantifier_warning	= --halt-at-warn
 MCFLAGS-simplify_bug2		= -O3
Index: tests/valid/par_saved_const.m
===================================================================
RCS file: tests/valid/par_saved_const.m
diff -N tests/valid/par_saved_const.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/par_saved_const.m	28 Apr 2006 00:58:18 -0000
@@ -0,0 +1,25 @@
+% The saved_vars pass was not pushing unifications that assign
+% constants to variables into parallel conjunctions.
+%
+% Uncaught Mercury exception:
+% Software Error: map.lookup: key not found
+%         Key Type: term.var(parse_tree.prog_data.prog_var_type)
+%         Key Value: var(4)
+%         Value Type: ll_backend.var_locn.var_state
+
+:- module par_saved_const.
+:- interface.
+:- import_module int.
+:- import_module list.
+
+:- pred p(list(int)::out) is det.
+
+:- implementation.
+
+p(M) :-
+    L = [1,2],
+    L = [H|_],
+    ( X = H
+    & true
+    ),
+    M = [X|L].
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list