[m-rev.] for review: fix recomputing instmap_delta over negations

Peter Wang novalazy at gmail.com
Fri Apr 23 13:44:09 AEST 2010


Branches: main, 10.04

compiler/mode_util.m:
        Fix a problem where recomputing the instmap_delta over a negation
        goal would change its reachability from `unreachable' to `reachable'.

tests/valid/Mercury.options:
tests/valid/Mmakefile:
tests/valid/neg_erroneous.m:
        Add test case.

diff --git a/compiler/mode_util.m b/compiler/mode_util.m
index be3ce91..cda780f 100644
--- a/compiler/mode_util.m
+++ b/compiler/mode_util.m
@@ -1157,7 +1157,12 @@ recompute_instmap_delta_2(RecomputeAtomic,
GoalExpr0, GoalExpr, GoalInfo,
         GoalExpr = disj(Goals)
     ;
         GoalExpr0 = negation(SubGoal0),
-        instmap_delta_init_reachable(InstMapDelta),
+        InstMapDelta0 = goal_info_get_instmap_delta(GoalInfo),
+        ( instmap_delta_is_reachable(InstMapDelta0) ->
+            instmap_delta_init_reachable(InstMapDelta)
+        ;
+            instmap_delta_init_unreachable(InstMapDelta)
+        ),
         recompute_instmap_delta_1(RecomputeAtomic, SubGoal0, SubGoal, VarTypes,
             InstMap0, _, !RI),
         GoalExpr = negation(SubGoal)
diff --git a/tests/valid/Mercury.options b/tests/valid/Mercury.options
index 0861096..4718a74 100644
--- a/tests/valid/Mercury.options
+++ b/tests/valid/Mercury.options
@@ -114,6 +114,7 @@ MCFLAGS-mc_implied_modes	= --prop-mode-constraints
 MCFLAGS-middle_rec_labels	= --middle-rec
 MCFLAGS-mostly_uniq_mode_inf	= --infer-all
 MCFLAGS-mpj6			= --infer-all
+MCFLAGS-neg_erroneous		= -O3
 MCFLAGS-no_warn_obsolete	= --no-warn-obsolete
 MCFLAGS-no_warn_unresolved_poly = --no-warn-unresolved-polymorphism
 MCFLAGS-opt_det_warn            = --intermodule-optimization --halt-at-warn
diff --git a/tests/valid/Mmakefile b/tests/valid/Mmakefile
index 0bb5fff..755156f 100644
--- a/tests/valid/Mmakefile
+++ b/tests/valid/Mmakefile
@@ -185,6 +185,7 @@ OTHER_PROGS= \
 	multidet_prune1 \
 	multidet_test \
 	nasty_func_test \
+	neg_erroneous \
 	nested_mod_type_bug \
 	nested_module_bug \
 	no_warn_obsolete \
diff --git a/tests/valid/neg_erroneous.m b/tests/valid/neg_erroneous.m
new file mode 100644
index 0000000..f5fb39d
--- /dev/null
+++ b/tests/valid/neg_erroneous.m
@@ -0,0 +1,17 @@
+% The instmap delta of a negated erroneous goal should also be `unreachable'.
+% Software Error: instmap.m: Unexpected: merge_instmapping_delta_2:
error merging var 2
+
+:- module neg_erroneous.
+:- interface.
+
+:- pred f(int::out) is semidet.
+
+:- implementation.
+
+f(X) :-
+    ( semidet_true ->
+        X = 1
+    ;
+        not private_builtin.sorry("sorry"),
+        fail
+    ).
--------------------------------------------------------------------------
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