This is the mail archive of the
mailing list for the GCC project.
[tree-ssa] More "const" call elimination infrastructure
- From: law at redhat dot com
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 11 Jun 2003 22:55:16 -0600
- Subject: [tree-ssa] More "const" call elimination infrastructure
- Reply-to: law at redhat dot com
Whee. I just love it when important code gets removed (or never emitted
to begin with).
When inlining a gimplified function TREE_SIDE_EFFECTS needs to be recomputed,
not simply copied from the CALL_EXPR since TREE_SIDE_EFFECTS may be cleared
by the gimplifier for CALL_EXPRs associated with "const" calls.
* tree-inline.c (expand_call_inline): Recalculate TREE_SIDE_EFFECTS
properly when inlining gimplified functions.
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 18.104.22.168
diff -c -3 -p -r22.214.171.124 tree-inline.c
*** tree-inline.c 7 Jun 2003 15:18:36 -0000 126.96.36.199
--- tree-inline.c 12 Jun 2003 04:53:58 -0000
*************** expand_call_inline (tp, walk_subtrees, d
*** 1177,1182 ****
--- 1177,1196 ----
*tp = expr;
+ /* When we gimplify a function call, we may clear TREE_SIDE_EFFECTS
+ on the call if it is to a "const" function. Thus the copy of
+ TREE_SIDE_EFFECTS from the CALL_EXPR to the BIND_EXPR above
+ with result in TREE_SIDE_EFFECTS not being set for the inlined
+ copy of a "const" function.
+ Unfortunately, that is wrong as inlining the function
+ can create/expose interesting side effects (such as setting
+ of a return value).
+ The easiest solution is to simply recalculate TREE_SIDE_EFFECTS
+ for the toplevel expression. */
+ recalculate_side_effects (expr);
*tp = expr;