for review: infinite loops introduced by deforestation
Simon Taylor
stayl at cs.mu.OZ.AU
Tue Nov 3 16:23:18 AEDT 1998
This will need to be committed on both the main and alias branches.
David Overton, could you please review this.
Estimated hours taken: 0.5
compiler/deforest.m:
Fix a bug reported by David Overton for the alias branch.
Don't assume the first goal in a conjunction to be deforested
can be unfolded -- if the unfolding fails an infinite loop
is introduced into the generated code.
The test case for this is library/relation.m on the alias branch.
This came up because of a bug in mode_util:recompute_instmap_delta
on the alias branch -- it doesn't handle constructions of
higher-order terms properly.
Index: deforest.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/deforest.m,v
retrieving revision 1.6
diff -u -t -u -r1.6 deforest.m
--- deforest.m 1998/11/03 05:13:56 1.6
+++ deforest.m 1998/11/03 05:17:10
@@ -842,12 +842,12 @@
pd_debug__message("unfolding first call\n", []),
deforest__unfold_call(no, no, PredId1, ProcId1, Args1,
- EarlierGoal, UnfoldedCall, _),
+ EarlierGoal, UnfoldedCall, DidUnfold),
{ deforest__create_conj(UnfoldedCall, BetweenGoals,
LaterGoal, NonLocals, DeforestGoal0) },
{ set__to_sorted_list(NonLocals, NonLocalsList) },
- ( { RunModes = yes } ->
+ ( { DidUnfold = yes, RunModes = yes } ->
%
% If we did a generalisation step when creating this
@@ -870,7 +870,11 @@
{ FoldGoal = FoldGoal0 },
{ Errors = [] }
),
- ( { Errors = [] } ->
+
+ % We must have been able to unfold the first call to proceed
+ % with the optimization, otherwise we will introduce an
+ % infinite loop in the generated code.
+ ( { DidUnfold = yes, Errors = [] } ->
%
% Create the new version.
More information about the developers
mailing list