[m-rev.] diff: fix bug 128

Zoltan Somogyi zs at csse.unimelb.edu.au
Wed Sep 15 12:27:58 AEST 2010


Fix Mantis bug #128.

compiler/loop_inv.m:
	Fix the bug. The bug was that the loop invariants pass considered
	the unification that constructed a partially instantiated term
	to be an invariant goal, and attempted to hoist it out of its
	predicate. Due to the free variable inside the term, this yielded
	a compiler abort.

	Improve the names of predicates and types.

tests/valid/bug128.m:
	Add the regression test for this bug.

tests/valid/Mmakefile:
tests/valid/Mercury.options:
	Enable the test case.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/extra
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/extra
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops/doc
cvs diff: Diffing boehm_gc/libatomic_ops/src
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/armcc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops/tests
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/m4
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/loop_inv.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/loop_inv.m,v
retrieving revision 1.54
diff -u -b -r1.54 loop_inv.m
--- compiler/loop_inv.m	5 Aug 2010 03:07:08 -0000	1.54
+++ compiler/loop_inv.m	14 Sep 2010 09:44:02 -0000
@@ -132,6 +132,7 @@
 
 :- import_module assoc_list.
 :- import_module bool.
+:- import_module cord.
 :- import_module list.
 :- import_module maybe.
 :- import_module pair.
@@ -168,7 +169,8 @@
         %
         % The recursive calls are the set of calls at the end of each
         % recursive path.
-        invariant_goal_candidates(PredProcId, Body, InvGoals0, RecCalls),
+        invariant_goal_candidates_in_proc(!.ModuleInfo, PredProcId, Body,
+            InvGoals0, RecCalls),
 
         % We can calculate the set of invariant args from the set of
         % recursive calls.
@@ -196,7 +198,7 @@
         %
         % So here we compute the subset of InvGoals (and the corresponding
         % InvVars) that should not be hoisted.
-        dont_hoist(!.ModuleInfo, InvGoals1, DontHoistGoals, DontHoistVars),
+        do_not_hoist(!.ModuleInfo, InvGoals1, DontHoistGoals, DontHoistVars),
 
         InvGoals = InvGoals1 `delete_elems` DontHoistGoals,
         InvVars  = InvVars1  `delete_elems` DontHoistVars,
@@ -212,7 +214,6 @@
         %   the InvGoals;
         % - all non-local vars in InvGoals are also in InvVars.
     ->
-
         % The set of computed invariant vars is the difference between
         % the whole invariant var set and the set of invariant args.
         ComputedInvVars = InvVars `delete_elems` InvArgs,
@@ -255,159 +256,189 @@
                                    %    for this recursive call.
             ).
 
