summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-alias.c
diff options
context:
space:
mode:
authorglisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-21 09:32:21 +0000
committerglisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-21 09:32:21 +0000
commit258bd648e6065446a18fe099309116cf658c4421 (patch)
tree773cf046c0dfd55437a213c2c0d6c24b378ad71e /gcc/tree-ssa-alias.c
parent46caa32dc6684dd49fc9d0be81e57eb5a9c89067 (diff)
downloadgcc-258bd648e6065446a18fe099309116cf658c4421.tar.gz
2014-08-21 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/62112 gcc/ * gimple-iterator.c (gsi_replace): Return whether EH cleanup is needed. * gimple-iterator.h (gsi_replace): Return bool. * tree-ssa-alias.c (ref_may_alias_global_p_1): New helper, code moved from ref_may_alias_global_p. (ref_may_alias_global_p, refs_may_alias_p, ref_maybe_used_by_stmt_p): New overloads. (ref_maybe_used_by_call_p): Take ao_ref* instead of tree. (stmt_kills_ref_p_1): Rename... (stmt_kills_ref_p): ... to this. * tree-ssa-alias.h (ref_may_alias_global_p, ref_maybe_used_by_stmt_p, stmt_kills_ref_p): Declare. * tree-ssa-dse.c (dse_possible_dead_store_p): New argument, use it. Move the self-assignment case... (dse_optimize_stmt): ... here. Handle builtin calls. Remove dead code. gcc/testsuite/ * gcc.dg/tree-ssa/pr62112-1.c: New file. * gcc.dg/tree-ssa/pr62112-2.c: Likewise. * gcc.c-torture/execute/pr35472.c: Add noclone attribute. * gcc.c-torture/execute/20071219-1.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@214262 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r--gcc/tree-ssa-alias.c54
1 files changed, 40 insertions, 14 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 67419a9cb2f..442112adb63 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -330,12 +330,11 @@ ptr_deref_may_alias_ref_p_1 (tree ptr, ao_ref *ref)
return true;
}
-/* Return true whether REF may refer to global memory. */
+/* Returns whether reference REF to BASE may refer to global memory. */
-bool
-ref_may_alias_global_p (tree ref)
+static bool
+ref_may_alias_global_p_1 (tree base)
{
- tree base = get_base_address (ref);
if (DECL_P (base))
return is_global_var (base);
else if (TREE_CODE (base) == MEM_REF
@@ -344,6 +343,20 @@ ref_may_alias_global_p (tree ref)
return true;
}
+bool
+ref_may_alias_global_p (ao_ref *ref)
+{
+ tree base = ao_ref_base (ref);
+ return ref_may_alias_global_p_1 (base);
+}
+
+bool
+ref_may_alias_global_p (tree ref)
+{
+ tree base = get_base_address (ref);
+ return ref_may_alias_global_p_1 (base);
+}
+
/* Return true whether STMT may clobber global memory. */
bool
@@ -1413,6 +1426,14 @@ refs_may_alias_p_1 (ao_ref *ref1, ao_ref *ref2, bool tbaa_p)
#endif
}
+static bool
+refs_may_alias_p (tree ref1, ao_ref *ref2)
+{
+ ao_ref r1;
+ ao_ref_init (&r1, ref1);
+ return refs_may_alias_p_1 (&r1, ref2, true);
+}
+
bool
refs_may_alias_p (tree ref1, tree ref2)
{
@@ -1769,12 +1790,10 @@ process_args:
}
static bool
-ref_maybe_used_by_call_p (gimple call, tree ref)
+ref_maybe_used_by_call_p (gimple call, ao_ref *ref)
{
- ao_ref r;
bool res;
- ao_ref_init (&r, ref);
- res = ref_maybe_used_by_call_p_1 (call, &r);
+ res = ref_maybe_used_by_call_p_1 (call, ref);
if (res)
++alias_stats.ref_maybe_used_by_call_p_may_alias;
else
@@ -1787,7 +1806,7 @@ ref_maybe_used_by_call_p (gimple call, tree ref)
true, otherwise return false. */
bool
-ref_maybe_used_by_stmt_p (gimple stmt, tree ref)
+ref_maybe_used_by_stmt_p (gimple stmt, ao_ref *ref)
{
if (is_gimple_assign (stmt))
{
@@ -1810,14 +1829,13 @@ ref_maybe_used_by_stmt_p (gimple stmt, tree ref)
else if (gimple_code (stmt) == GIMPLE_RETURN)
{
tree retval = gimple_return_retval (stmt);
- tree base;
if (retval
&& TREE_CODE (retval) != SSA_NAME
&& !is_gimple_min_invariant (retval)
&& refs_may_alias_p (retval, ref))
return true;
/* If ref escapes the function then the return acts as a use. */
- base = get_base_address (ref);
+ tree base = ao_ref_base (ref);
if (!base)
;
else if (DECL_P (base))
@@ -1831,6 +1849,14 @@ ref_maybe_used_by_stmt_p (gimple stmt, tree ref)
return true;
}
+bool
+ref_maybe_used_by_stmt_p (gimple stmt, tree ref)
+{
+ ao_ref r;
+ ao_ref_init (&r, ref);
+ return ref_maybe_used_by_stmt_p (stmt, &r);
+}
+
/* If the call in statement CALL may clobber the memory reference REF
return true, otherwise return false. */
@@ -2169,8 +2195,8 @@ stmt_may_clobber_ref_p (gimple stmt, tree ref)
/* If STMT kills the memory reference REF return true, otherwise
return false. */
-static bool
-stmt_kills_ref_p_1 (gimple stmt, ao_ref *ref)
+bool
+stmt_kills_ref_p (gimple stmt, ao_ref *ref)
{
if (!ao_ref_base (ref))
return false;
@@ -2357,7 +2383,7 @@ stmt_kills_ref_p (gimple stmt, tree ref)
{
ao_ref r;
ao_ref_init (&r, ref);
- return stmt_kills_ref_p_1 (stmt, &r);
+ return stmt_kills_ref_p (stmt, &r);
}