[m-rev.] diff: remove workaroudns for loop invariant hoisting bug
Julien Fischer
juliensf at cs.mu.OZ.AU
Mon Feb 7 15:38:45 AEDT 2005
On Fri, 4 Feb 2005, Julien Fischer wrote:
>
> On Fri, 4 Feb 2005, Ralph Becket wrote:
>
> > Julien Fischer, Friday, 4 February 2005:
> > >
> > > Actually, I won't remove them at the moment. There seems to be
> > > another problem with robdd module.
> >
> > Not with loop-invariants, I hope...
>
> I'm still looking at it.
>
Actually, this is still the original problem.
At the time Zoltan had a look at this problem and came up with
the following:
> The cause of the bug is in fact in the loop invariant optimization.
> The bug occurs is not restricted to -O5, it also occurs with -O0
> --common-struct --loop-invariants. The problem is that --common-struct
> optimizes a duplicate TypeClassInfo with an unsafe_cast, and loop
> invariant optimization deletes the unsafe_cast (replaces it with true)
> as well as the original construction of the TypeClassInfo.
> From then on, the HLDS is invalid, as it uses TypeClassInfo_for_enum_17
> without defining it; the code generator just happens to be first pass
> to notice the problem. The two relevant procedures (the correct modified
> original and its incorrect loop-invariant-exploiting twin) from the
> HLDS dump immediately after loop invariant optimization show the problem.
>
> I have a modification to the common-struct optimization that doesn't
> cause loop invariant optimization to fail (and generates better code
> than we now do besides), but I don't want to commit it until we know
> *why* the loop invariant optimization is screwing up with the data it
> is given.
> Ralph, since you wrote the loop invariant optimization pass, will you
> please have a look at the problem?
The problem with the loop invariant hoisting has now been fixed AFAIK.
Zoltan, you recently committed some changes the common-struct
optimization. Were these the ones you were referring to above?
I'm going to commit the following test case which is a further
simplified example that triggers the above bug. (At the moment
this bug won't show up because there are workaround in place in the
parts of the compiler/library that trigger it).
Estimated hours taken: 0.1
Branches: main, release
tests/valid/Mercury.options:
tests/valid/Mmakefile:
tests/valid/loop_inv_bug.m:
Add a test case that exposes a bug in loop invariant and
common-struct optimizations.
Index: valid/Mercury.options
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mercury.options,v
retrieving revision 1.14
diff -u -r1.14 Mercury.options
--- valid/Mercury.options 20 Oct 2004 09:45:11 -0000 1.14
+++ valid/Mercury.options 7 Feb 2005 04:07:19 -0000
@@ -78,6 +78,7 @@
MCFLAGS-ite_to_disj = --aditi
MCFLAGS-lambda_inference = --infer-all
MCFLAGS-livevals_seq = -O5 --opt-space
+MCFLAGS-loop_inv_bug = --common-struct --loop-invariants
MCFLAGS-middle_rec_labels = --middle-rec
MCFLAGS-mostly_uniq_mode_inf = --infer-all
MCFLAGS-pred_with_no_modes = --infer-all
Index: valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.146
diff -u -r1.146 Mmakefile
--- valid/Mmakefile 13 Jan 2005 07:09:25 -0000 1.146
+++ valid/Mmakefile 7 Feb 2005 04:05:12 -0000
@@ -130,6 +130,7 @@
livevals_seq \
loop \
loop_in_disj \
+ loop_inv_bug \
merge_ground_any \
middle_rec_labels \
modes_bug \
Index: valid/loop_inv_bug.m
===================================================================
RCS file: valid/loop_inv_bug.m
diff -N valid/loop_inv_bug.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ valid/loop_inv_bug.m 7 Feb 2005 04:06:34 -0000
@@ -0,0 +1,27 @@
+% Causes the following assertion failure in rotd-2005-02-07
+% before:
+%
+% Uncaught Mercury exception:
+% Software Error: map__lookup: key not found
+% Key Type: term.var(parse_tree.prog_data.prog_var_type)
+% Key Value: var(13)
+% Value Type: ll_backend.var_locn.var_state
+%
+% Compile with: mmc -C -O0 --common-struct --loop-invariants
+
+:- module loop_inv_bug.
+
+:- interface.
+
+:- import_module sparse_bitset.
+:- import_module term.
+
+:- pred foo(var(T)::in, sparse_bitset(var(T))::in, sparse_bitset(var(T))::in)
+ is det.
+
+:- implementation.
+
+foo(Var, TrueVars0, FalseVars0) :-
+ sparse_bitset.remove_leq(TrueVars0, Var, TrueVars),
+ sparse_bitset.remove_leq(FalseVars0, Var, FalseVars),
+ foo(Var, TrueVars, FalseVars).
Julien.
--------------------------------------------------------------------------
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