[m-rev.] diff: document problem with puzzle_detism_bug
Zoltan Somogyi
zs at cs.mu.OZ.AU
Wed Dec 8 19:07:37 AEDT 2004
Document the cause of the failure of the puzzle_detism_bug test case.
compiler/instmap.m:
compiler/mode_util.m:
Document the problem in the places in the code that are responsible for
it.
compiler/handle_options.m:
Add a dump verbosity alias that was helpful in tracking down the
problem.
tests/hard_coded/puzzle_detism_bug.m:
Add a comment pointing to the source of the bug.
Zoltan.
Index: compiler/instmap.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/instmap.m,v
retrieving revision 1.34
diff -u -r1.34 instmap.m
--- compiler/instmap.m 14 Jun 2004 04:16:10 -0000 1.34
+++ compiler/instmap.m 7 Dec 2004 14:05:44 -0000
@@ -982,9 +982,26 @@
),
(
inst_merge(InstA, InstB, yes(VarTypes ^ det_elem(Var)),
- ModuleInfo0, Inst, ModuleInfoPrime)
+ ModuleInfo0, Inst1, ModuleInfoPrime)
->
+ % XXX Given instmap__lookup_var(InstMap, Var, OldInst),
+ % we should probably set Inst not directly from Inst1, but
+ % from a conjunction of OldInst and Inst1. If OldInst says that
+ % Var is bound to f, and Inst1 says that it is bound to g,
+ % Inst should be `unreachable', not bound(g). If OldInst says
+ % that Var is bound to f or g, and Inst1 says that it is bound
+ % to g or h, Inst should say that it is bound(g).
+ %
+ % If there is an invariant to the effect that such situations
+ % are not supposed to arise, then it is being broken, due to
+ % the XXX in recompute_instmap_delta_unify in mode_util.m.
+ %
+ % At present, I believe that the cases we mishandle here can
+ % arise only after inlining, as in puzzle_detism_bug.m in
+ % tests/hard_coded. -zs
+
ModuleInfo1 = ModuleInfoPrime,
+ Inst = Inst1,
map__det_insert(InstMapping0, Var, Inst, InstMapping1)
;
term__var_to_int(Var, VarInt),
Index: compiler/mode_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_util.m,v
retrieving revision 1.158
diff -u -r1.158 mode_util.m
--- compiler/mode_util.m 14 Jun 2004 04:16:22 -0000 1.158
+++ compiler/mode_util.m 7 Dec 2004 13:40:44 -0000
@@ -343,11 +343,6 @@
%-----------------------------------------------------------------------------%
inst_lookup(ModuleInfo, InstName, Inst) :-
- inst_lookup_2(InstName, ModuleInfo, Inst).
-
-:- pred inst_lookup_2(inst_name::in, module_info::in, (inst)::out) is det.
-
-inst_lookup_2(InstName, ModuleInfo, Inst) :-
(
InstName = unify_inst(_, _, _, _),
module_info_insts(ModuleInfo, InstTable),
@@ -429,7 +424,7 @@
ground(Uniq, none), Inst)
;
InstName = typed_inst(Type, TypedInstName),
- inst_lookup_2(TypedInstName, ModuleInfo, Inst0),
+ inst_lookup(ModuleInfo, TypedInstName, Inst0),
map__init(Subst),
propagate_type_into_inst(Type, Subst, ModuleInfo, Inst0, Inst)
).
@@ -1263,6 +1258,12 @@
goal_info_get_instmap_delta(GoalInfo, OldInstMapDelta),
instmap__lookup_var(InstMap, Var, InitialInst),
( instmap_delta_search_var(OldInstMapDelta, Var, FinalInst1) ->
+ % XXX we need to merge the information in InitialInst
+ % and FinalInst1. In puzzle_detism_bug, InitialInst
+ % has a var bound to one function symbol (james), while
+ % FinalInst1 has it bound to another (katherine).
+ % The correct final inst is thus `unreachable', but
+ % we don't return that.
FinalInst = FinalInst1
;
% it wasn't in the instmap_delta, so the inst didn't
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.210
diff -u -r1.210 handle_options.m
--- compiler/handle_options.m 2 Sep 2004 04:31:36 -0000 1.210
+++ compiler/handle_options.m 7 Dec 2004 11:32:29 -0000
@@ -1981,6 +1981,7 @@
convert_dump_alias("ALL", "abcdfgilmnprstuvCDIMPTU").
convert_dump_alias("all", "abcdfgilmnprstuvCMPT").
+convert_dump_alias("allD", "abcdfgilmnprstuvCDMPT").
convert_dump_alias("most", "bcdfgilmnprstuvP").
convert_dump_alias("trans", "bcdglmnstuv").
convert_dump_alias("codegen", "dfnprsu").
cvs diff: Diffing tests/hard_coded
Index: tests/hard_coded/puzzle_detism_bug.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/puzzle_detism_bug.m,v
retrieving revision 1.1
diff -u -r1.1 puzzle_detism_bug.m
--- tests/hard_coded/puzzle_detism_bug.m 2 Dec 2004 08:03:57 -0000 1.1
+++ tests/hard_coded/puzzle_detism_bug.m 7 Dec 2004 14:05:50 -0000
@@ -6,7 +6,14 @@
% Uncaught Mercury exception:
% Software Error: inappropriate determinism inside a negation
%
-% The problem goes away when `--no-inlining' is enabled.
+% The problem goes away when inlining is disabled.
+%
+% The cause of the problem is that the recomputation of instmap_deltas after
+% inlining generates incorrect results. See the XXXs in the predicate
+% merge_instmapping_delta_2 in instmap.m and in recompute_instmap_delta_unify
+% in mode_util.m. There is no easy fix, since there seems to be no existing
+% predicate that takes two insts and computes the intersections of all the
+% bound insts inside them.
%
%----------------------------------------------------------------------------%
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
--------------------------------------------------------------------------
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