summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-alias.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-27 12:45:13 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-27 12:45:13 +0000
commit268b9e9e95f56a59a8817b28ad59b53f40fc668d (patch)
tree5e9529982daf11d5b3ab800d4c58bc3fbee99d28 /gcc/tree-ssa-alias.c
parente1910362719612f58bd1ea5050fa7a5175036abc (diff)
downloadgcc-268b9e9e95f56a59a8817b28ad59b53f40fc668d.tar.gz
2009-04-27 Basile Starynkevitch <basile@starynkevitch.net>
MERGED WITH TRUNK r146824:: * gcc/basilys.h: all GTY goes before the identifiers. * gcc/basilys.c: removed errors.h include. * gcc/run-basilys.h: ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@146839 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r--gcc/tree-ssa-alias.c57
1 files changed, 42 insertions, 15 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index a85858e17af..8982280fb2c 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -670,16 +670,6 @@ refs_may_alias_p_1 (tree ref1, tree ref2)
|| INDIRECT_REF_P (ref2)
|| TREE_CODE (ref2) == TARGET_MEM_REF));
- /* Defer to TBAA if possible. */
- if (flag_strict_aliasing
- && !alias_sets_conflict_p (get_alias_set (ref1), get_alias_set (ref2)))
- return false;
-
- /* If one reference is a TARGET_MEM_REF weird things are allowed. */
- if (TREE_CODE (ref1) == TARGET_MEM_REF
- || TREE_CODE (ref2) == TARGET_MEM_REF)
- return true;
-
/* Decompose the references into their base objects and the access. */
base1 = get_ref_base_and_extent (ref1, &offset1, &size1, &max_size1);
base2 = get_ref_base_and_extent (ref2, &offset2, &size2, &max_size2);
@@ -688,19 +678,37 @@ refs_may_alias_p_1 (tree ref1, tree ref2)
*D.1663_44 = VIEW_CONVERT_EXPR<struct DB_LSN>(__tmp$B0F64_59);
which is seen as a struct copy. */
if (TREE_CODE (base1) == SSA_NAME
- || CONSTANT_CLASS_P (base1)
|| TREE_CODE (base2) == SSA_NAME
- || CONSTANT_CLASS_P (base2))
+ || is_gimple_min_invariant (base1)
+ || is_gimple_min_invariant (base2))
return false;
+ /* Defer to simple offset based disambiguation if we have
+ references based on two decls. Do this before defering to
+ TBAA to handle must-alias cases in conformance with the
+ GCC extension of allowing type-punning through unions. */
var1_p = SSA_VAR_P (base1);
var2_p = SSA_VAR_P (base2);
- ind1_p = INDIRECT_REF_P (base1);
- ind2_p = INDIRECT_REF_P (base2);
if (var1_p && var2_p)
return decl_refs_may_alias_p (base1, offset1, max_size1,
base2, offset2, max_size2);
- else if (var1_p && ind2_p)
+
+ /* First defer to TBAA if possible. */
+ if (flag_strict_aliasing
+ && !alias_sets_conflict_p (get_alias_set (ref1), get_alias_set (ref2)))
+ return false;
+
+ /* If one reference is a TARGET_MEM_REF weird things are allowed. Still
+ TBAA disambiguation based on the access type is possible, so bail
+ out only after that check. */
+ if (TREE_CODE (ref1) == TARGET_MEM_REF
+ || TREE_CODE (ref2) == TARGET_MEM_REF)
+ return true;
+
+ /* Dispatch to the pointer-vs-decl or pointer-vs-pointer disambiguators. */
+ ind1_p = INDIRECT_REF_P (base1);
+ ind2_p = INDIRECT_REF_P (base2);
+ if (var1_p && ind2_p)
return indirect_ref_may_alias_decl_p (ref2, TREE_OPERAND (base2, 0),
offset2, max_size2, -1,
ref1, base1,
@@ -754,6 +762,14 @@ 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))
+ goto process_args;
+
/* Check if base is a global static variable that is not read
by the function. */
if (TREE_CODE (base) == VAR_DECL
@@ -866,6 +882,17 @@ 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
+ or the call may implement a threading barrier which we must
+ treat as may-def. */
+ && (TREE_READONLY (base)
+ || !is_global_var (base)))
+ return false;
+
/* Check if base is a global static variable that is not written
by the function. */
if (TREE_CODE (base) == VAR_DECL