diff options
author | Dan Gohman <gohman@apple.com> | 2011-05-21 01:05:08 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2011-05-21 01:05:08 +0000 |
commit | 8b20187c822117845e13a835e81c17c8571e7331 (patch) | |
tree | 73bfa92dd20673b802c6c51cda5d6975ae66bfba /llvm/lib/Analysis/BasicAliasAnalysis.cpp | |
parent | d5d0764b3b07a72cd370396332bbd382ebc876a4 (diff) | |
download | bcm5719-llvm-8b20187c822117845e13a835e81c17c8571e7331.tar.gz bcm5719-llvm-8b20187c822117845e13a835e81c17c8571e7331.zip |
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.
llvm-svn: 131781
Diffstat (limited to 'llvm/lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/BasicAliasAnalysis.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index f1bb8a38f09..f50660844fe 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/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 |