-:- type rec_calls == list(rec_call).
+:- type igc_info
+    --->    igc_info(
+                igc_module_info             :: module_info,
 
-:- type invariant_goal_candidates_acc
-    --->    invariant_goal_candidates_acc(
                 % path_candidates is the list of accumulated invariant
                 % goal candidates.
-                path_candidates         :: hlds_goals,
+                igc_path_candidates         :: cord(hlds_goal),
 
-                % rec_calls is the list of pairs of recursive calls
-                % with the path_candidates up to that point. This is
-                % extended whenever a recursive call is identified.
-                rec_calls               :: rec_calls
+                % rec_calls pairs each recursive call with the list of
+                % path_candidates up to that call. We extend this list
+                % whenever we identify a new recursive call.
+                igc_rec_calls               :: list(rec_call)
             ).
 
-    % invariant_goal_candidates(PredProcId, Body, CandidateInvGoals,
+    % invariant_goal_candidates_in_proc(PredProcId, Body, CandidateInvGoals,
     %   RecCallGoals):
     %
     % Computes (a conservative approximation to) the set of candidate
     % invariant atomic goals in Body and the set of recursive calls
     % in Body identified via PredProcId.
     %
-:- pred invariant_goal_candidates(pred_proc_id::in, hlds_goal::in,
-    hlds_goals::out, hlds_goals::out) is det.
+:- pred invariant_goal_candidates_in_proc(module_info::in, pred_proc_id::in,
+    hlds_goal::in, hlds_goals::out, hlds_goals::out) is det.
 
-invariant_goal_candidates(PredProcId, Body, CandidateInvGoals, RecCallGoals) :-
-    GoalCandidates0 = invariant_goal_candidates_acc([], []),
-    invariant_goal_candidates_2(PredProcId, Body,
+invariant_goal_candidates_in_proc(ModuleInfo, PredProcId, Body,
+        CandidateInvGoals, RecCallGoals) :-
+    GoalCandidates0 = igc_info(ModuleInfo, cord.empty, []),
+    invariant_goal_candidates_in_goal(PredProcId, Body,
         GoalCandidates0, GoalCandidates),
-    GoalCandidates = invariant_goal_candidates_acc(_, RecCalls),
+    GoalCandidates = igc_info(_, _, RecCalls),
     assoc_list.keys_and_values(RecCalls, RecCallGoals, CandidateInvGoalsList),
     CandidateInvGoals = intersect_candidate_inv_goals(CandidateInvGoalsList).
 
 %-----------------------------------------------------------------------------%
 
-:- pred invariant_goal_candidates_2(pred_proc_id::in, hlds_goal::in,
-    invariant_goal_candidates_acc::in, invariant_goal_candidates_acc::out)
-    is det.
+:- pred invariant_goal_candidates_in_goal(pred_proc_id::in, hlds_goal::in,
+    igc_info::in, igc_info::out) is det.
 
-invariant_goal_candidates_2(PPId, Goal, !IGCs) :-
-    Goal = hlds_goal(GoalExpr, GoalInfo),
+invariant_goal_candidates_in_goal(PPId, Goal, !IGCs) :-
+    Goal = hlds_goal(GoalExpr, _GoalInfo),
     (
         GoalExpr = plain_call(PredId, ProcId, _, _, _, _),
         ( proc(PredId, ProcId) = PPId ->
             add_recursive_call(Goal, !IGCs)
         ;
-            invariant_goal_candidates_handle_non_recursive_call(Goal, !IGCs)
+            invariant_goal_candidates_handle_primitive_goal(Goal, !IGCs)
         )
     ;
         ( GoalExpr = generic_call(_, _, _, _)
         ; GoalExpr = unify(_, _, _, _, _)
         ; GoalExpr = call_foreign_proc(_, _, _, _, _, _, _)
         ),
-        invariant_goal_candidates_handle_non_recursive_call(Goal, !IGCs)
+        invariant_goal_candidates_handle_primitive_goal(Goal, !IGCs)
     ;
         GoalExpr = conj(ConjType, Conjuncts),
         (
             ConjType = plain_conj,
-            list.foldl(invariant_goal_candidates_2(PPId), Conjuncts, !IGCs)
+            invariant_goal_candidates_in_plain_conj(PPId, Conjuncts, !IGCs)
         ;
             ConjType = parallel_conj,
-            list.foldl(invariant_goal_candidates_keeping_path_candidates(PPId),
-                Conjuncts, !IGCs)
+            invariant_goal_candidates_in_parallel_conj(PPId, Conjuncts, !IGCs)
         )
     ;
         GoalExpr = disj(Disjuncts),
-        list.foldl(invariant_goal_candidates_keeping_path_candidates(PPId),
-            Disjuncts, !IGCs)
+        invariant_goal_candidates_in_disj(PPId, Disjuncts, !IGCs)
     ;
         GoalExpr = switch(_, _, Cases),
-        list.foldl(invariant_goal_candidates_keeping_path_candidates(PPId),
-            case_goals(Cases), !IGCs)
+        invariant_goal_candidates_in_switch(PPId, Cases, !IGCs)
     ;
-        GoalExpr = negation(SubdGoal),
-        invariant_goal_candidates_keeping_path_candidates(PPId, SubdGoal,
-            !IGCs)
+        GoalExpr = negation(SubGoal),
+        invariant_goal_candidates_keeping_path_candidates(PPId, SubGoal, !IGCs)
     ;
-        GoalExpr = scope(_Reason, SubdGoal),
+        GoalExpr = scope(_Reason, SubGoal),
         % XXX We should specialize the handling of from_ground_term_construct
         % scopes here.
-        invariant_goal_candidates_keeping_path_candidates(PPId, SubdGoal,
-            !IGCs)
+        invariant_goal_candidates_keeping_path_candidates(PPId, SubGoal, !IGCs)
     ;
         GoalExpr = if_then_else(_XVs, Cond, Then, Else),
-        CoTe = hlds_goal(conj(plain_conj, [Cond, Then]), GoalInfo),
-        invariant_goal_candidates_keeping_path_candidates(PPId, CoTe, !IGCs),
+        PathCandidates0 = !.IGCs ^ igc_path_candidates,
+        invariant_goal_candidates_in_goal(PPId, Cond, !IGCs),
+        invariant_goal_candidates_in_goal(PPId, Then, !IGCs),
+        !IGCs ^ igc_path_candidates := PathCandidates0,
         invariant_goal_candidates_keeping_path_candidates(PPId, Else, !IGCs)
     ;
         GoalExpr = shorthand(_),
         % These should have been expanded out by now.
-        unexpected(this_file, "invariant_goal_candidates_2: shorthand")
+        unexpected(this_file, "invariant_goal_candidates_in_goal: shorthand")
     ).
 
 %-----------------------------------------------------------------------------%
 
 :- pred invariant_goal_candidates_keeping_path_candidates(pred_proc_id::in,
-    hlds_goal::in,
-    invariant_goal_candidates_acc::in, invariant_goal_candidates_acc::out)
-    is det.
+    hlds_goal::in, igc_info::in, igc_info::out) is det.
 
 invariant_goal_candidates_keeping_path_candidates(PPId, Goal, !IGCs) :-
-    PathCandidates0 = !.IGCs ^ path_candidates,
-    invariant_goal_candidates_2(PPId, Goal, !IGCs),
-    !IGCs ^ path_candidates := PathCandidates0.
+    PathCandidates0 = !.IGCs ^ igc_path_candidates,
+    invariant_goal_candidates_in_goal(PPId, Goal, !IGCs),
+    !IGCs ^ igc_path_candidates := PathCandidates0.
 
 %-----------------------------------------------------------------------------%
 
-:- func case_goals(list(case)) = hlds_goals.
+:- pred invariant_goal_candidates_in_plain_conj(pred_proc_id::in,
+    list(hlds_goal)::in, igc_info::in, igc_info::out) is det.
 
-case_goals(Cases) =
-    list.map(func(case(_MainConsId, _OtherConsIds, Goal)) = Goal, Cases).
+invariant_goal_candidates_in_plain_conj(_, [], !IGCs).
+invariant_goal_candidates_in_plain_conj(PPId, [Goal | Goals], !IGCs) :-
+    invariant_goal_candidates_in_goal(PPId, Goal, !IGCs),
+    invariant_goal_candidates_in_plain_conj(PPId, Goals, !IGCs).
+
+:- pred invariant_goal_candidates_in_parallel_conj(pred_proc_id::in,
+    list(hlds_goal)::in, igc_info::in, igc_info::out) is det.
+
+invariant_goal_candidates_in_parallel_conj(_, [], !IGCs).
+invariant_goal_candidates_in_parallel_conj(PPId, [Goal | Goals], !IGCs) :-
+    invariant_goal_candidates_keeping_path_candidates(PPId, Goal, !IGCs),
+    invariant_goal_candidates_in_parallel_conj(PPId, Goals, !IGCs).
+
+:- pred invariant_goal_candidates_in_disj(pred_proc_id::in,
+    list(hlds_goal)::in, igc_info::in, igc_info::out) is det.
+
+invariant_goal_candidates_in_disj(_, [], !IGCs).
+invariant_goal_candidates_in_disj(PPId, [Goal | Goals], !IGCs) :-
+    invariant_goal_candidates_keeping_path_candidates(PPId, Goal, !IGCs),
+    invariant_goal_candidates_in_disj(PPId, Goals, !IGCs).
+
+:- pred invariant_goal_candidates_in_switch(pred_proc_id::in,
+    list(case)::in, igc_info::in, igc_info::out) is det.
+
+invariant_goal_candidates_in_switch(_, [], !IGCs).
+invariant_goal_candidates_in_switch(PPId, [Case | Cases], !IGCs) :-
+    Case = case(_, _, Goal),
+    invariant_goal_candidates_keeping_path_candidates(PPId, Goal, !IGCs),
+    invariant_goal_candidates_in_switch(PPId, Cases, !IGCs).
 
 %-----------------------------------------------------------------------------%
 
 :- pred add_recursive_call(hlds_goal::in,
-    invariant_goal_candidates_acc::in, invariant_goal_candidates_acc::out)
-    is det.
+    igc_info::in, igc_info::out) is det.
 
-    % We have to reverse the path_candidates because they are accumulated
-    % in reverse order, whereas we need them in producer-consumer order
-    % as they appear in the procedure.
-    %
 add_recursive_call(Goal, !IGCs) :-
-    !IGCs ^ rec_calls :=
-        [Goal - list.reverse(!.IGCs ^ path_candidates) | !.IGCs ^ rec_calls].
+    RecCall = Goal - cord.list(!.IGCs ^ igc_path_candidates),
+    !IGCs ^ igc_rec_calls := [RecCall | !.IGCs ^ igc_rec_calls].
 
 %-----------------------------------------------------------------------------%
 
     % NOTE: We could hoist semipure goals that have no preceeding impure goals,
-    % but that's a very low-level optimization that is not entirely trivial
+    % but that is a very low-level optimization that is not entirely trivial
     % to implement.
     %
-:- pred invariant_goal_candidates_handle_non_recursive_call(hlds_goal::in,
-    invariant_goal_candidates_acc::in, invariant_goal_candidates_acc::out)
-    is det.
+:- pred invariant_goal_candidates_handle_primitive_goal(hlds_goal::in,
+    igc_info::in, igc_info::out) is det.
 
-invariant_goal_candidates_handle_non_recursive_call(Goal, !IGCs) :-
+invariant_goal_candidates_handle_primitive_goal(Goal, !IGCs) :-
     Goal = hlds_goal(_GoalExpr, GoalInfo),
     (
-        not model_non(GoalInfo),
-        goal_info_get_purity(GoalInfo) = purity_pure
+        Detism = hlds_goal.goal_info_get_determinism(GoalInfo),
+        code_model.determinism_to_code_model(Detism, CodeModel),
+        ( CodeModel = model_det
+        ; CodeModel = model_semi
+        ),
+
+        goal_info_get_purity(GoalInfo) = purity_pure,
+
+        InstMapDelta = goal_info_get_instmap_delta(GoalInfo),
+        instmap_delta_to_assoc_list(InstMapDelta, InstMapDeltaPairs),
+        ModuleInfo = !.IGCs ^ igc_module_info,
+        all_instmap_deltas_are_ground(ModuleInfo, InstMapDeltaPairs)
     ->
-        !IGCs ^ path_candidates := [Goal | !.IGCs ^ path_candidates]
+        !IGCs ^ igc_path_candidates :=
+            snoc(!.IGCs ^ igc_path_candidates, Goal)
     ;
         true
     ).
 
 %-----------------------------------------------------------------------------%
 
-:- pred model_non(hlds_goal_info::in) is semidet.
+:- pred all_instmap_deltas_are_ground(module_info::in,
+    assoc_list(prog_var, mer_inst)::in) is semidet.
 
-model_non(GoalInfo) :-
-    Detism = hlds_goal.goal_info_get_determinism(GoalInfo),
-    code_model.determinism_to_code_model(Detism, model_non).
+all_instmap_deltas_are_ground(_, []).
+all_instmap_deltas_are_ground(ModuleInfo, [_Var - Inst | VarInsts]) :-
+    inst_is_ground(ModuleInfo, Inst),
+    all_instmap_deltas_are_ground(ModuleInfo, VarInsts).
 
 %-----------------------------------------------------------------------------%
 
@@ -569,17 +600,17 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pred dont_hoist(module_info::in, hlds_goals::in,
+:- pred do_not_hoist(module_info::in, hlds_goals::in,
     hlds_goals::out, prog_vars::out) is det.
 
-dont_hoist(ModuleInfo, InvGoals, DontHoistGoals, DontHoistVars) :-
-    list.foldl2(dont_hoist_2(ModuleInfo), InvGoals,
+do_not_hoist(ModuleInfo, InvGoals, DontHoistGoals, DontHoistVars) :-
+    list.foldl2(do_not_hoist_2(ModuleInfo), InvGoals,
         [], DontHoistGoals, [], DontHoistVars).
 
-:- pred dont_hoist_2(module_info::in, hlds_goal::in,
+:- pred do_not_hoist_2(module_info::in, hlds_goal::in,
     hlds_goals::in, hlds_goals::out, prog_vars::in, prog_vars::out) is det.
 
-dont_hoist_2(ModuleInfo, Goal, !DHGs, !DHVs) :-
+do_not_hoist_2(ModuleInfo, Goal, !DHGs, !DHVs) :-
     (
         ( const_construction(Goal)
         ; deconstruction(Goal)
@@ -1114,6 +1145,11 @@
         unexpected(this_file, "used_vars: shorthand")
     ).
 
+:- func case_goals(list(case)) = list(hlds_goal).
+
+case_goals(Cases) =
+    list.map(func(case(_MainConsId, _OtherConsIds, Goal)) = Goal, Cases).
+
 %-----------------------------------------------------------------------------%
 
 :- func uniquely_used_args(module_info, prog_var, mer_mode) = prog_var
cvs diff: Diffing compiler/notes
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/base64
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/fixed
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_allegro
cvs diff: Diffing extras/graphics/mercury_allegro/examples
cvs diff: Diffing extras/graphics/mercury_allegro/samples
cvs diff: Diffing extras/graphics/mercury_allegro/samples/demo
cvs diff: Diffing extras/graphics/mercury_allegro/samples/mandel
cvs diff: Diffing extras/graphics/mercury_allegro/samples/pendulum2
cvs diff: Diffing extras/graphics/mercury_allegro/samples/speed
cvs diff: Diffing extras/graphics/mercury_cairo
cvs diff: Diffing extras/graphics/mercury_cairo/samples
cvs diff: Diffing extras/graphics/mercury_cairo/samples/data
cvs diff: Diffing extras/graphics/mercury_cairo/tutorial
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/log4m
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/monte
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/mopenssl
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/net
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/posix/samples
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/standalone_c
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/java_interface
cvs diff: Diffing samples/java_interface/java_calls_mercury
cvs diff: Diffing samples/java_interface/mercury_calls_java
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/solver_types
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing ssdb
cvs diff: Diffing tests
cvs diff: Diffing tests/analysis
cvs diff: Diffing tests/analysis/ctgc
cvs diff: Diffing tests/analysis/excp
cvs diff: Diffing tests/analysis/ext
cvs diff: Diffing tests/analysis/sharing
cvs diff: Diffing tests/analysis/table
cvs diff: Diffing tests/analysis/trail
cvs diff: Diffing tests/analysis/unused_args
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/stm
cvs diff: Diffing tests/stm/orig
cvs diff: Diffing tests/stm/orig/stm-compiler
cvs diff: Diffing tests/stm/orig/stm-compiler/test1
cvs diff: Diffing tests/stm/orig/stm-compiler/test10
cvs diff: Diffing tests/stm/orig/stm-compiler/test2
cvs diff: Diffing tests/stm/orig/stm-compiler/test3
cvs diff: Diffing tests/stm/orig/stm-compiler/test4
cvs diff: Diffing tests/stm/orig/stm-compiler/test5
cvs diff: Diffing tests/stm/orig/stm-compiler/test6
cvs diff: Diffing tests/stm/orig/stm-compiler/test7
cvs diff: Diffing tests/stm/orig/stm-compiler/test8
cvs diff: Diffing tests/stm/orig/stm-compiler/test9
cvs diff: Diffing tests/stm/orig/stm-compiler-par
cvs diff: Diffing tests/stm/orig/stm-compiler-par/bm1
cvs diff: Diffing tests/stm/orig/stm-compiler-par/bm2
cvs diff: Diffing tests/stm/orig/stm-compiler-par/stmqueue
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test1
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test10
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test11
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test2
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test3
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test4
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test5
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test6
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test7
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test8
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test9
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test1
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test2
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test3
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test4
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test5
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test6
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test7
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test8
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test9
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
Index: tests/valid/Mercury.options
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/Mercury.options,v
retrieving revision 1.70
diff -u -b -r1.70 Mercury.options
--- tests/valid/Mercury.options	14 Sep 2010 09:08:32 -0000	1.70
+++ tests/valid/Mercury.options	14 Sep 2010 09:48:43 -0000
@@ -42,6 +42,7 @@
 MCFLAGS-builtin_false		= --intermodule-optimization
 MCFLAGS-bug85			= -O0 --deforestation
 MCFLAGS-bug100                  = --halt-at-warn
+MCFLAGS-bug128                  = -O5 --loop-invariants
 MCFLAGS-bug134                  = --no-static-ground-terms --no-optimize-dead-procs
 MCFLAGS-bug142                  = --optimise-higher-order --inline-single-use
 MCFLAGS-bug159                  = -w
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.243
diff -u -b -r1.243 Mmakefile
--- tests/valid/Mmakefile	14 Sep 2010 09:08:32 -0000	1.243
+++ tests/valid/Mmakefile	14 Sep 2010 09:48:19 -0000
@@ -69,6 +69,7 @@
 	big_foreign_type \
 	bug85 \
 	bug100 \
+	bug128 \
 	bug134 \
 	bug142 \
 	bug159 \
Index: tests/valid/bug128.m
===================================================================
RCS file: tests/valid/bug128.m
diff -N tests/valid/bug128.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/bug128.m	14 Sep 2010 09:47:56 -0000
@@ -0,0 +1,66 @@
+% vim: ts=4 sw=4 et ft=mercury
+%
+% This a regression test for Mantis bug #128. The bug was that the loop
+% invariants pass considered the unification that constructed a partially
+% instantiated term (_L3-comma in parse_enum0) to be an invariant goal,
+% and attempted to hoist it out of parse_enum0's loop. Due to the free
+% variable inside the term, this yielded a compiler abort.
+
+:- module bug128.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+%--------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module assoc_list.
+:- import_module int.
+:- import_module list.
+:- import_module maybe.
+:- import_module pair.
+:- import_module string.
+
+:- type tokens == assoc_list(int, token).
+
+:- type token
+    --->    comma
+    ;       symbol(string)
+    ;       eof.
+
+main(!IO) :-
+    write_string("Hello, world!\n", !IO).
+
+:- type value
+    --->    value(int, value0).
+
+:- type value0
+    --->    value_sym(string).
+
+:- type parse_res(T)
+    --->    ok(T)
+    ;       error.
+
+:- pred parse_enum0(int::in, assoc_list(string, maybe(value))::in,
+    parse_res(value)::out, tokens::in, tokens::out) is det.
+
+parse_enum0(L, Vs0, Res, !Ts) :-
+    ( if next(_L2-symbol(Sym), !Ts) then
+        ( if next(_L3-comma, !Ts) then
+            Vs = [Sym-no | Vs0],
+            parse_enum0(L, Vs, Res, !Ts)
+        else
+            Res = error
+        )
+    else
+        Res = error
+    ).
+
+:- pred next(pair(int, token)::out, tokens::in, tokens::out) is det.
+
+next(L-T, [L-T | Ts], Ts).
+next(0-eof, [], []).
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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