summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-alias.c
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2010-01-29 18:21:39 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2010-01-29 18:21:39 +0000
commit4b4d1513df0d72611a831542d4d5fc3a2dc51052 (patch)
tree5344e048d3cfa8a76a87a8e11dda42f08b02b060 /gcc/tree-ssa-alias.c
parenta158fb67ebb533c6110686d88eb6dc850f165367 (diff)
downloadgcc-4b4d1513df0d72611a831542d4d5fc3a2dc51052.tar.gz
* tree-ssa-alias.c (same_type_for_tbaa): Return -1 if the types have
the same alias set and their sizes different constantness. (aliasing_component_refs_p): Revert 2009-10-24 change. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156362 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r--gcc/tree-ssa-alias.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index cbb43b5bfea..6ace7e32680 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -537,13 +537,22 @@ same_type_for_tbaa (tree type1, tree type2)
if (TYPE_CANONICAL (type1) == TYPE_CANONICAL (type2))
return 1;
- /* ??? Array types are not properly unified in all cases as we have
+ /* ??? Array types are not properly unified in all cases as we have
spurious changes in the index types for example. Removing this
causes all sorts of problems with the Fortran frontend. */
if (TREE_CODE (type1) == ARRAY_TYPE
&& TREE_CODE (type2) == ARRAY_TYPE)
return -1;
+ /* In Ada, an lvalue of unconstrained type can be used to access an object
+ of one of its constrained subtypes, for example when a function with an
+ unconstrained parameter passed by reference is called on a constrained
+ object and inlined. In this case, the types have the same alias set. */
+ if (TYPE_SIZE (type1) && TYPE_SIZE (type2)
+ && TREE_CONSTANT (TYPE_SIZE (type1)) != TREE_CONSTANT (TYPE_SIZE (type2))
+ && get_alias_set (type1) == get_alias_set (type2))
+ return -1;
+
/* The types are known to be not equal. */
return 0;
}
@@ -600,19 +609,9 @@ aliasing_component_refs_p (tree ref1, tree type1,
offset1 -= offadj;
return ranges_overlap_p (offset1, max_size1, offset2, max_size2);
}
-
- /* We haven't found any common base to apply offset-based disambiguation.
- There are two cases:
- 1. The base access types have the same alias set. This can happen
- in Ada when a function with an unconstrained parameter passed by
- reference is called on a constrained object and inlined: the types
- have the same alias set but aren't equivalent. The references may
- alias in this case.
- 2. The base access types don't have the same alias set, i.e. one set
- is a subset of the other. We have proved that B1 is not in the
- access path B2.path and that B2 is not in the access path B1.path
- so the references may not alias. */
- return get_alias_set (type1) == get_alias_set (type2);
+ /* If we have two type access paths B1.path1 and B2.path2 they may
+ only alias if either B1 is in B2.path2 or B2 is in B1.path1. */
+ return false;
}
/* Return true if two memory references based on the variables BASE1