This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lno] Patch: fix wild load from loop duplication
- From: Dale Johannesen <dalej at apple dot com>
- To: "gcc-patches at gcc dot gnu dot org Patches" <gcc-patches at gcc dot gnu dot org>
- Cc: Dale Johannesen <dalej at apple dot com>
- Date: Wed, 16 Jun 2004 11:49:26 -0700
- Subject: [lno] Patch: fix wild load from loop duplication
This fixes a crash building the version of gcc in SPEC with
-fscalar-evolutions.
Approved offline by Zdenek, but here is what is going on:
There is a loop with
a reference to an SSA_NAME which is defined outside the loop. The
loop is copied by tree_duplicate_loop_to_exit, and the variables are
renamed. Since this variable is not defined in the loop,
allocate_new_names
does not set its common.aux, and the code in rename_op expects this to
be 0
in this case. It was not 0 in the crashing case, becuase the SSA_NAME
was
created originally by an earlier run of allocate_new_names on a nested
inner loop, and the aux field of the original variable was incorrectly
propagated
to the copies made by peeling that loop (one of which became the
SSA_NAME
causing the trouble in the outer loop). This just pushes the setting
of the aux
field of the original variable forward to a place after the copies have
been
created.
The algorithm here assumes that the aux field is null upon entry to this
code, so I've added some documentation for that. If it's agreed this
is how
it is supposed to work in general, this should go in mainline.
2004-06-16 Dale Johannesen <dalej@apple.com>
* tree-flow.h (tree_ann_common-d.aux): Document required
behavior.
* tree-ssa-loop-manip.c (allocate_new_names): Don't propagate
new_names into copies.
Index: tree-ssa-loop-manip.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-loop-manip.c,v
retrieving revision 1.1.2.20
diff -u -d -b -w -r1.1.2.20 tree-ssa-loop-manip.c
--- tree-ssa-loop-manip.c 14 Jun 2004 01:58:15 -0000 1.1.2.20
+++ tree-ssa-loop-manip.c 16 Jun 2004 18:19:52 -0000
@@ -168,7 +168,6 @@
{
def = TREE_VALUE (definitions);
new_names = xmalloc (sizeof (tree) * (ndupl + (origin ? 1 : 0)));
- SSA_NAME_AUX (def) = new_names;
abnormal = SSA_NAME_OCCURS_IN_ABNORMAL_PHI (def);
for (i = (origin ? 0 : 1); i <= ndupl; i++)
@@ -176,6 +175,9 @@
new_names[i] = duplicate_ssa_name (def, SSA_NAME_DEF_STMT
(def));
SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_names[i]) = abnormal;
}
+ /* Delay this until now so it doesn't get propagated to the
copies.
+ That would cause problems in the next outer loop. */
+ SSA_NAME_AUX (def) = new_names;
}
}
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow.h,v
retrieving revision 1.1.4.177.2.33
diff -u -d -b -w -r1.1.4.177.2.33 tree-flow.h
--- tree-flow.h 14 Jun 2004 01:58:13 -0000 1.1.4.177.2.33
+++ tree-flow.h 16 Jun 2004 18:19:40 -0000
@@ -48,7 +48,8 @@
/* Annotation type. */
enum tree_ann_type type;
- /* Auxiliary info specific to a pass. */
+ /* Auxiliary info specific to a pass. At all times, this
+ should either point to valid data or be NULL. */
PTR GTY ((skip (""))) aux;
/* The value handle for this expression. Used by GVN-PRE. */