Index: include/llvm/Analysis/AliasSetTracker.h =================================================================== --- include/llvm/Analysis/AliasSetTracker.h +++ include/llvm/Analysis/AliasSetTracker.h @@ -212,7 +212,7 @@ bool isForwardingAliasSet() const { return Forward; } /// Merge the specified alias set into this alias set. - void mergeSetIn(AliasSet &AS, AliasSetTracker &AST); + void mergeSetIn(AliasSet &AS, AliasSetTracker &AST, AliasResult AR); // Alias Set iteration - Allow access to all of the pointers which are part of // this alias set. Index: lib/Analysis/AliasSetTracker.cpp =================================================================== --- lib/Analysis/AliasSetTracker.cpp +++ lib/Analysis/AliasSetTracker.cpp @@ -47,7 +47,7 @@ /// mergeSetIn - Merge the specified alias set into this alias set. /// -void AliasSet::mergeSetIn(AliasSet &AS, AliasSetTracker &AST) { +void AliasSet::mergeSetIn(AliasSet &AS, AliasSetTracker &AST, AliasResult AR) { assert(!AS.Forward && "Alias set is already forwarding!"); assert(!Forward && "This set is a forwarding set!!"); @@ -56,20 +56,8 @@ Access |= AS.Access; Alias |= AS.Alias; - if (Alias == SetMustAlias) { - // 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(); - PointerRec *L = getSomePointer(); - PointerRec *R = AS.getSomePointer(); - - // If the pointers are not a must-alias pair, this set becomes a may alias. - if (AA.alias(MemoryLocation(L->getValue(), L->getSize(), L->getAAInfo()), - MemoryLocation(R->getValue(), R->getSize(), R->getAAInfo())) != - MustAlias) - Alias = SetMayAlias; - } + if (Alias == SetMustAlias && AR != MustAlias) + Alias = SetMayAlias; if (Alias == SetMayAlias) { if (WasMustAlias) @@ -299,12 +287,17 @@ AliasSet *FoundSet = nullptr; for (iterator I = begin(), E = end(); I != E;) { iterator Cur = I++; - if (Cur->Forward || !Cur->aliasesPointer(Ptr, Size, AAInfo, AA)) continue; + if (Cur->Forward) + continue; + + AliasResult AR = Cur->aliasesPointer(Ptr, Size, AAInfo, AA); + if (AR == NoAlias) + continue; if (!FoundSet) { // If this is the first alias set ptr can go into. FoundSet = &*Cur; // Remember it. } else { // Otherwise, we must merge the sets. - FoundSet->mergeSetIn(*Cur, *this); // Merge in contents. + FoundSet->mergeSetIn(*Cur, *this, AR); // Merge in contents. } } @@ -320,7 +313,7 @@ if (!FoundSet) // If this is the first alias set ptr can go into. FoundSet = &*Cur; // Remember it. else // Otherwise, we must merge the sets. - FoundSet->mergeSetIn(*Cur, *this); // Merge in contents. + FoundSet->mergeSetIn(*Cur, *this, MayAlias); // Merge in contents. } return FoundSet; } @@ -600,7 +593,7 @@ } // Otherwise, perform the actual merge. - AliasAnyAS->mergeSetIn(*Cur, *this); + AliasAnyAS->mergeSetIn(*Cur, *this, MayAlias); } return *AliasAnyAS;