aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2009-04-07 14:19:17 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2009-04-07 14:19:17 +0000
commit0609b35537e3c1c5677632064635e24bc257ee25 (patch)
treeec3035cfe629873603d5a1adbd802860a839d078
parentc27f2f15fde7c742e7b6fa996a7b35cf5e8c9f66 (diff)
downloadgcc-0609b35537e3c1c5677632064635e24bc257ee25.zip
gcc-0609b35537e3c1c5677632064635e24bc257ee25.tar.gz
gcc-0609b35537e3c1c5677632064635e24bc257ee25.tar.bz2
tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Non-aliased decls are only used if passes as parameters or if...
2009-04-07 Richard Guenther <rguenther@suse.de> * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Non-aliased decls are only used if passes as parameters or if they are local statics and the call is not to a builtin. (call_may_clobber_ref_p_1): Likewise. From-SVN: r145676
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/tree-ssa-alias.c33
2 files changed, 38 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c01b7d9..13c4eb2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2009-04-07 Richard Guenther <rguenther@suse.de>
+
+ * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Non-aliased
+ decls are only used if passes as parameters or if they are
+ local statics and the call is not to a builtin.
+ (call_may_clobber_ref_p_1): Likewise.
+
2009-04-07 Paolo Bonzini <bonzini@gnu.org>
* expr.c (do_store_flag): Remove last argument. Simplify code
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index a85858e..f97502a 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -737,7 +737,7 @@ refs_may_alias_p (tree ref1, tree ref2)
static bool
ref_maybe_used_by_call_p_1 (gimple call, tree ref)
{
- tree base;
+ tree base, fndecl;
unsigned i;
int flags = gimple_call_flags (call);
@@ -754,6 +754,20 @@ ref_maybe_used_by_call_p_1 (gimple call, tree ref)
|| !DECL_P (base))
return true;
+ /* If the reference is based on a decl that is not aliased the call
+ cannot possibly use it. */
+ if (DECL_P (base)
+ && !may_be_aliased (base)
+ /* But local statics can be used through recursion! */
+ && (!is_global_var (base)
+ /* But not via builtins.
+ ??? We just assume that this is true if we are not a
+ builtin function ourself. */
+ || (!DECL_BUILT_IN (cfun->decl)
+ && (fndecl = gimple_call_fndecl (call))
+ && DECL_BUILT_IN (fndecl))))
+ goto process_args;
+
/* Check if base is a global static variable that is not read
by the function. */
if (TREE_CODE (base) == VAR_DECL
@@ -851,7 +865,7 @@ ref_maybe_used_by_stmt_p (gimple stmt, tree ref)
static bool
call_may_clobber_ref_p_1 (gimple call, tree ref)
{
- tree base;
+ tree fndecl, base;
/* If the call is pure or const it cannot clobber anything. */
if (gimple_call_flags (call)
@@ -866,6 +880,21 @@ call_may_clobber_ref_p_1 (gimple call, tree ref)
|| CONSTANT_CLASS_P (base))
return false;
+ /* If the reference is based on a decl that is not aliased the call
+ cannot possibly clobber it. */
+ if (DECL_P (base)
+ && !may_be_aliased (base)
+ /* But local non-readonly statics can be modified through recursion! */
+ && (TREE_READONLY (base)
+ || !is_global_var (base)
+ /* But not via builtins.
+ ??? We just assume that this is true if we are not a
+ builtin function ourself. */
+ || (!DECL_BUILT_IN (cfun->decl)
+ && (fndecl = gimple_call_fndecl (call))
+ && DECL_BUILT_IN (fndecl))))
+ return false;
+
/* Check if base is a global static variable that is not written
by the function. */
if (TREE_CODE (base) == VAR_DECL