for review: bug fix for recompute_instmap_delta
Simon Taylor
stayl at cs.mu.OZ.AU
Fri Feb 27 17:07:56 AEDT 1998
Hi Tom,
Could you please review this.
Simon.
Estimated hours taken: 1
compiler/mode_util.m
Fix a bug: recompute_instmap_delta wasn't recomputing
the instmap_deltas of lambda goals.
tests/valid/lambda_recompute.m
Regression test.
Index: compiler/mode_util.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/mode_util.m,v
retrieving revision 1.106
diff -u -r1.106 mode_util.m
--- mode_util.m 1998/02/14 14:39:01 1.106
+++ mode_util.m 1998/02/27 04:38:57
@@ -1072,7 +1072,13 @@
InstMap0, InstMapDelta) -->
(
{ RecomputeAtomic = no },
- { goal_is_atomic(Goal0) }
+ (
+ { goal_is_atomic(Goal0) }
+ ;
+ % Lambda expressions always need to be processed.
+ { Goal0 = unify(_, Rhs, _, _, _) },
+ { Rhs \= lambda_goal(_, _, _, _, _, _) }
+ )
->
{ Goal = Goal0 },
{ GoalInfo = GoalInfo0 },
@@ -1149,10 +1155,28 @@
recompute_instmap_delta_call(PredId, ProcId,
Args, InstMap, InstMapDelta).
-recompute_instmap_delta_2(_, unify(A, B, UniMode0, Uni, E), GoalInfo,
- unify(A, B, UniMode, Uni, E), InstMap, InstMapDelta) -->
- recompute_instmap_delta_unify(Uni, UniMode0, UniMode,
- GoalInfo, InstMap, InstMapDelta).
+recompute_instmap_delta_2(Atomic, unify(A, Rhs0, UniMode0, Uni, E), GoalInfo,
+ unify(A, Rhs, UniMode, Uni, E), InstMap0, InstMapDelta) -->
+ (
+ { Rhs0 = lambda_goal(PorF, NonLocals,
+ LambdaVars, Modes, Det, Goal0) }
+ ->
+ =(ModuleInfo0),
+ { instmap__pre_lambda_update(ModuleInfo0, LambdaVars, Modes,
+ InstMap0, InstMap) },
+ recompute_instmap_delta(Atomic, Goal0, Goal, InstMap),
+ { Rhs = lambda_goal(PorF, NonLocals, LambdaVars,
+ Modes, Det, Goal) }
+ ;
+ { Rhs = Rhs0 }
+ ),
+ ( { Atomic = yes } ->
+ recompute_instmap_delta_unify(Uni, UniMode0, UniMode,
+ GoalInfo, InstMap0, InstMapDelta)
+ ;
+ { UniMode = UniMode0 },
+ { goal_info_get_instmap_delta(GoalInfo, InstMapDelta) }
+ ).
recompute_instmap_delta_2(_, pragma_c_code(A, PredId, ProcId, Args, E, F,
G), _, pragma_c_code(A, PredId, ProcId, Args, E, F, G),
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/staff/zs/imp/tests/valid/Mmakefile,v
retrieving revision 1.11
diff -u -r1.11 Mmakefile
--- Mmakefile 1998/02/25 00:12:14 1.11
+++ Mmakefile 1998/02/27 05:02:29
@@ -50,6 +50,7 @@
lambda_instmap_bug.m \
lambda_quant.m \
lambda_quant_bug.m \
+ lambda_recompute.m \
lambda_struct_bug.m \
lambda_switch.m \
lambda_type.m \
% Regression test.
% Date: Feb 27: 1998.
% Symptom: Software error: variable XX not found.
% Cause: mode_util:recompute_instmap_delta was not recomputing the instmap
% delta of the inner lambda goal after some duplicate call elimination was
% performed.
:- module lambda_recompute.
:- interface.
:- import_module io.
:- pred compile_display_list(display_list, io__state, io__state).
:- mode compile_display_list(out, di, uo) is det.
%------------------------------------------------------------------------------%
:- implementation.
:- import_module bool, char, float, int, list, map, require, std_util, string.
%------------------------------------------------------------------------------%
compile_display_list([mon(PPos, 1)|DList]) -->
{ PPos = 1 - 1 },
{ map__init(MapIKnow) },
{ for(0, 1, (pred(X::in, in, out) is det -->
for(0, 1, (pred(Y::in, in, out) is det -->
( { search(MapIKnow, pos(X, Y), Place) } ->
{ Place = place(Kind, _Flags, Obj) },
( (
{ Kind \= 1 }
;
{ PPos = pos(X, Y) }
)
->
element(place(pos(X, Y), Kind)),
( { Obj = [_N - T|_] } ->
element(thing(pos(X, Y), T))
;
[]
)
;
[]
)
;
[]
)
))
), [], DList) }.
:- pred element(element, display_list, display_list).
:- mode element(in, in, out) is det.
element(E, DL, [E|DL]).
:- type map == map(pos, place).
:- type pos == pair(int).
:- type place
---> place(int, int, list(pair(int))).
:- func pos(int, int) = pos.
:- external(pos/2).
:- type map_i_know
---> map(
list(map),
map,
list(map)
).
:- type element
---> place(pos, int)
; thing(pos, int)
; mon(pos, int)
.
:- type display_list == list(element).
%------------------------------------------------------------------------------%
:- pred get_monst(int, int, io__state, io__state).
:- mode get_monst(in, out, di, uo) is det.
:- external(get_monst/4).
:- pred for(int, int, pred(int, T, T), T, T).
:- mode for(in, in, pred(in, in, out) is det, in, out) is det.
:- mode for(in, in, pred(in, in, out) is semidet, in, out) is semidet.
:- mode for(in, in, pred(in, di, uo) is det, di, uo) is det.
for(Min, Max, Pred, Acc0, Acc) :-
( Min =< Max ->
call(Pred, Min, Acc0, Acc1),
for(Min+1, Max, Pred, Acc1, Acc)
;
Acc = Acc0
).
More information about the developers
mailing list