diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-09-03 07:15:51 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-09-03 07:15:51 +0000 |
commit | 43ee3f43c8355e623faca36246804e55a784b985 (patch) | |
tree | be310b3c549e4a26b6cc910f7f7dc8dcbd09a174 /gcc/tree-ssa-alias.c | |
parent | c5f9099f3c8c8e7e3a89952504f01eec289117bd (diff) | |
download | gcc-43ee3f43c8355e623faca36246804e55a784b985.tar.gz |
2009-09-03 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 151367
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@151369 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r-- | gcc/tree-ssa-alias.c | 79 |
1 files changed, 59 insertions, 20 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index acfdcae0c0c..7e83a84b82c 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -302,14 +302,6 @@ ptr_deref_may_alias_ref_p_1 (tree ptr, ao_ref *ref) return true; } -static bool -ptr_deref_may_alias_ref_p (tree ptr, tree ref) -{ - ao_ref r; - ao_ref_init (&r, ref); - return ptr_deref_may_alias_ref_p_1 (ptr, &r); -} - /* Dump alias information on FILE. */ @@ -490,6 +482,34 @@ ao_ref_alias_set (ao_ref *ref) return ref->ref_alias_set; } +/* Init an alias-oracle reference representation from a gimple pointer + PTR and a gimple size SIZE in bytes. If SIZE is NULL_TREE the the + size is assumed to be unknown. The access is assumed to be only + to or after of the pointer target, not before it. */ + +void +ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size) +{ + HOST_WIDE_INT t1, t2; + ref->ref = NULL_TREE; + if (TREE_CODE (ptr) == ADDR_EXPR) + ref->base = get_ref_base_and_extent (TREE_OPERAND (ptr, 0), + &ref->offset, &t1, &t2); + else + { + ref->base = build1 (INDIRECT_REF, char_type_node, ptr); + ref->offset = 0; + } + if (size + && host_integerp (size, 0) + && TREE_INT_CST_LOW (size) * 8 / 8 == TREE_INT_CST_LOW (size)) + ref->max_size = ref->size = TREE_INT_CST_LOW (size) * 8; + else + ref->max_size = ref->size = -1; + ref->ref_alias_set = 0; + ref->base_alias_set = 0; +} + /* Return 1 if TYPE1 and TYPE2 are to be considered equivalent for the purpose of TBAA. Return 0 if they are distinct and -1 if we cannot decide. */ @@ -854,7 +874,7 @@ refs_output_dependent_p (tree store1, tree store2) otherwise return false. */ static bool -ref_maybe_used_by_call_p_1 (gimple call, tree ref) +ref_maybe_used_by_call_p_1 (gimple call, ao_ref *ref) { tree base, callee; unsigned i; @@ -865,7 +885,7 @@ ref_maybe_used_by_call_p_1 (gimple call, tree ref) && (flags & (ECF_CONST|ECF_NOVOPS))) goto process_args; - base = get_base_address (ref); + base = ao_ref_base (ref); if (!base) return true; @@ -899,8 +919,14 @@ ref_maybe_used_by_call_p_1 (gimple call, tree ref) case BUILT_IN_STRCAT: case BUILT_IN_STRNCAT: { - tree src = gimple_call_arg (call, 1); - return ptr_deref_may_alias_ref_p (src, ref); + ao_ref dref; + tree size = NULL_TREE; + if (gimple_call_num_args (call) == 3) + size = gimple_call_arg (call, 2); + ao_ref_init_from_ptr_and_size (&dref, + gimple_call_arg (call, 1), + size); + return refs_may_alias_p_1 (&dref, ref, false); } /* The following builtins do not read from memory. */ case BUILT_IN_FREE: @@ -1004,9 +1030,13 @@ process_args: op = TREE_OPERAND (op, 0); if (TREE_CODE (op) != SSA_NAME - && !is_gimple_min_invariant (op) - && refs_may_alias_p (op, ref)) - return true; + && !is_gimple_min_invariant (op)) + { + ao_ref r; + ao_ref_init (&r, op); + if (refs_may_alias_p_1 (&r, ref, true)) + return true; + } } return false; @@ -1015,7 +1045,10 @@ process_args: static bool ref_maybe_used_by_call_p (gimple call, tree ref) { - bool res = ref_maybe_used_by_call_p_1 (call, ref); + ao_ref r; + bool res; + ao_ref_init (&r, ref); + res = ref_maybe_used_by_call_p_1 (call, &r); if (res) ++alias_stats.ref_maybe_used_by_call_p_may_alias; else @@ -1106,15 +1139,21 @@ call_may_clobber_ref_p_1 (gimple call, ao_ref *ref) case BUILT_IN_STPNCPY: case BUILT_IN_STRCAT: case BUILT_IN_STRNCAT: + case BUILT_IN_MEMSET: { - tree dest = gimple_call_arg (call, 0); - return ptr_deref_may_alias_ref_p_1 (dest, ref); + ao_ref dref; + tree size = NULL_TREE; + if (gimple_call_num_args (call) == 3) + size = gimple_call_arg (call, 2); + ao_ref_init_from_ptr_and_size (&dref, + gimple_call_arg (call, 0), + size); + return refs_may_alias_p_1 (&dref, ref, false); } /* Freeing memory kills the pointed-to memory. More importantly the call has to serve as a barrier for moving loads and stores - across it. Same is true for memset. */ + across it. */ case BUILT_IN_FREE: - case BUILT_IN_MEMSET: { tree ptr = gimple_call_arg (call, 0); return ptr_deref_may_alias_ref_p_1 (ptr, ref); |