summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2011-05-21 01:05:08 +0000
committerDan Gohman <gohman@apple.com>2011-05-21 01:05:08 +0000
commit424b7771711d8be54f8ac65a24d1870d931c18ee (patch)
tree4762419fa98755d9a78caedbebfbbdbd57abcd7d /lib
parentdc5948d47205fd05184a25251e128db6a47b25c2 (diff)
downloadllvm-424b7771711d8be54f8ac65a24d1870d931c18ee.tar.gz
llvm-424b7771711d8be54f8ac65a24d1870d931c18ee.tar.bz2
llvm-424b7771711d8be54f8ac65a24d1870d931c18ee.tar.xz
When BasicAA can determine that two pointers have the same base but
differ by a dynamic offset, return PartialAlias instead of MayAlias. See the comment in the code for details. This fixes PR9971. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131781 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index f1bb8a38f0..f50660844f 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -940,7 +940,17 @@ BasicAliasAnalysis::aliasGEP(const GEPOperator *GEP1, uint64_t V1Size,
return NoAlias;
}
- return MayAlias;
+ // Statically, we can see that the base objects are the same, but the
+ // pointers have dynamic offsets which we can't resolve. And none of our
+ // little tricks above worked.
+ //
+ // TODO: Returning PartialAlias instead of MayAlias is a mild hack; the
+ // practical effect of this is protecting TBAA in the case of dynamic
+ // indices into arrays of unions. An alternative way to solve this would
+ // be to have clang emit extra metadata for unions and/or union accesses.
+ // A union-specific solution wouldn't handle the problem for malloc'd
+ // memory however.
+ return PartialAlias;
}
/// aliasSelect - Provide a bunch of ad-hoc rules to disambiguate a Select