This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Java] PATCH for optimization/12547
- From: Jason Merrill <jason at redhat dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: jsturm at redhat dot com, gcc-patches at gcc dot gnu dot org
- Date: Wed, 12 Nov 2003 20:21:17 -0500
- Subject: [Java] PATCH for optimization/12547
This bug on the tree-ssa branch turned out to be an unsharing problem.
jsturm had removed java_tree_inlining_walk_subtrees as part of his work on
Java gimplification; as a result, the unsharing pass wasn't walking into
BLOCKs, so it wasn't really doing any unsharing of Java code. The affected
testcases have shared COND_EXPRs.
I restored the hook, but things were still broken. The problem turned out
to be that it was walking the TREE_CHAIN chain of a BLOCK_EXPR_BODY.
TREE_CHAIN has no defined meaning for an arbitrary expression, and the Java
frontend uses it for chaining the loop stack and such. So if the thing
directly inside a BLOCK is a loop, we walk from there to the next outermost
loop. Boom.
Fixed thus. Andrew, was there something else you were trying to do with
this code?
Tested x86_64-pc-linux-gnu, applied to trunk. tree-ssa version follows.
2003-11-12 Jason Merrill <jason@redhat.com>
PR optimization/12547
* lang.c (java_tree_inlining_walk_subtrees): Just walk
BLOCK_EXPR_BODY directly.
*** java/lang.c.~1~ 2003-11-03 16:39:20.000000000 -0500
--- java/lang.c 2003-11-12 18:34:43.000000000 -0500
*************** java_tree_inlining_walk_subtrees (tree *
*** 840,860 ****
switch (code)
{
case BLOCK:
! if (BLOCK_EXPR_BODY (t))
! {
! tree *prev = &BLOCK_EXPR_BODY (*tp);
! while (*prev)
! {
! WALK_SUBTREE (*prev);
! prev = &TREE_CHAIN (*prev);
! }
! }
return NULL_TREE;
- break;
default:
return NULL_TREE;
}
}
/* Called from unsafe_for_reeval. */
--- 840,853 ----
switch (code)
{
case BLOCK:
! WALK_SUBTREE (BLOCK_EXPR_BODY (t));
return NULL_TREE;
default:
return NULL_TREE;
}
+
+ #undef WALK_SUBTREE
}
/* Called from unsafe_for_reeval. */