* tree.c (build): A CALL_EXPR has side-effects if its arguments do.
* calls.c (call_expr_flags): New fn.
* tree.h: Declare it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73589
138bc75d-0d04-0410-961f-
82ee72b054a4
+2003-11-14 Jason Merrill <jason@redhat.com>
+
+ PR middle-end/12526
+ * tree.c (build): A CALL_EXPR has side-effects if its arguments do.
+ * calls.c (call_expr_flags): New fn.
+ * tree.h: Declare it.
+
2003-11-13 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/lib1funcs.asm (__udivsi3): Remove.
return flags;
}
+/* Detect flags from a CALL_EXPR. */
+
+int
+call_expr_flags (tree t)
+{
+ int flags;
+ tree decl = get_callee_fndecl (t);
+
+ if (decl)
+ flags = flags_from_decl_or_type (decl);
+ else
+ {
+ t = TREE_TYPE (TREE_OPERAND (t, 0));
+ if (t && TREE_CODE (t) == POINTER_TYPE)
+ flags = flags_from_decl_or_type (TREE_TYPE (t));
+ else
+ flags = 0;
+ }
+
+ return flags;
+}
+
/* Precompute all register parameters as described by ARGS, storing values
into fields within the ARGS array.
int fro;
int constant;
va_list p;
+ tree node;
va_start (p, tt);
{
/* Calls have side-effects, except those to const or
pure functions. */
- tree fn = get_callee_fndecl (t);
-
- if (!fn || (!DECL_IS_PURE (fn) && !TREE_READONLY (fn)))
+ i = call_expr_flags (t);
+ if (!(i & (ECF_CONST | ECF_PURE)))
TREE_SIDE_EFFECTS (t) = 1;
+
+ /* And even those have side-effects if their arguments do. */
+ else for (node = TREE_OPERAND (t, 1); node; node = TREE_CHAIN (node))
+ if (TREE_SIDE_EFFECTS (TREE_VALUE (node)))
+ {
+ TREE_SIDE_EFFECTS (t) = 1;
+ break;
+ }
}
return t;
#define ECF_LIBCALL_BLOCK 4096
extern int flags_from_decl_or_type (tree);
+extern int call_expr_flags (tree);
extern int setjmp_call_p (tree);
extern bool alloca_call_p (tree);