diff options
| author | Chris Lattner <sabre@nondot.org> | 2004-11-27 18:37:42 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2004-11-27 18:37:42 +0000 |
| commit | 24bba4d2370acb3ddecf54b8b7f2dafc1f4935d2 (patch) | |
| tree | 97a8d88a2ba34bb684449b7f1ef4f74ba50ba72b /llvm/lib/Analysis/AliasSetTracker.cpp | |
| parent | 3e511dd7391ff424de1b35c15203182f4bbaaf1b (diff) | |
| download | bcm5719-llvm-24bba4d2370acb3ddecf54b8b7f2dafc1f4935d2.tar.gz bcm5719-llvm-24bba4d2370acb3ddecf54b8b7f2dafc1f4935d2.zip | |
When merging to alias sets, if they are both must alias, the result is not
a must alias set unless all of the pointers in the resultant set are must
aliased together.
llvm-svn: 18275
Diffstat (limited to 'llvm/lib/Analysis/AliasSetTracker.cpp')
| -rw-r--r-- | llvm/lib/Analysis/AliasSetTracker.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/AliasSetTracker.cpp b/llvm/lib/Analysis/AliasSetTracker.cpp index b351874e883..b277634e6c5 100644 --- a/llvm/lib/Analysis/AliasSetTracker.cpp +++ b/llvm/lib/Analysis/AliasSetTracker.cpp @@ -21,9 +21,9 @@ #include <iostream> using namespace llvm; -/// mergeSetIn - Merge the specified alias set into this alias set... +/// mergeSetIn - Merge the specified alias set into this alias set. /// -void AliasSet::mergeSetIn(AliasSet &AS) { +void AliasSet::mergeSetIn(AliasSet &AS, AliasSetTracker &AST) { assert(!AS.Forward && "Alias set is already forwarding!"); assert(!Forward && "This set is a forwarding set!!"); @@ -31,6 +31,20 @@ void AliasSet::mergeSetIn(AliasSet &AS) { AccessTy |= AS.AccessTy; AliasTy |= AS.AliasTy; + if (AliasTy == MustAlias) { + // Check that these two merged sets really are must aliases. Since both + // used to be must-alias sets, we can just check any pointer from each set + // for aliasing. + AliasAnalysis &AA = AST.getAliasAnalysis(); + HashNodePair *L = getSomePointer(); + HashNodePair *R = AS.getSomePointer(); + + // If the pointers are not a must-alias pair, this set becomes a may alias. + if (AA.alias(L->first, L->second.getSize(), R->first, R->second.getSize()) + != AliasAnalysis::MustAlias) + AliasTy = MayAlias; + } + if (CallSites.empty()) { // Merge call sites... if (!AS.CallSites.empty()) std::swap(CallSites, AS.CallSites); @@ -179,10 +193,10 @@ AliasSet *AliasSetTracker::findAliasSetForPointer(const Value *Ptr, AliasSet *FoundSet = 0; for (iterator I = begin(), E = end(); I != E; ++I) if (!I->Forward && I->aliasesPointer(Ptr, Size, AA)) { - if (FoundSet == 0) { // If this is the first alias set ptr can go into... + if (FoundSet == 0) { // If this is the first alias set ptr can go into. FoundSet = I; // Remember it. - } else { // Otherwise, we must merge the sets... - FoundSet->mergeSetIn(*I); // Merge in contents... + } else { // Otherwise, we must merge the sets. + FoundSet->mergeSetIn(*I, *this); // Merge in contents. } } @@ -205,10 +219,10 @@ AliasSet *AliasSetTracker::findAliasSetForCallSite(CallSite CS) { AliasSet *FoundSet = 0; for (iterator I = begin(), E = end(); I != E; ++I) if (!I->Forward && I->aliasesCallSite(CS, AA)) { - if (FoundSet == 0) { // If this is the first alias set ptr can go into... + if (FoundSet == 0) { // If this is the first alias set ptr can go into. FoundSet = I; // Remember it. - } else if (!I->Forward) { // Otherwise, we must merge the sets... - FoundSet->mergeSetIn(*I); // Merge in contents... + } else if (!I->Forward) { // Otherwise, we must merge the sets. + FoundSet->mergeSetIn(*I, *this); // Merge in contents. } } |

