diff: bug fix for recompute_instmap_delta on switches
Fergus Henderson
fjh at cs.mu.oz.au
Mon Jun 16 16:18:07 AEST 1997
Hi Simon,
Can you please review this change?
(As well as fixing up the bugs, I'm going to clean up the code a bit,
but I'll commit that as a separate change.)
Fix some bugs that caused the compiler to generate incorrect code in
certain cases.
compiler/mode_util.m:
Fix bugs in recompute_instmap_delta_cases.
The old code was passing the wrong instmap to
instmap_delta_bind_var and in the recursive call.
It was passing the instmap _after_ the implicit
functor test unification at the start of the case.
For example, for a switch like this:
% Point 0
(
Var has functor f/1
% Point 1
Case
;
...
)
it was passing the instmap at point 1 rather than the instmap
at point 0.
compiler/instmap.m:
Fix a bug in instmap_delta_bind_var. It was inserting the new inst
for a switch variable in the instmap delta only if it had changed
from point 1 in the above example, but it should have been inserting
it if it had changed from point 0.
Index: instmap.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/instmap.m,v
retrieving revision 1.8
diff -u -r1.8 instmap.m
--- instmap.m 1997/06/11 09:00:05 1.8
+++ instmap.m 1997/06/16 06:04:37
@@ -387,14 +387,15 @@
ModuleInfo = ModuleInfo0
;
InstmapDelta0 = reachable(InstmappingDelta0),
+ instmap__lookup_var(InstMap, Var, OldInst),
( map__search(InstmappingDelta0, Var, Inst0) ->
Inst1 = Inst0
;
- instmap__lookup_var(InstMap, Var, Inst1)
+ Inst1 = OldInst
),
bind_inst_to_functor(Inst1, ConsId, Inst,
ModuleInfo0, ModuleInfo),
- ( Inst \= Inst1 ->
+ ( Inst \= OldInst ->
instmap_delta_set(InstmapDelta0, Var,
Inst, InstmapDelta)
;
Index: mode_util.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/mode_util.m,v
retrieving revision 1.90
diff -u -r1.90 mode_util.m
--- mode_util.m 1997/06/11 05:37:56 1.90
+++ mode_util.m 1997/06/16 05:52:33
@@ -1735,7 +1735,7 @@
recompute_instmap_delta(Atomic, Goal0, Goal,
InstMap, InstMapDelta0),
instmap_delta_bind_var_to_functor(Var, Functor,
- InstMap, InstMapDelta0, InstMapDelta),
+ InstMap0, InstMapDelta0, InstMapDelta),
{ Case = case(Functor, Goal) }.
recompute_instmap_delta_cases(Atomic, Var, [Case0 | Cases0], [Case | Cases],
InstMap0, NonLocals, InstMapDelta) -->
@@ -1745,11 +1745,11 @@
recompute_instmap_delta(Atomic, Goal0, Goal,
InstMap, InstMapDelta0),
instmap_delta_bind_var_to_functor(Var, Functor,
- InstMap, InstMapDelta0, InstMapDelta1),
+ InstMap0, InstMapDelta0, InstMapDelta1),
{ Case = case(Functor, Goal) },
recompute_instmap_delta_cases(Atomic, Var, Cases0, Cases,
- InstMap, NonLocals, InstMapDelta2),
- merge_instmap_delta(InstMap, NonLocals, InstMapDelta1,
+ InstMap0, NonLocals, InstMapDelta2),
+ merge_instmap_delta(InstMap0, NonLocals, InstMapDelta1,
InstMapDelta2, InstMapDelta).
%-----------------------------------------------------------------------------%
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list