1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[NFC][AA] Prepare to convert AliasResult to class with PartialAlias offset.

Main reason is preparation to transform AliasResult to class that contains
offset for PartialAlias case.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D98027
This commit is contained in:
dfukalov 2021-03-05 13:58:13 +03:00
parent 3385208ac9
commit cb0d7fd331
35 changed files with 275 additions and 271 deletions

View File

@ -504,7 +504,7 @@ public:
/// A trivial helper function to check to see if the specified pointers are /// A trivial helper function to check to see if the specified pointers are
/// no-alias. /// no-alias.
bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) { bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
return alias(LocA, LocB) == NoAlias; return alias(LocA, LocB) == AliasResult::NoAlias;
} }
/// A convenience wrapper around the \c isNoAlias helper interface. /// A convenience wrapper around the \c isNoAlias helper interface.
@ -522,13 +522,13 @@ public:
/// A trivial helper function to check to see if the specified pointers are /// A trivial helper function to check to see if the specified pointers are
/// must-alias. /// must-alias.
bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) { bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
return alias(LocA, LocB) == MustAlias; return alias(LocA, LocB) == AliasResult::MustAlias;
} }
/// A convenience wrapper around the \c isMustAlias helper interface. /// A convenience wrapper around the \c isMustAlias helper interface.
bool isMustAlias(const Value *V1, const Value *V2) { bool isMustAlias(const Value *V1, const Value *V2) {
return alias(V1, LocationSize::precise(1), V2, LocationSize::precise(1)) == return alias(V1, LocationSize::precise(1), V2, LocationSize::precise(1)) ==
MustAlias; AliasResult::MustAlias;
} }
/// Checks whether the given location points to constant memory, or if /// Checks whether the given location points to constant memory, or if
@ -915,11 +915,12 @@ public:
return AA.getModRefBehavior(Call); return AA.getModRefBehavior(Call);
} }
bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) { bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
return alias(LocA, LocB) == MustAlias; return alias(LocA, LocB) == AliasResult::MustAlias;
} }
bool isMustAlias(const Value *V1, const Value *V2) { bool isMustAlias(const Value *V1, const Value *V2) {
return alias(MemoryLocation(V1, LocationSize::precise(1)), return alias(MemoryLocation(V1, LocationSize::precise(1)),
MemoryLocation(V2, LocationSize::precise(1))) == MustAlias; MemoryLocation(V2, LocationSize::precise(1))) ==
AliasResult::MustAlias;
} }
Optional<int64_t> getClobberOffset(const MemoryLocation &LocA, Optional<int64_t> getClobberOffset(const MemoryLocation &LocA,
const MemoryLocation &LocB) const; const MemoryLocation &LocB) const;
@ -1149,7 +1150,7 @@ protected:
public: public:
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
AAQueryInfo &AAQI) { AAQueryInfo &AAQI) {
return MayAlias; return AliasResult::MayAlias;
} }
bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI, bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI,

View File

@ -73,7 +73,7 @@ public:
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
AAQueryInfo &AAQI) { AAQueryInfo &AAQI) {
if (LocA.Ptr == LocB.Ptr) if (LocA.Ptr == LocB.Ptr)
return MustAlias; return AliasResult::MustAlias;
// Comparisons between global variables and other constants should be // Comparisons between global variables and other constants should be
// handled by BasicAA. // handled by BasicAA.
@ -84,7 +84,7 @@ public:
return AAResultBase::alias(LocA, LocB, AAQI); return AAResultBase::alias(LocA, LocB, AAQI);
AliasResult QueryResult = query(LocA, LocB); AliasResult QueryResult = query(LocA, LocB);
if (QueryResult == MayAlias) if (QueryResult == AliasResult::MayAlias)
return AAResultBase::alias(LocA, LocB, AAQI); return AAResultBase::alias(LocA, LocB, AAQI);
return QueryResult; return QueryResult;

View File

@ -288,7 +288,7 @@ protected:
DeleteValueTy DeleteValue, Instruction *MI, BasicBlock *BB, DeleteValueTy DeleteValue, Instruction *MI, BasicBlock *BB,
unsigned NumOperands) unsigned NumOperands)
: MemoryAccess(C, Vty, DeleteValue, BB, NumOperands), : MemoryAccess(C, Vty, DeleteValue, BB, NumOperands),
MemoryInstruction(MI), OptimizedAccessAlias(MayAlias) { MemoryInstruction(MI), OptimizedAccessAlias(AliasResult::MayAlias) {
setDefiningAccess(DMA); setDefiningAccess(DMA);
} }
@ -300,7 +300,7 @@ protected:
} }
void setDefiningAccess(MemoryAccess *DMA, bool Optimized = false, void setDefiningAccess(MemoryAccess *DMA, bool Optimized = false,
Optional<AliasResult> AR = MayAlias) { Optional<AliasResult> AR = AliasResult::MayAlias) {
if (!Optimized) { if (!Optimized) {
setOperand(0, DMA); setOperand(0, DMA);
return; return;

View File

@ -123,7 +123,7 @@ AliasResult AAResults::alias(const MemoryLocation &LocA,
AliasResult AAResults::alias(const MemoryLocation &LocA, AliasResult AAResults::alias(const MemoryLocation &LocA,
const MemoryLocation &LocB, AAQueryInfo &AAQI) { const MemoryLocation &LocB, AAQueryInfo &AAQI) {
AliasResult Result = MayAlias; AliasResult Result = AliasResult::MayAlias;
if (EnableAATrace) { if (EnableAATrace) {
for (unsigned I = 0; I < AAQI.Depth; ++I) for (unsigned I = 0; I < AAQI.Depth; ++I)
@ -135,7 +135,7 @@ AliasResult AAResults::alias(const MemoryLocation &LocA,
AAQI.Depth++; AAQI.Depth++;
for (const auto &AA : AAs) { for (const auto &AA : AAs) {
Result = AA->alias(LocA, LocB, AAQI); Result = AA->alias(LocA, LocB, AAQI);
if (Result != MayAlias) if (Result != AliasResult::MayAlias)
break; break;
} }
AAQI.Depth--; AAQI.Depth--;
@ -148,9 +148,9 @@ AliasResult AAResults::alias(const MemoryLocation &LocA,
} }
if (AAQI.Depth == 0) { if (AAQI.Depth == 0) {
if (Result == NoAlias) if (Result == AliasResult::NoAlias)
++NumNoAlias; ++NumNoAlias;
else if (Result == MustAlias) else if (Result == AliasResult::MustAlias)
++NumMustAlias; ++NumMustAlias;
else else
++NumMayAlias; ++NumMayAlias;
@ -256,12 +256,12 @@ ModRefInfo AAResults::getModRefInfo(const CallBase *Call,
MemoryLocation ArgLoc = MemoryLocation ArgLoc =
MemoryLocation::getForArgument(Call, ArgIdx, TLI); MemoryLocation::getForArgument(Call, ArgIdx, TLI);
AliasResult ArgAlias = alias(ArgLoc, Loc, AAQI); AliasResult ArgAlias = alias(ArgLoc, Loc, AAQI);
if (ArgAlias != NoAlias) { if (ArgAlias != AliasResult::NoAlias) {
ModRefInfo ArgMask = getArgModRefInfo(Call, ArgIdx); ModRefInfo ArgMask = getArgModRefInfo(Call, ArgIdx);
AllArgsMask = unionModRef(AllArgsMask, ArgMask); AllArgsMask = unionModRef(AllArgsMask, ArgMask);
} }
// Conservatively clear IsMustAlias unless only MustAlias is found. // Conservatively clear IsMustAlias unless only MustAlias is found.
IsMustAlias &= (ArgAlias == MustAlias); IsMustAlias &= (ArgAlias == AliasResult::MustAlias);
} }
} }
// Return NoModRef if no alias found with any argument. // Return NoModRef if no alias found with any argument.
@ -449,16 +449,16 @@ FunctionModRefBehavior AAResults::getModRefBehavior(const Function *F) {
raw_ostream &llvm::operator<<(raw_ostream &OS, AliasResult AR) { raw_ostream &llvm::operator<<(raw_ostream &OS, AliasResult AR) {
switch (AR) { switch (AR) {
case NoAlias: case AliasResult::NoAlias:
OS << "NoAlias"; OS << "NoAlias";
break; break;
case MustAlias: case AliasResult::MustAlias:
OS << "MustAlias"; OS << "MustAlias";
break; break;
case MayAlias: case AliasResult::MayAlias:
OS << "MayAlias"; OS << "MayAlias";
break; break;
case PartialAlias: case AliasResult::PartialAlias:
OS << "PartialAlias"; OS << "PartialAlias";
break; break;
} }
@ -485,9 +485,9 @@ ModRefInfo AAResults::getModRefInfo(const LoadInst *L,
// or write the specified memory. // or write the specified memory.
if (Loc.Ptr) { if (Loc.Ptr) {
AliasResult AR = alias(MemoryLocation::get(L), Loc, AAQI); AliasResult AR = alias(MemoryLocation::get(L), Loc, AAQI);
if (AR == NoAlias) if (AR == AliasResult::NoAlias)
return ModRefInfo::NoModRef; return ModRefInfo::NoModRef;
if (AR == MustAlias) if (AR == AliasResult::MustAlias)
return ModRefInfo::MustRef; return ModRefInfo::MustRef;
} }
// Otherwise, a load just reads. // Otherwise, a load just reads.
@ -510,7 +510,7 @@ ModRefInfo AAResults::getModRefInfo(const StoreInst *S,
AliasResult AR = alias(MemoryLocation::get(S), Loc, AAQI); AliasResult AR = alias(MemoryLocation::get(S), Loc, AAQI);
// If the store address cannot alias the pointer in question, then the // If the store address cannot alias the pointer in question, then the
// specified memory cannot be modified by the store. // specified memory cannot be modified by the store.
if (AR == NoAlias) if (AR == AliasResult::NoAlias)
return ModRefInfo::NoModRef; return ModRefInfo::NoModRef;
// If the pointer is a pointer to constant memory, then it could not have // If the pointer is a pointer to constant memory, then it could not have
@ -519,7 +519,7 @@ ModRefInfo AAResults::getModRefInfo(const StoreInst *S,
return ModRefInfo::NoModRef; return ModRefInfo::NoModRef;
// If the store address aliases the pointer as must alias, set Must. // If the store address aliases the pointer as must alias, set Must.
if (AR == MustAlias) if (AR == AliasResult::MustAlias)
return ModRefInfo::MustMod; return ModRefInfo::MustMod;
} }
@ -555,7 +555,7 @@ ModRefInfo AAResults::getModRefInfo(const VAArgInst *V,
AliasResult AR = alias(MemoryLocation::get(V), Loc, AAQI); AliasResult AR = alias(MemoryLocation::get(V), Loc, AAQI);
// If the va_arg address cannot alias the pointer in question, then the // If the va_arg address cannot alias the pointer in question, then the
// specified memory cannot be accessed by the va_arg. // specified memory cannot be accessed by the va_arg.
if (AR == NoAlias) if (AR == AliasResult::NoAlias)
return ModRefInfo::NoModRef; return ModRefInfo::NoModRef;
// If the pointer is a pointer to constant memory, then it could not have // If the pointer is a pointer to constant memory, then it could not have
@ -564,7 +564,7 @@ ModRefInfo AAResults::getModRefInfo(const VAArgInst *V,
return ModRefInfo::NoModRef; return ModRefInfo::NoModRef;
// If the va_arg aliases the pointer as must alias, set Must. // If the va_arg aliases the pointer as must alias, set Must.
if (AR == MustAlias) if (AR == AliasResult::MustAlias)
return ModRefInfo::MustModRef; return ModRefInfo::MustModRef;
} }
@ -629,11 +629,11 @@ ModRefInfo AAResults::getModRefInfo(const AtomicCmpXchgInst *CX,
AliasResult AR = alias(MemoryLocation::get(CX), Loc, AAQI); AliasResult AR = alias(MemoryLocation::get(CX), Loc, AAQI);
// If the cmpxchg address does not alias the location, it does not access // If the cmpxchg address does not alias the location, it does not access
// it. // it.
if (AR == NoAlias) if (AR == AliasResult::NoAlias)
return ModRefInfo::NoModRef; return ModRefInfo::NoModRef;
// If the cmpxchg address aliases the pointer as must alias, set Must. // If the cmpxchg address aliases the pointer as must alias, set Must.
if (AR == MustAlias) if (AR == AliasResult::MustAlias)
return ModRefInfo::MustModRef; return ModRefInfo::MustModRef;
} }
@ -657,11 +657,11 @@ ModRefInfo AAResults::getModRefInfo(const AtomicRMWInst *RMW,
AliasResult AR = alias(MemoryLocation::get(RMW), Loc, AAQI); AliasResult AR = alias(MemoryLocation::get(RMW), Loc, AAQI);
// If the atomicrmw address does not alias the location, it does not access // If the atomicrmw address does not alias the location, it does not access
// it. // it.
if (AR == NoAlias) if (AR == AliasResult::NoAlias)
return ModRefInfo::NoModRef; return ModRefInfo::NoModRef;
// If the atomicrmw address aliases the pointer as must alias, set Must. // If the atomicrmw address aliases the pointer as must alias, set Must.
if (AR == MustAlias) if (AR == AliasResult::MustAlias)
return ModRefInfo::MustModRef; return ModRefInfo::MustModRef;
} }
@ -751,9 +751,9 @@ ModRefInfo AAResults::callCapturesBefore(const Instruction *I,
// is impossible to alias the pointer we're checking. If not, we have to // is impossible to alias the pointer we're checking. If not, we have to
// assume that the call could touch the pointer, even though it doesn't // assume that the call could touch the pointer, even though it doesn't
// escape. // escape.
if (AR != MustAlias) if (AR != AliasResult::MustAlias)
IsMustAlias = false; IsMustAlias = false;
if (AR == NoAlias) if (AR == AliasResult::NoAlias)
continue; continue;
if (Call->doesNotAccessMemory(ArgNo)) if (Call->doesNotAccessMemory(ArgNo))
continue; continue;

View File

@ -151,19 +151,19 @@ void AAEvaluator::runInternal(Function &F, AAResults &AA) {
AliasResult AR = AA.alias(*I1, I1Size, *I2, I2Size); AliasResult AR = AA.alias(*I1, I1Size, *I2, I2Size);
switch (AR) { switch (AR) {
case NoAlias: case AliasResult::NoAlias:
PrintResults(AR, PrintNoAlias, *I1, *I2, F.getParent()); PrintResults(AR, PrintNoAlias, *I1, *I2, F.getParent());
++NoAliasCount; ++NoAliasCount;
break; break;
case MayAlias: case AliasResult::MayAlias:
PrintResults(AR, PrintMayAlias, *I1, *I2, F.getParent()); PrintResults(AR, PrintMayAlias, *I1, *I2, F.getParent());
++MayAliasCount; ++MayAliasCount;
break; break;
case PartialAlias: case AliasResult::PartialAlias:
PrintResults(AR, PrintPartialAlias, *I1, *I2, F.getParent()); PrintResults(AR, PrintPartialAlias, *I1, *I2, F.getParent());
++PartialAliasCount; ++PartialAliasCount;
break; break;
case MustAlias: case AliasResult::MustAlias:
PrintResults(AR, PrintMustAlias, *I1, *I2, F.getParent()); PrintResults(AR, PrintMustAlias, *I1, *I2, F.getParent());
++MustAliasCount; ++MustAliasCount;
break; break;
@ -178,19 +178,19 @@ void AAEvaluator::runInternal(Function &F, AAResults &AA) {
AliasResult AR = AA.alias(MemoryLocation::get(cast<LoadInst>(Load)), AliasResult AR = AA.alias(MemoryLocation::get(cast<LoadInst>(Load)),
MemoryLocation::get(cast<StoreInst>(Store))); MemoryLocation::get(cast<StoreInst>(Store)));
switch (AR) { switch (AR) {
case NoAlias: case AliasResult::NoAlias:
PrintLoadStoreResults(AR, PrintNoAlias, Load, Store, F.getParent()); PrintLoadStoreResults(AR, PrintNoAlias, Load, Store, F.getParent());
++NoAliasCount; ++NoAliasCount;
break; break;
case MayAlias: case AliasResult::MayAlias:
PrintLoadStoreResults(AR, PrintMayAlias, Load, Store, F.getParent()); PrintLoadStoreResults(AR, PrintMayAlias, Load, Store, F.getParent());
++MayAliasCount; ++MayAliasCount;
break; break;
case PartialAlias: case AliasResult::PartialAlias:
PrintLoadStoreResults(AR, PrintPartialAlias, Load, Store, F.getParent()); PrintLoadStoreResults(AR, PrintPartialAlias, Load, Store, F.getParent());
++PartialAliasCount; ++PartialAliasCount;
break; break;
case MustAlias: case AliasResult::MustAlias:
PrintLoadStoreResults(AR, PrintMustAlias, Load, Store, F.getParent()); PrintLoadStoreResults(AR, PrintMustAlias, Load, Store, F.getParent());
++MustAliasCount; ++MustAliasCount;
break; break;
@ -205,19 +205,19 @@ void AAEvaluator::runInternal(Function &F, AAResults &AA) {
AliasResult AR = AA.alias(MemoryLocation::get(cast<StoreInst>(*I1)), AliasResult AR = AA.alias(MemoryLocation::get(cast<StoreInst>(*I1)),
MemoryLocation::get(cast<StoreInst>(*I2))); MemoryLocation::get(cast<StoreInst>(*I2)));
switch (AR) { switch (AR) {
case NoAlias: case AliasResult::NoAlias:
PrintLoadStoreResults(AR, PrintNoAlias, *I1, *I2, F.getParent()); PrintLoadStoreResults(AR, PrintNoAlias, *I1, *I2, F.getParent());
++NoAliasCount; ++NoAliasCount;
break; break;
case MayAlias: case AliasResult::MayAlias:
PrintLoadStoreResults(AR, PrintMayAlias, *I1, *I2, F.getParent()); PrintLoadStoreResults(AR, PrintMayAlias, *I1, *I2, F.getParent());
++MayAliasCount; ++MayAliasCount;
break; break;
case PartialAlias: case AliasResult::PartialAlias:
PrintLoadStoreResults(AR, PrintPartialAlias, *I1, *I2, F.getParent()); PrintLoadStoreResults(AR, PrintPartialAlias, *I1, *I2, F.getParent());
++PartialAliasCount; ++PartialAliasCount;
break; break;
case MustAlias: case AliasResult::MustAlias:
PrintLoadStoreResults(AR, PrintMustAlias, *I1, *I2, F.getParent()); PrintLoadStoreResults(AR, PrintMustAlias, *I1, *I2, F.getParent());
++MustAliasCount; ++MustAliasCount;
break; break;

View File

@ -63,9 +63,9 @@ void AliasSet::mergeSetIn(AliasSet &AS, AliasSetTracker &AST) {
PointerRec *R = AS.getSomePointer(); PointerRec *R = AS.getSomePointer();
// If the pointers are not a must-alias pair, this set becomes a may alias. // 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()), if (!AA.isMustAlias(
MemoryLocation(R->getValue(), R->getSize(), R->getAAInfo())) != MemoryLocation(L->getValue(), L->getSize(), L->getAAInfo()),
MustAlias) MemoryLocation(R->getValue(), R->getSize(), R->getAAInfo())))
Alias = SetMayAlias; Alias = SetMayAlias;
} }
@ -141,11 +141,11 @@ void AliasSet::addPointer(AliasSetTracker &AST, PointerRec &Entry,
AliasResult Result = AA.alias( AliasResult Result = AA.alias(
MemoryLocation(P->getValue(), P->getSize(), P->getAAInfo()), MemoryLocation(P->getValue(), P->getSize(), P->getAAInfo()),
MemoryLocation(Entry.getValue(), Size, AAInfo)); MemoryLocation(Entry.getValue(), Size, AAInfo));
if (Result != MustAlias) { if (Result != AliasResult::MustAlias) {
Alias = SetMayAlias; Alias = SetMayAlias;
AST.TotalMayAliasSetSize += size(); AST.TotalMayAliasSetSize += size();
} }
assert(Result != NoAlias && "Cannot be part of must set!"); assert(Result != AliasResult::NoAlias && "Cannot be part of must set!");
} else if (!SkipSizeUpdate) } else if (!SkipSizeUpdate)
P->updateSizeAndAAInfo(Size, AAInfo); P->updateSizeAndAAInfo(Size, AAInfo);
} }
@ -195,7 +195,7 @@ AliasResult AliasSet::aliasesPointer(const Value *Ptr, LocationSize Size,
const AAMDNodes &AAInfo, const AAMDNodes &AAInfo,
AliasAnalysis &AA) const { AliasAnalysis &AA) const {
if (AliasAny) if (AliasAny)
return MayAlias; return AliasResult::MayAlias;
if (Alias == SetMustAlias) { if (Alias == SetMustAlias) {
assert(UnknownInsts.empty() && "Illegal must alias set!"); assert(UnknownInsts.empty() && "Illegal must alias set!");
@ -211,11 +211,13 @@ AliasResult AliasSet::aliasesPointer(const Value *Ptr, LocationSize Size,
// If this is a may-alias set, we have to check all of the pointers in the set // If this is a may-alias set, we have to check all of the pointers in the set
// to be sure it doesn't alias the set... // to be sure it doesn't alias the set...
for (iterator I = begin(), E = end(); I != E; ++I) for (iterator I = begin(), E = end(); I != E; ++I) {
if (AliasResult AR = AA.alias( AliasResult AR =
MemoryLocation(Ptr, Size, AAInfo), AA.alias(MemoryLocation(Ptr, Size, AAInfo),
MemoryLocation(I.getPointer(), I.getSize(), I.getAAInfo()))) MemoryLocation(I.getPointer(), I.getSize(), I.getAAInfo()));
if (AR != AliasResult::NoAlias)
return AR; return AR;
}
// Check the unknown instructions... // Check the unknown instructions...
if (!UnknownInsts.empty()) { if (!UnknownInsts.empty()) {
@ -223,10 +225,10 @@ AliasResult AliasSet::aliasesPointer(const Value *Ptr, LocationSize Size,
if (auto *Inst = getUnknownInst(i)) if (auto *Inst = getUnknownInst(i))
if (isModOrRefSet( if (isModOrRefSet(
AA.getModRefInfo(Inst, MemoryLocation(Ptr, Size, AAInfo)))) AA.getModRefInfo(Inst, MemoryLocation(Ptr, Size, AAInfo))))
return MayAlias; return AliasResult::MayAlias;
} }
return NoAlias; return AliasResult::NoAlias;
} }
bool AliasSet::aliasesUnknownInst(const Instruction *Inst, bool AliasSet::aliasesUnknownInst(const Instruction *Inst,
@ -307,10 +309,10 @@ AliasSet *AliasSetTracker::mergeAliasSetsForPointer(const Value *Ptr,
continue; continue;
AliasResult AR = AS.aliasesPointer(Ptr, Size, AAInfo, AA); AliasResult AR = AS.aliasesPointer(Ptr, Size, AAInfo, AA);
if (AR == NoAlias) if (AR == AliasResult::NoAlias)
continue; continue;
if (AR != MustAlias) if (AR != AliasResult::MustAlias)
MustAliasAll = false; MustAliasAll = false;
if (!FoundSet) { if (!FoundSet) {

View File

@ -850,10 +850,10 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call,
AliasResult AR = getBestAAResults().alias( AliasResult AR = getBestAAResults().alias(
MemoryLocation::getBeforeOrAfter(*CI), MemoryLocation::getBeforeOrAfter(*CI),
MemoryLocation::getBeforeOrAfter(Object), AAQI); MemoryLocation::getBeforeOrAfter(Object), AAQI);
if (AR != MustAlias) if (AR != AliasResult::MustAlias)
IsMustAlias = false; IsMustAlias = false;
// Operand doesn't alias 'Object', continue looking for other aliases // Operand doesn't alias 'Object', continue looking for other aliases
if (AR == NoAlias) if (AR == AliasResult::NoAlias)
continue; continue;
// Operand aliases 'Object', but call doesn't modify it. Strengthen // Operand aliases 'Object', but call doesn't modify it. Strengthen
// initial assumption and keep looking in case if there are more aliases. // initial assumption and keep looking in case if there are more aliases.
@ -895,8 +895,8 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call,
if (isMallocOrCallocLikeFn(Call, &TLI)) { if (isMallocOrCallocLikeFn(Call, &TLI)) {
// Be conservative if the accessed pointer may alias the allocation - // Be conservative if the accessed pointer may alias the allocation -
// fallback to the generic handling below. // fallback to the generic handling below.
if (getBestAAResults().alias(MemoryLocation::getBeforeOrAfter(Call), if (getBestAAResults().alias(MemoryLocation::getBeforeOrAfter(Call), Loc,
Loc, AAQI) == NoAlias) AAQI) == AliasResult::NoAlias)
return ModRefInfo::NoModRef; return ModRefInfo::NoModRef;
} }
@ -910,9 +910,9 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call,
getBestAAResults().alias(MemoryLocation::getForDest(Inst), Loc, AAQI); getBestAAResults().alias(MemoryLocation::getForDest(Inst), Loc, AAQI);
// It's also possible for Loc to alias both src and dest, or neither. // It's also possible for Loc to alias both src and dest, or neither.
ModRefInfo rv = ModRefInfo::NoModRef; ModRefInfo rv = ModRefInfo::NoModRef;
if (SrcAA != NoAlias) if (SrcAA != AliasResult::NoAlias)
rv = setRef(rv); rv = setRef(rv);
if (DestAA != NoAlias) if (DestAA != AliasResult::NoAlias)
rv = setMod(rv); rv = setMod(rv);
return rv; return rv;
} }
@ -1032,7 +1032,7 @@ AliasResult BasicAAResult::aliasGEP(
// compile-time constant. // compile-time constant.
if (!DecompGEP1.HasCompileTimeConstantScale || if (!DecompGEP1.HasCompileTimeConstantScale ||
!DecompGEP2.HasCompileTimeConstantScale) !DecompGEP2.HasCompileTimeConstantScale)
return MayAlias; return AliasResult::MayAlias;
assert(DecompGEP1.Base == UnderlyingV1 && DecompGEP2.Base == UnderlyingV2 && assert(DecompGEP1.Base == UnderlyingV1 && DecompGEP2.Base == UnderlyingV2 &&
"DecomposeGEPExpression returned a result different from " "DecomposeGEPExpression returned a result different from "
@ -1048,14 +1048,14 @@ AliasResult BasicAAResult::aliasGEP(
if (*DecompGEP1.InBounds && DecompGEP1.VarIndices.empty() && if (*DecompGEP1.InBounds && DecompGEP1.VarIndices.empty() &&
V2Size.hasValue() && DecompGEP1.Offset.sge(V2Size.getValue()) && V2Size.hasValue() && DecompGEP1.Offset.sge(V2Size.getValue()) &&
isBaseOfObject(DecompGEP2.Base)) isBaseOfObject(DecompGEP2.Base))
return NoAlias; return AliasResult::NoAlias;
if (isa<GEPOperator>(V2)) { if (isa<GEPOperator>(V2)) {
// Symmetric case to above. // Symmetric case to above.
if (*DecompGEP2.InBounds && DecompGEP1.VarIndices.empty() && if (*DecompGEP2.InBounds && DecompGEP1.VarIndices.empty() &&
V1Size.hasValue() && DecompGEP1.Offset.sle(-V1Size.getValue()) && V1Size.hasValue() && DecompGEP1.Offset.sle(-V1Size.getValue()) &&
isBaseOfObject(DecompGEP1.Base)) isBaseOfObject(DecompGEP1.Base))
return NoAlias; return AliasResult::NoAlias;
} }
// For GEPs with identical offsets, we can preserve the size and AAInfo // For GEPs with identical offsets, we can preserve the size and AAInfo
@ -1072,8 +1072,9 @@ AliasResult BasicAAResult::aliasGEP(
// If we get a No or May, then return it immediately, no amount of analysis // If we get a No or May, then return it immediately, no amount of analysis
// will improve this situation. // will improve this situation.
if (BaseAlias != MustAlias) { if (BaseAlias != AliasResult::MustAlias) {
assert(BaseAlias == NoAlias || BaseAlias == MayAlias); assert(BaseAlias == AliasResult::NoAlias ||
BaseAlias == AliasResult::MayAlias);
return BaseAlias; return BaseAlias;
} }
@ -1116,9 +1117,9 @@ AliasResult BasicAAResult::aliasGEP(
AAQI.setClobberOffset(LeftPtr, RightPtr, LSize, RSize, AAQI.setClobberOffset(LeftPtr, RightPtr, LSize, RSize,
Off.getSExtValue()); Off.getSExtValue());
} }
return PartialAlias; return AliasResult::PartialAlias;
} }
return NoAlias; return AliasResult::NoAlias;
} }
} }
@ -1169,7 +1170,7 @@ AliasResult BasicAAResult::aliasGEP(
if (V1Size.hasValue() && V2Size.hasValue() && if (V1Size.hasValue() && V2Size.hasValue() &&
ModOffset.uge(V2Size.getValue()) && ModOffset.uge(V2Size.getValue()) &&
(GCD - ModOffset).uge(V1Size.getValue())) (GCD - ModOffset).uge(V1Size.getValue()))
return NoAlias; return AliasResult::NoAlias;
// If we know all the variables are non-negative, then the total offset is // If we know all the variables are non-negative, then the total offset is
// also non-negative and >= DecompGEP1.Offset. We have the following layout: // also non-negative and >= DecompGEP1.Offset. We have the following layout:
@ -1177,14 +1178,14 @@ AliasResult BasicAAResult::aliasGEP(
// If DecompGEP1.Offset >= V2Size, the accesses don't alias. // If DecompGEP1.Offset >= V2Size, the accesses don't alias.
if (AllNonNegative && V2Size.hasValue() && if (AllNonNegative && V2Size.hasValue() &&
DecompGEP1.Offset.uge(V2Size.getValue())) DecompGEP1.Offset.uge(V2Size.getValue()))
return NoAlias; return AliasResult::NoAlias;
// Similarly, if the variables are non-positive, then the total offset is // Similarly, if the variables are non-positive, then the total offset is
// also non-positive and <= DecompGEP1.Offset. We have the following layout: // also non-positive and <= DecompGEP1.Offset. We have the following layout:
// [TotalOffset, TotalOffset+V1Size) ... [0, V2Size) // [TotalOffset, TotalOffset+V1Size) ... [0, V2Size)
// If -DecompGEP1.Offset >= V1Size, the accesses don't alias. // If -DecompGEP1.Offset >= V1Size, the accesses don't alias.
if (AllNonPositive && V1Size.hasValue() && if (AllNonPositive && V1Size.hasValue() &&
(-DecompGEP1.Offset).uge(V1Size.getValue())) (-DecompGEP1.Offset).uge(V1Size.getValue()))
return NoAlias; return AliasResult::NoAlias;
if (V1Size.hasValue() && V2Size.hasValue()) { if (V1Size.hasValue() && V2Size.hasValue()) {
// Try to determine whether abs(VarIndex) > 0. // Try to determine whether abs(VarIndex) > 0.
@ -1215,19 +1216,19 @@ AliasResult BasicAAResult::aliasGEP(
// or higher both do not alias. // or higher both do not alias.
if (OffsetLo.isNegative() && (-OffsetLo).uge(V1Size.getValue()) && if (OffsetLo.isNegative() && (-OffsetLo).uge(V1Size.getValue()) &&
OffsetHi.isNonNegative() && OffsetHi.uge(V2Size.getValue())) OffsetHi.isNonNegative() && OffsetHi.uge(V2Size.getValue()))
return NoAlias; return AliasResult::NoAlias;
} }
} }
if (constantOffsetHeuristic(DecompGEP1.VarIndices, V1Size, V2Size, if (constantOffsetHeuristic(DecompGEP1.VarIndices, V1Size, V2Size,
DecompGEP1.Offset, &AC, DT)) DecompGEP1.Offset, &AC, DT))
return NoAlias; return AliasResult::NoAlias;
} }
// Statically, we can see that the base objects are the same, but the // 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 // pointers have dynamic offsets which we can't resolve. And none of our
// little tricks above worked. // little tricks above worked.
return MayAlias; return AliasResult::MayAlias;
} }
static AliasResult MergeAliasResults(AliasResult A, AliasResult B) { static AliasResult MergeAliasResults(AliasResult A, AliasResult B) {
@ -1235,11 +1236,11 @@ static AliasResult MergeAliasResults(AliasResult A, AliasResult B) {
if (A == B) if (A == B)
return A; return A;
// A mix of PartialAlias and MustAlias is PartialAlias. // A mix of PartialAlias and MustAlias is PartialAlias.
if ((A == PartialAlias && B == MustAlias) || if ((A == AliasResult::PartialAlias && B == AliasResult::MustAlias) ||
(B == PartialAlias && A == MustAlias)) (B == AliasResult::PartialAlias && A == AliasResult::MustAlias))
return PartialAlias; return AliasResult::PartialAlias;
// Otherwise, we don't know anything. // Otherwise, we don't know anything.
return MayAlias; return AliasResult::MayAlias;
} }
/// Provides a bunch of ad-hoc rules to disambiguate a Select instruction /// Provides a bunch of ad-hoc rules to disambiguate a Select instruction
@ -1255,8 +1256,8 @@ BasicAAResult::aliasSelect(const SelectInst *SI, LocationSize SISize,
AliasResult Alias = getBestAAResults().alias( AliasResult Alias = getBestAAResults().alias(
MemoryLocation(SI->getTrueValue(), SISize), MemoryLocation(SI->getTrueValue(), SISize),
MemoryLocation(SI2->getTrueValue(), V2Size), AAQI); MemoryLocation(SI2->getTrueValue(), V2Size), AAQI);
if (Alias == MayAlias) if (Alias == AliasResult::MayAlias)
return MayAlias; return AliasResult::MayAlias;
AliasResult ThisAlias = getBestAAResults().alias( AliasResult ThisAlias = getBestAAResults().alias(
MemoryLocation(SI->getFalseValue(), SISize), MemoryLocation(SI->getFalseValue(), SISize),
MemoryLocation(SI2->getFalseValue(), V2Size), AAQI); MemoryLocation(SI2->getFalseValue(), V2Size), AAQI);
@ -1268,8 +1269,8 @@ BasicAAResult::aliasSelect(const SelectInst *SI, LocationSize SISize,
AliasResult Alias = getBestAAResults().alias( AliasResult Alias = getBestAAResults().alias(
MemoryLocation(V2, V2Size), MemoryLocation(V2, V2Size),
MemoryLocation(SI->getTrueValue(), SISize), AAQI); MemoryLocation(SI->getTrueValue(), SISize), AAQI);
if (Alias == MayAlias) if (Alias == AliasResult::MayAlias)
return MayAlias; return AliasResult::MayAlias;
AliasResult ThisAlias = getBestAAResults().alias( AliasResult ThisAlias = getBestAAResults().alias(
MemoryLocation(V2, V2Size), MemoryLocation(V2, V2Size),
@ -1298,7 +1299,7 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
*Alias = MergeAliasResults(*Alias, ThisAlias); *Alias = MergeAliasResults(*Alias, ThisAlias);
else else
Alias = ThisAlias; Alias = ThisAlias;
if (*Alias == MayAlias) if (*Alias == AliasResult::MayAlias)
break; break;
} }
return *Alias; return *Alias;
@ -1327,7 +1328,7 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
// is if both sides are PHI nodes. In which case, this is O(m x n) time // is if both sides are PHI nodes. In which case, this is O(m x n) time
// where 'm' and 'n' are the number of PHI sources. // where 'm' and 'n' are the number of PHI sources.
if (PhiValueSet.size() > MaxLookupSearchDepth) if (PhiValueSet.size() > MaxLookupSearchDepth)
return MayAlias; return AliasResult::MayAlias;
// Add the values to V1Srcs // Add the values to V1Srcs
for (Value *PV1 : PhiValueSet) { for (Value *PV1 : PhiValueSet) {
if (CheckForRecPhi(PV1)) if (CheckForRecPhi(PV1))
@ -1347,7 +1348,7 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
// that we handle the single phi case as that lets us handle LCSSA // that we handle the single phi case as that lets us handle LCSSA
// phi nodes and (combined with the recursive phi handling) simple // phi nodes and (combined with the recursive phi handling) simple
// pointer induction variable patterns. // pointer induction variable patterns.
return MayAlias; return AliasResult::MayAlias;
} }
OnePhi = PV1; OnePhi = PV1;
} }
@ -1362,14 +1363,14 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
if (OnePhi && UniqueSrc.size() > 1) if (OnePhi && UniqueSrc.size() > 1)
// Out of an abundance of caution, allow only the trivial lcssa and // Out of an abundance of caution, allow only the trivial lcssa and
// recursive phi cases. // recursive phi cases.
return MayAlias; return AliasResult::MayAlias;
} }
// If V1Srcs is empty then that means that the phi has no underlying non-phi // If V1Srcs is empty then that means that the phi has no underlying non-phi
// value. This should only be possible in blocks unreachable from the entry // value. This should only be possible in blocks unreachable from the entry
// block, but return MayAlias just in case. // block, but return MayAlias just in case.
if (V1Srcs.empty()) if (V1Srcs.empty())
return MayAlias; return AliasResult::MayAlias;
// If this PHI node is recursive, indicate that the pointer may be moved // If this PHI node is recursive, indicate that the pointer may be moved
// across iterations. We can only prove NoAlias if different underlying // across iterations. We can only prove NoAlias if different underlying
@ -1398,12 +1399,12 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
// Early exit if the check of the first PHI source against V2 is MayAlias. // Early exit if the check of the first PHI source against V2 is MayAlias.
// Other results are not possible. // Other results are not possible.
if (Alias == MayAlias) if (Alias == AliasResult::MayAlias)
return MayAlias; return AliasResult::MayAlias;
// With recursive phis we cannot guarantee that MustAlias/PartialAlias will // With recursive phis we cannot guarantee that MustAlias/PartialAlias will
// remain valid to all elements and needs to conservatively return MayAlias. // remain valid to all elements and needs to conservatively return MayAlias.
if (isRecursive && Alias != NoAlias) if (isRecursive && Alias != AliasResult::NoAlias)
return MayAlias; return AliasResult::MayAlias;
// If all sources of the PHI node NoAlias or MustAlias V2, then returns // If all sources of the PHI node NoAlias or MustAlias V2, then returns
// NoAlias / MustAlias. Otherwise, returns MayAlias. // NoAlias / MustAlias. Otherwise, returns MayAlias.
@ -1413,7 +1414,7 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
AliasResult ThisAlias = getBestAAResults().alias( AliasResult ThisAlias = getBestAAResults().alias(
MemoryLocation(V2, V2Size), MemoryLocation(V, PNSize), *UseAAQI); MemoryLocation(V2, V2Size), MemoryLocation(V, PNSize), *UseAAQI);
Alias = MergeAliasResults(ThisAlias, Alias); Alias = MergeAliasResults(ThisAlias, Alias);
if (Alias == MayAlias) if (Alias == AliasResult::MayAlias)
break; break;
} }
@ -1428,7 +1429,7 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
// If either of the memory references is empty, it doesn't matter what the // If either of the memory references is empty, it doesn't matter what the
// pointer values are. // pointer values are.
if (V1Size.isZero() || V2Size.isZero()) if (V1Size.isZero() || V2Size.isZero())
return NoAlias; return AliasResult::NoAlias;
// Strip off any casts if they exist. // Strip off any casts if they exist.
V1 = V1->stripPointerCastsForAliasAnalysis(); V1 = V1->stripPointerCastsForAliasAnalysis();
@ -1437,7 +1438,7 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
// If V1 or V2 is undef, the result is NoAlias because we can always pick a // If V1 or V2 is undef, the result is NoAlias because we can always pick a
// value for undef that aliases nothing in the program. // value for undef that aliases nothing in the program.
if (isa<UndefValue>(V1) || isa<UndefValue>(V2)) if (isa<UndefValue>(V1) || isa<UndefValue>(V2))
return NoAlias; return AliasResult::NoAlias;
// Are we checking for alias of the same value? // Are we checking for alias of the same value?
// Because we look 'through' phi nodes, we could look at "Value" pointers from // Because we look 'through' phi nodes, we could look at "Value" pointers from
@ -1446,10 +1447,10 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
// happen by looking at the visited phi nodes and making sure they cannot // happen by looking at the visited phi nodes and making sure they cannot
// reach the value. // reach the value.
if (isValueEqualInPotentialCycles(V1, V2)) if (isValueEqualInPotentialCycles(V1, V2))
return MustAlias; return AliasResult::MustAlias;
if (!V1->getType()->isPointerTy() || !V2->getType()->isPointerTy()) if (!V1->getType()->isPointerTy() || !V2->getType()->isPointerTy())
return NoAlias; // Scalars cannot alias each other return AliasResult::NoAlias; // Scalars cannot alias each other
// Figure out what objects these things are pointing to if we can. // Figure out what objects these things are pointing to if we can.
const Value *O1 = getUnderlyingObject(V1, MaxLookupSearchDepth); const Value *O1 = getUnderlyingObject(V1, MaxLookupSearchDepth);
@ -1459,26 +1460,26 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
// don't alias any other pointer. // don't alias any other pointer.
if (const ConstantPointerNull *CPN = dyn_cast<ConstantPointerNull>(O1)) if (const ConstantPointerNull *CPN = dyn_cast<ConstantPointerNull>(O1))
if (!NullPointerIsDefined(&F, CPN->getType()->getAddressSpace())) if (!NullPointerIsDefined(&F, CPN->getType()->getAddressSpace()))
return NoAlias; return AliasResult::NoAlias;
if (const ConstantPointerNull *CPN = dyn_cast<ConstantPointerNull>(O2)) if (const ConstantPointerNull *CPN = dyn_cast<ConstantPointerNull>(O2))
if (!NullPointerIsDefined(&F, CPN->getType()->getAddressSpace())) if (!NullPointerIsDefined(&F, CPN->getType()->getAddressSpace()))
return NoAlias; return AliasResult::NoAlias;
if (O1 != O2) { if (O1 != O2) {
// If V1/V2 point to two different objects, we know that we have no alias. // If V1/V2 point to two different objects, we know that we have no alias.
if (isIdentifiedObject(O1) && isIdentifiedObject(O2)) if (isIdentifiedObject(O1) && isIdentifiedObject(O2))
return NoAlias; return AliasResult::NoAlias;
// Constant pointers can't alias with non-const isIdentifiedObject objects. // Constant pointers can't alias with non-const isIdentifiedObject objects.
if ((isa<Constant>(O1) && isIdentifiedObject(O2) && !isa<Constant>(O2)) || if ((isa<Constant>(O1) && isIdentifiedObject(O2) && !isa<Constant>(O2)) ||
(isa<Constant>(O2) && isIdentifiedObject(O1) && !isa<Constant>(O1))) (isa<Constant>(O2) && isIdentifiedObject(O1) && !isa<Constant>(O1)))
return NoAlias; return AliasResult::NoAlias;
// Function arguments can't alias with things that are known to be // Function arguments can't alias with things that are known to be
// unambigously identified at the function level. // unambigously identified at the function level.
if ((isa<Argument>(O1) && isIdentifiedFunctionLocal(O2)) || if ((isa<Argument>(O1) && isIdentifiedFunctionLocal(O2)) ||
(isa<Argument>(O2) && isIdentifiedFunctionLocal(O1))) (isa<Argument>(O2) && isIdentifiedFunctionLocal(O1)))
return NoAlias; return AliasResult::NoAlias;
// If one pointer is the result of a call/invoke or load and the other is a // If one pointer is the result of a call/invoke or load and the other is a
// non-escaping local object within the same function, then we know the // non-escaping local object within the same function, then we know the
@ -1491,10 +1492,10 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
// nocapture value to other functions as long as they don't capture it. // nocapture value to other functions as long as they don't capture it.
if (isEscapeSource(O1) && if (isEscapeSource(O1) &&
isNonEscapingLocalObject(O2, &AAQI.IsCapturedCache)) isNonEscapingLocalObject(O2, &AAQI.IsCapturedCache))
return NoAlias; return AliasResult::NoAlias;
if (isEscapeSource(O2) && if (isEscapeSource(O2) &&
isNonEscapingLocalObject(O1, &AAQI.IsCapturedCache)) isNonEscapingLocalObject(O1, &AAQI.IsCapturedCache))
return NoAlias; return AliasResult::NoAlias;
} }
// If the size of one access is larger than the entire object on the other // If the size of one access is larger than the entire object on the other
@ -1506,7 +1507,7 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
(isObjectSmallerThan( (isObjectSmallerThan(
O1, getMinimalExtentFrom(*V2, V2Size, DL, NullIsValidLocation), DL, O1, getMinimalExtentFrom(*V2, V2Size, DL, NullIsValidLocation), DL,
TLI, NullIsValidLocation))) TLI, NullIsValidLocation)))
return NoAlias; return AliasResult::NoAlias;
// If one the accesses may be before the accessed pointer, canonicalize this // If one the accesses may be before the accessed pointer, canonicalize this
// by using unknown after-pointer sizes for both accesses. This is // by using unknown after-pointer sizes for both accesses. This is
@ -1525,7 +1526,7 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
// enough to be very rarely hit, while still being small enough to avoid // enough to be very rarely hit, while still being small enough to avoid
// stack overflows. // stack overflows.
if (AAQI.Depth >= 512) if (AAQI.Depth >= 512)
return MayAlias; return AliasResult::MayAlias;
// Check the cache before climbing up use-def chains. This also terminates // Check the cache before climbing up use-def chains. This also terminates
// otherwise infinitely recursive queries. // otherwise infinitely recursive queries.
@ -1533,7 +1534,7 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
if (V1 > V2) if (V1 > V2)
std::swap(Locs.first, Locs.second); std::swap(Locs.first, Locs.second);
const auto &Pair = AAQI.AliasCache.try_emplace( const auto &Pair = AAQI.AliasCache.try_emplace(
Locs, AAQueryInfo::CacheEntry{NoAlias, 0}); Locs, AAQueryInfo::CacheEntry{AliasResult::NoAlias, 0});
if (!Pair.second) { if (!Pair.second) {
auto &Entry = Pair.first->second; auto &Entry = Pair.first->second;
if (!Entry.isDefinitive()) { if (!Entry.isDefinitive()) {
@ -1554,9 +1555,10 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
auto &Entry = It->second; auto &Entry = It->second;
// Check whether a NoAlias assumption has been used, but disproven. // Check whether a NoAlias assumption has been used, but disproven.
bool AssumptionDisproven = Entry.NumAssumptionUses > 0 && Result != NoAlias; bool AssumptionDisproven =
Entry.NumAssumptionUses > 0 && Result != AliasResult::NoAlias;
if (AssumptionDisproven) if (AssumptionDisproven)
Result = MayAlias; Result = AliasResult::MayAlias;
// This is a definitive result now, when considered as a root query. // This is a definitive result now, when considered as a root query.
AAQI.NumAssumptionUses -= Entry.NumAssumptionUses; AAQI.NumAssumptionUses -= Entry.NumAssumptionUses;
@ -1572,7 +1574,8 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
// The result may still be based on assumptions higher up in the chain. // The result may still be based on assumptions higher up in the chain.
// Remember it, so it can be purged from the cache later. // Remember it, so it can be purged from the cache later.
if (OrigNumAssumptionUses != AAQI.NumAssumptionUses && Result != MayAlias) if (OrigNumAssumptionUses != AAQI.NumAssumptionUses &&
Result != AliasResult::MayAlias)
AAQI.AssumptionBasedResults.push_back(Locs); AAQI.AssumptionBasedResults.push_back(Locs);
return Result; return Result;
} }
@ -1583,31 +1586,31 @@ AliasResult BasicAAResult::aliasCheckRecursive(
AAQueryInfo &AAQI, const Value *O1, const Value *O2) { AAQueryInfo &AAQI, const Value *O1, const Value *O2) {
if (const GEPOperator *GV1 = dyn_cast<GEPOperator>(V1)) { if (const GEPOperator *GV1 = dyn_cast<GEPOperator>(V1)) {
AliasResult Result = aliasGEP(GV1, V1Size, V2, V2Size, O1, O2, AAQI); AliasResult Result = aliasGEP(GV1, V1Size, V2, V2Size, O1, O2, AAQI);
if (Result != MayAlias) if (Result != AliasResult::MayAlias)
return Result; return Result;
} else if (const GEPOperator *GV2 = dyn_cast<GEPOperator>(V2)) { } else if (const GEPOperator *GV2 = dyn_cast<GEPOperator>(V2)) {
AliasResult Result = aliasGEP(GV2, V2Size, V1, V1Size, O2, O1, AAQI); AliasResult Result = aliasGEP(GV2, V2Size, V1, V1Size, O2, O1, AAQI);
if (Result != MayAlias) if (Result != AliasResult::MayAlias)
return Result; return Result;
} }
if (const PHINode *PN = dyn_cast<PHINode>(V1)) { if (const PHINode *PN = dyn_cast<PHINode>(V1)) {
AliasResult Result = aliasPHI(PN, V1Size, V2, V2Size, AAQI); AliasResult Result = aliasPHI(PN, V1Size, V2, V2Size, AAQI);
if (Result != MayAlias) if (Result != AliasResult::MayAlias)
return Result; return Result;
} else if (const PHINode *PN = dyn_cast<PHINode>(V2)) { } else if (const PHINode *PN = dyn_cast<PHINode>(V2)) {
AliasResult Result = aliasPHI(PN, V2Size, V1, V1Size, AAQI); AliasResult Result = aliasPHI(PN, V2Size, V1, V1Size, AAQI);
if (Result != MayAlias) if (Result != AliasResult::MayAlias)
return Result; return Result;
} }
if (const SelectInst *S1 = dyn_cast<SelectInst>(V1)) { if (const SelectInst *S1 = dyn_cast<SelectInst>(V1)) {
AliasResult Result = aliasSelect(S1, V1Size, V2, V2Size, AAQI); AliasResult Result = aliasSelect(S1, V1Size, V2, V2Size, AAQI);
if (Result != MayAlias) if (Result != AliasResult::MayAlias)
return Result; return Result;
} else if (const SelectInst *S2 = dyn_cast<SelectInst>(V2)) { } else if (const SelectInst *S2 = dyn_cast<SelectInst>(V2)) {
AliasResult Result = aliasSelect(S2, V2Size, V1, V1Size, AAQI); AliasResult Result = aliasSelect(S2, V2Size, V1, V1Size, AAQI);
if (Result != MayAlias) if (Result != AliasResult::MayAlias)
return Result; return Result;
} }
@ -1618,10 +1621,10 @@ AliasResult BasicAAResult::aliasCheckRecursive(
if (V1Size.isPrecise() && V2Size.isPrecise() && if (V1Size.isPrecise() && V2Size.isPrecise() &&
(isObjectSize(O1, V1Size.getValue(), DL, TLI, NullIsValidLocation) || (isObjectSize(O1, V1Size.getValue(), DL, TLI, NullIsValidLocation) ||
isObjectSize(O2, V2Size.getValue(), DL, TLI, NullIsValidLocation))) isObjectSize(O2, V2Size.getValue(), DL, TLI, NullIsValidLocation)))
return PartialAlias; return AliasResult::PartialAlias;
} }
return MayAlias; return AliasResult::MayAlias;
} }
/// Check whether two Values can be considered equivalent. /// Check whether two Values can be considered equivalent.

View File

@ -850,7 +850,7 @@ AliasResult CFLAndersAAResult::query(const MemoryLocation &LocA,
auto *ValB = LocB.Ptr; auto *ValB = LocB.Ptr;
if (!ValA->getType()->isPointerTy() || !ValB->getType()->isPointerTy()) if (!ValA->getType()->isPointerTy() || !ValB->getType()->isPointerTy())
return NoAlias; return AliasResult::NoAlias;
auto *Fn = parentFunctionOfValue(ValA); auto *Fn = parentFunctionOfValue(ValA);
if (!Fn) { if (!Fn) {
@ -861,7 +861,7 @@ AliasResult CFLAndersAAResult::query(const MemoryLocation &LocA,
LLVM_DEBUG( LLVM_DEBUG(
dbgs() dbgs()
<< "CFLAndersAA: could not extract parent function information.\n"); << "CFLAndersAA: could not extract parent function information.\n");
return MayAlias; return AliasResult::MayAlias;
} }
} else { } else {
assert(!parentFunctionOfValue(ValB) || parentFunctionOfValue(ValB) == Fn); assert(!parentFunctionOfValue(ValB) || parentFunctionOfValue(ValB) == Fn);
@ -872,15 +872,15 @@ AliasResult CFLAndersAAResult::query(const MemoryLocation &LocA,
// AliasMap lookup // AliasMap lookup
if (FunInfo->mayAlias(ValA, LocA.Size, ValB, LocB.Size)) if (FunInfo->mayAlias(ValA, LocA.Size, ValB, LocB.Size))
return MayAlias; return AliasResult::MayAlias;
return NoAlias; return AliasResult::NoAlias;
} }
AliasResult CFLAndersAAResult::alias(const MemoryLocation &LocA, AliasResult CFLAndersAAResult::alias(const MemoryLocation &LocA,
const MemoryLocation &LocB, const MemoryLocation &LocB,
AAQueryInfo &AAQI) { AAQueryInfo &AAQI) {
if (LocA.Ptr == LocB.Ptr) if (LocA.Ptr == LocB.Ptr)
return MustAlias; return AliasResult::MustAlias;
// Comparisons between global variables and other constants should be // Comparisons between global variables and other constants should be
// handled by BasicAA. // handled by BasicAA.
@ -891,7 +891,7 @@ AliasResult CFLAndersAAResult::alias(const MemoryLocation &LocA,
return AAResultBase::alias(LocA, LocB, AAQI); return AAResultBase::alias(LocA, LocB, AAQI);
AliasResult QueryResult = query(LocA, LocB); AliasResult QueryResult = query(LocA, LocB);
if (QueryResult == MayAlias) if (QueryResult == AliasResult::MayAlias)
return AAResultBase::alias(LocA, LocB, AAQI); return AAResultBase::alias(LocA, LocB, AAQI);
return QueryResult; return QueryResult;

View File

@ -269,7 +269,7 @@ AliasResult CFLSteensAAResult::query(const MemoryLocation &LocA,
auto *ValB = const_cast<Value *>(LocB.Ptr); auto *ValB = const_cast<Value *>(LocB.Ptr);
if (!ValA->getType()->isPointerTy() || !ValB->getType()->isPointerTy()) if (!ValA->getType()->isPointerTy() || !ValB->getType()->isPointerTy())
return NoAlias; return AliasResult::NoAlias;
Function *Fn = nullptr; Function *Fn = nullptr;
Function *MaybeFnA = const_cast<Function *>(parentFunctionOfValue(ValA)); Function *MaybeFnA = const_cast<Function *>(parentFunctionOfValue(ValA));
@ -280,7 +280,7 @@ AliasResult CFLSteensAAResult::query(const MemoryLocation &LocA,
LLVM_DEBUG( LLVM_DEBUG(
dbgs() dbgs()
<< "CFLSteensAA: could not extract parent function information.\n"); << "CFLSteensAA: could not extract parent function information.\n");
return MayAlias; return AliasResult::MayAlias;
} }
if (MaybeFnA) { if (MaybeFnA) {
@ -298,11 +298,11 @@ AliasResult CFLSteensAAResult::query(const MemoryLocation &LocA,
auto &Sets = MaybeInfo->getStratifiedSets(); auto &Sets = MaybeInfo->getStratifiedSets();
auto MaybeA = Sets.find(InstantiatedValue{ValA, 0}); auto MaybeA = Sets.find(InstantiatedValue{ValA, 0});
if (!MaybeA.hasValue()) if (!MaybeA.hasValue())
return MayAlias; return AliasResult::MayAlias;
auto MaybeB = Sets.find(InstantiatedValue{ValB, 0}); auto MaybeB = Sets.find(InstantiatedValue{ValB, 0});
if (!MaybeB.hasValue()) if (!MaybeB.hasValue())
return MayAlias; return AliasResult::MayAlias;
auto SetA = *MaybeA; auto SetA = *MaybeA;
auto SetB = *MaybeB; auto SetB = *MaybeB;
@ -320,14 +320,14 @@ AliasResult CFLSteensAAResult::query(const MemoryLocation &LocA,
// - AttrEscaped do not alias globals/arguments, but they may alias // - AttrEscaped do not alias globals/arguments, but they may alias
// AttrUnknown values // AttrUnknown values
if (SetA.Index == SetB.Index) if (SetA.Index == SetB.Index)
return MayAlias; return AliasResult::MayAlias;
if (AttrsA.none() || AttrsB.none()) if (AttrsA.none() || AttrsB.none())
return NoAlias; return AliasResult::NoAlias;
if (hasUnknownOrCallerAttr(AttrsA) || hasUnknownOrCallerAttr(AttrsB)) if (hasUnknownOrCallerAttr(AttrsA) || hasUnknownOrCallerAttr(AttrsB))
return MayAlias; return AliasResult::MayAlias;
if (isGlobalOrArgAttr(AttrsA) && isGlobalOrArgAttr(AttrsB)) if (isGlobalOrArgAttr(AttrsA) && isGlobalOrArgAttr(AttrsB))
return MayAlias; return AliasResult::MayAlias;
return NoAlias; return AliasResult::NoAlias;
} }
AnalysisKey CFLSteensAA::Key; AnalysisKey CFLSteensAA::Key;

View File

@ -657,8 +657,8 @@ static AliasResult underlyingObjectsAlias(AAResults *AA,
MemoryLocation::getBeforeOrAfter(LocA.Ptr, LocA.AATags); MemoryLocation::getBeforeOrAfter(LocA.Ptr, LocA.AATags);
MemoryLocation LocBS = MemoryLocation LocBS =
MemoryLocation::getBeforeOrAfter(LocB.Ptr, LocB.AATags); MemoryLocation::getBeforeOrAfter(LocB.Ptr, LocB.AATags);
if (AA->alias(LocAS, LocBS) == NoAlias) if (AA->isNoAlias(LocAS, LocBS))
return NoAlias; return AliasResult::NoAlias;
// Check the underlying objects are the same // Check the underlying objects are the same
const Value *AObj = getUnderlyingObject(LocA.Ptr); const Value *AObj = getUnderlyingObject(LocA.Ptr);
@ -666,16 +666,16 @@ static AliasResult underlyingObjectsAlias(AAResults *AA,
// If the underlying objects are the same, they must alias // If the underlying objects are the same, they must alias
if (AObj == BObj) if (AObj == BObj)
return MustAlias; return AliasResult::MustAlias;
// We may have hit the recursion limit for underlying objects, or have // We may have hit the recursion limit for underlying objects, or have
// underlying objects where we don't know they will alias. // underlying objects where we don't know they will alias.
if (!isIdentifiedObject(AObj) || !isIdentifiedObject(BObj)) if (!isIdentifiedObject(AObj) || !isIdentifiedObject(BObj))
return MayAlias; return AliasResult::MayAlias;
// Otherwise we know the objects are different and both identified objects so // Otherwise we know the objects are different and both identified objects so
// must not alias. // must not alias.
return NoAlias; return AliasResult::NoAlias;
} }
@ -3501,16 +3501,16 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
switch (underlyingObjectsAlias(AA, F->getParent()->getDataLayout(), switch (underlyingObjectsAlias(AA, F->getParent()->getDataLayout(),
MemoryLocation::get(Dst), MemoryLocation::get(Dst),
MemoryLocation::get(Src))) { MemoryLocation::get(Src))) {
case MayAlias: case AliasResult::MayAlias:
case PartialAlias: case AliasResult::PartialAlias:
// cannot analyse objects if we don't understand their aliasing. // cannot analyse objects if we don't understand their aliasing.
LLVM_DEBUG(dbgs() << "can't analyze may or partial alias\n"); LLVM_DEBUG(dbgs() << "can't analyze may or partial alias\n");
return std::make_unique<Dependence>(Src, Dst); return std::make_unique<Dependence>(Src, Dst);
case NoAlias: case AliasResult::NoAlias:
// If the objects noalias, they are distinct, accesses are independent. // If the objects noalias, they are distinct, accesses are independent.
LLVM_DEBUG(dbgs() << "no alias\n"); LLVM_DEBUG(dbgs() << "no alias\n");
return nullptr; return nullptr;
case MustAlias: case AliasResult::MustAlias:
break; // The underlying objects alias; test accesses for dependence. break; // The underlying objects alias; test accesses for dependence.
} }
@ -3914,9 +3914,9 @@ const SCEV *DependenceInfo::getSplitIteration(const Dependence &Dep,
assert(isLoadOrStore(Dst)); assert(isLoadOrStore(Dst));
Value *SrcPtr = getLoadStorePointerOperand(Src); Value *SrcPtr = getLoadStorePointerOperand(Src);
Value *DstPtr = getLoadStorePointerOperand(Dst); Value *DstPtr = getLoadStorePointerOperand(Dst);
assert(underlyingObjectsAlias(AA, F->getParent()->getDataLayout(), assert(underlyingObjectsAlias(
MemoryLocation::get(Dst), AA, F->getParent()->getDataLayout(), MemoryLocation::get(Dst),
MemoryLocation::get(Src)) == MustAlias); MemoryLocation::get(Src)) == AliasResult::MustAlias);
// establish loop nesting levels // establish loop nesting levels
establishNestingLevels(Src, Dst); establishNestingLevels(Src, Dst);

View File

@ -847,14 +847,14 @@ AliasResult GlobalsAAResult::alias(const MemoryLocation &LocA,
// If the two pointers are derived from two different non-addr-taken // If the two pointers are derived from two different non-addr-taken
// globals we know these can't alias. // globals we know these can't alias.
if (GV1 && GV2 && GV1 != GV2) if (GV1 && GV2 && GV1 != GV2)
return NoAlias; return AliasResult::NoAlias;
// If one is and the other isn't, it isn't strictly safe but we can fake // If one is and the other isn't, it isn't strictly safe but we can fake
// this result if necessary for performance. This does not appear to be // this result if necessary for performance. This does not appear to be
// a common problem in practice. // a common problem in practice.
if (EnableUnsafeGlobalsModRefAliasResults) if (EnableUnsafeGlobalsModRefAliasResults)
if ((GV1 || GV2) && GV1 != GV2) if ((GV1 || GV2) && GV1 != GV2)
return NoAlias; return AliasResult::NoAlias;
// Check for a special case where a non-escaping global can be used to // Check for a special case where a non-escaping global can be used to
// conclude no-alias. // conclude no-alias.
@ -862,7 +862,7 @@ AliasResult GlobalsAAResult::alias(const MemoryLocation &LocA,
const GlobalValue *GV = GV1 ? GV1 : GV2; const GlobalValue *GV = GV1 ? GV1 : GV2;
const Value *UV = GV1 ? UV2 : UV1; const Value *UV = GV1 ? UV2 : UV1;
if (isNonEscapingGlobalNoAlias(GV, UV)) if (isNonEscapingGlobalNoAlias(GV, UV))
return NoAlias; return AliasResult::NoAlias;
} }
// Otherwise if they are both derived from the same addr-taken global, we // Otherwise if they are both derived from the same addr-taken global, we
@ -893,14 +893,14 @@ AliasResult GlobalsAAResult::alias(const MemoryLocation &LocA,
// use this to disambiguate the pointers. If the pointers are based on // use this to disambiguate the pointers. If the pointers are based on
// different indirect globals they cannot alias. // different indirect globals they cannot alias.
if (GV1 && GV2 && GV1 != GV2) if (GV1 && GV2 && GV1 != GV2)
return NoAlias; return AliasResult::NoAlias;
// If one is based on an indirect global and the other isn't, it isn't // If one is based on an indirect global and the other isn't, it isn't
// strictly safe but we can fake this result if necessary for performance. // strictly safe but we can fake this result if necessary for performance.
// This does not appear to be a common problem in practice. // This does not appear to be a common problem in practice.
if (EnableUnsafeGlobalsModRefAliasResults) if (EnableUnsafeGlobalsModRefAliasResults)
if ((GV1 || GV2) && GV1 != GV2) if ((GV1 || GV2) && GV1 != GV2)
return NoAlias; return AliasResult::NoAlias;
return AAResultBase::alias(LocA, LocB, AAQI); return AAResultBase::alias(LocA, LocB, AAQI);
} }
@ -925,7 +925,7 @@ ModRefInfo GlobalsAAResult::getModRefInfoForArgument(const CallBase *Call,
!all_of(Objects, [&](const Value *V) { !all_of(Objects, [&](const Value *V) {
return this->alias(MemoryLocation::getBeforeOrAfter(V), return this->alias(MemoryLocation::getBeforeOrAfter(V),
MemoryLocation::getBeforeOrAfter(GV), MemoryLocation::getBeforeOrAfter(GV),
AAQI) == NoAlias; AAQI) == AliasResult::NoAlias;
})) }))
return ConservativeResult; return ConservativeResult;

View File

@ -242,7 +242,8 @@ void Lint::visitCallBase(CallBase &I) {
continue; continue;
if (AI != BI && (*BI)->getType()->isPointerTy()) { if (AI != BI && (*BI)->getType()->isPointerTy()) {
AliasResult Result = AA->alias(*AI, *BI); AliasResult Result = AA->alias(*AI, *BI);
Assert(Result != MustAlias && Result != PartialAlias, Assert(Result != AliasResult::MustAlias &&
Result != AliasResult::PartialAlias,
"Unusual: noalias argument aliases another argument", &I); "Unusual: noalias argument aliases another argument", &I);
} }
} }
@ -302,7 +303,7 @@ void Lint::visitCallBase(CallBase &I) {
if (Len->getValue().isIntN(32)) if (Len->getValue().isIntN(32))
Size = LocationSize::precise(Len->getValue().getZExtValue()); Size = LocationSize::precise(Len->getValue().getZExtValue());
Assert(AA->alias(MCI->getSource(), Size, MCI->getDest(), Size) != Assert(AA->alias(MCI->getSource(), Size, MCI->getDest(), Size) !=
MustAlias, AliasResult::MustAlias,
"Undefined behavior: memcpy source and destination overlap", &I); "Undefined behavior: memcpy source and destination overlap", &I);
break; break;
} }
@ -318,7 +319,8 @@ void Lint::visitCallBase(CallBase &I) {
// isn't expressive enough for what we really want to do. Known partial // isn't expressive enough for what we really want to do. Known partial
// overlap is not distinguished from the case where nothing is known. // overlap is not distinguished from the case where nothing is known.
const LocationSize LS = LocationSize::precise(Size); const LocationSize LS = LocationSize::precise(Size);
Assert(AA->alias(MCII->getSource(), LS, MCII->getDest(), LS) != MustAlias, Assert(AA->alias(MCII->getSource(), LS, MCII->getDest(), LS) !=
AliasResult::MustAlias,
"Undefined behavior: memcpy source and destination overlap", &I); "Undefined behavior: memcpy source and destination overlap", &I);
break; break;
} }

View File

@ -457,9 +457,9 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom(
MemoryLocation Loc; MemoryLocation Loc;
/*ModRefInfo MR =*/ GetLocation(II, Loc, TLI); /*ModRefInfo MR =*/ GetLocation(II, Loc, TLI);
AliasResult R = BatchAA.alias(Loc, MemLoc); AliasResult R = BatchAA.alias(Loc, MemLoc);
if (R == NoAlias) if (R == AliasResult::NoAlias)
continue; continue;
if (R == MustAlias) if (R == AliasResult::MustAlias)
return MemDepResult::getDef(II); return MemDepResult::getDef(II);
if (ID == Intrinsic::masked_load) if (ID == Intrinsic::masked_load)
continue; continue;
@ -505,11 +505,11 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom(
AliasResult R = BatchAA.alias(LoadLoc, MemLoc); AliasResult R = BatchAA.alias(LoadLoc, MemLoc);
if (isLoad) { if (isLoad) {
if (R == NoAlias) if (R == AliasResult::NoAlias)
continue; continue;
// Must aliased loads are defs of each other. // Must aliased loads are defs of each other.
if (R == MustAlias) if (R == AliasResult::MustAlias)
return MemDepResult::getDef(Inst); return MemDepResult::getDef(Inst);
#if 0 // FIXME: Temporarily disabled. GVN is cleverly rewriting loads #if 0 // FIXME: Temporarily disabled. GVN is cleverly rewriting loads
@ -519,7 +519,7 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom(
// If we have a partial alias, then return this as a clobber for the // If we have a partial alias, then return this as a clobber for the
// client to handle. // client to handle.
if (R == PartialAlias) if (R == AliasResult::PartialAlias)
return MemDepResult::getClobber(Inst); return MemDepResult::getClobber(Inst);
#endif #endif
@ -529,7 +529,7 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom(
} }
// Stores don't depend on other no-aliased accesses. // Stores don't depend on other no-aliased accesses.
if (R == NoAlias) if (R == AliasResult::NoAlias)
continue; continue;
// Stores don't alias loads from read-only memory. // Stores don't alias loads from read-only memory.
@ -575,9 +575,9 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom(
// If we found a pointer, check if it could be the same as our pointer. // If we found a pointer, check if it could be the same as our pointer.
AliasResult R = BatchAA.alias(StoreLoc, MemLoc); AliasResult R = BatchAA.alias(StoreLoc, MemLoc);
if (R == NoAlias) if (R == AliasResult::NoAlias)
continue; continue;
if (R == MustAlias) if (R == AliasResult::MustAlias)
return MemDepResult::getDef(Inst); return MemDepResult::getDef(Inst);
if (isInvariantLoad) if (isInvariantLoad)
continue; continue;

View File

@ -286,7 +286,7 @@ instructionClobbersQuery(const MemoryDef *MD, const MemoryLocation &UseLoc,
case Intrinsic::invariant_end: case Intrinsic::invariant_end:
case Intrinsic::assume: case Intrinsic::assume:
case Intrinsic::experimental_noalias_scope_decl: case Intrinsic::experimental_noalias_scope_decl:
return {false, NoAlias}; return {false, AliasResult::NoAlias};
case Intrinsic::dbg_addr: case Intrinsic::dbg_addr:
case Intrinsic::dbg_declare: case Intrinsic::dbg_declare:
case Intrinsic::dbg_label: case Intrinsic::dbg_label:
@ -299,16 +299,16 @@ instructionClobbersQuery(const MemoryDef *MD, const MemoryLocation &UseLoc,
if (auto *CB = dyn_cast_or_null<CallBase>(UseInst)) { if (auto *CB = dyn_cast_or_null<CallBase>(UseInst)) {
ModRefInfo I = AA.getModRefInfo(DefInst, CB); ModRefInfo I = AA.getModRefInfo(DefInst, CB);
AR = isMustSet(I) ? MustAlias : MayAlias; AR = isMustSet(I) ? AliasResult::MustAlias : AliasResult::MayAlias;
return {isModOrRefSet(I), AR}; return {isModOrRefSet(I), AR};
} }
if (auto *DefLoad = dyn_cast<LoadInst>(DefInst)) if (auto *DefLoad = dyn_cast<LoadInst>(DefInst))
if (auto *UseLoad = dyn_cast_or_null<LoadInst>(UseInst)) if (auto *UseLoad = dyn_cast_or_null<LoadInst>(UseInst))
return {!areLoadsReorderable(UseLoad, DefLoad), MayAlias}; return {!areLoadsReorderable(UseLoad, DefLoad), AliasResult::MayAlias};
ModRefInfo I = AA.getModRefInfo(DefInst, UseLoc); ModRefInfo I = AA.getModRefInfo(DefInst, UseLoc);
AR = isMustSet(I) ? MustAlias : MayAlias; AR = isMustSet(I) ? AliasResult::MustAlias : AliasResult::MayAlias;
return {isModSet(I), AR}; return {isModSet(I), AR};
} }
@ -344,7 +344,7 @@ struct UpwardsMemoryQuery {
const Instruction *Inst = nullptr; const Instruction *Inst = nullptr;
// The MemoryAccess we actually got called with, used to test local domination // The MemoryAccess we actually got called with, used to test local domination
const MemoryAccess *OriginalAccess = nullptr; const MemoryAccess *OriginalAccess = nullptr;
Optional<AliasResult> AR = MayAlias; Optional<AliasResult> AR = AliasResult::MayAlias;
bool SkipSelfAccess = false; bool SkipSelfAccess = false;
UpwardsMemoryQuery() = default; UpwardsMemoryQuery() = default;
@ -570,14 +570,14 @@ template <class AliasAnalysisType> class ClobberWalker {
for (MemoryAccess *Current : def_chain(Desc.Last)) { for (MemoryAccess *Current : def_chain(Desc.Last)) {
Desc.Last = Current; Desc.Last = Current;
if (Current == StopAt || Current == SkipStopAt) if (Current == StopAt || Current == SkipStopAt)
return {Current, false, MayAlias}; return {Current, false, AliasResult::MayAlias};
if (auto *MD = dyn_cast<MemoryDef>(Current)) { if (auto *MD = dyn_cast<MemoryDef>(Current)) {
if (MSSA.isLiveOnEntryDef(MD)) if (MSSA.isLiveOnEntryDef(MD))
return {MD, true, MustAlias}; return {MD, true, AliasResult::MustAlias};
if (!--*UpwardWalkLimit) if (!--*UpwardWalkLimit)
return {Current, true, MayAlias}; return {Current, true, AliasResult::MayAlias};
ClobberAlias CA = ClobberAlias CA =
instructionClobbersQuery(MD, Desc.Loc, Query->Inst, AA); instructionClobbersQuery(MD, Desc.Loc, Query->Inst, AA);
@ -591,7 +591,7 @@ template <class AliasAnalysisType> class ClobberWalker {
assert(isa<MemoryPhi>(Desc.Last) && assert(isa<MemoryPhi>(Desc.Last) &&
"Ended at a non-clobber that's not a phi?"); "Ended at a non-clobber that's not a phi?");
return {Desc.Last, false, MayAlias}; return {Desc.Last, false, AliasResult::MayAlias};
} }
void addSearches(MemoryPhi *Phi, SmallVectorImpl<ListIndex> &PausedSearches, void addSearches(MemoryPhi *Phi, SmallVectorImpl<ListIndex> &PausedSearches,
@ -1409,7 +1409,7 @@ void MemorySSA::OptimizeUses::optimizeUsesInBlock(
if (!LocInfo.LastKillValid) { if (!LocInfo.LastKillValid) {
LocInfo.LastKill = VersionStack.size() - 1; LocInfo.LastKill = VersionStack.size() - 1;
LocInfo.LastKillValid = true; LocInfo.LastKillValid = true;
LocInfo.AR = MayAlias; LocInfo.AR = AliasResult::MayAlias;
} }
// At this point, we should have corrected last kill and LowerBound to be // At this point, we should have corrected last kill and LowerBound to be
@ -2490,8 +2490,8 @@ MemorySSA::ClobberWalkerBase<AliasAnalysisType>::getClobberingMemoryAccessBase(
StartingAccess->setOptimized(OptimizedAccess); StartingAccess->setOptimized(OptimizedAccess);
if (MSSA->isLiveOnEntryDef(OptimizedAccess)) if (MSSA->isLiveOnEntryDef(OptimizedAccess))
StartingAccess->setOptimizedAccessType(None); StartingAccess->setOptimizedAccessType(None);
else if (Q.AR == MustAlias) else if (Q.AR == AliasResult::MustAlias)
StartingAccess->setOptimizedAccessType(MustAlias); StartingAccess->setOptimizedAccessType(AliasResult::MustAlias);
} else } else
OptimizedAccess = StartingAccess->getOptimized(); OptimizedAccess = StartingAccess->getOptimized();

View File

@ -49,7 +49,7 @@ AliasResult ObjCARCAAResult::alias(const MemoryLocation &LocA,
AliasResult Result = AliasResult Result =
AAResultBase::alias(MemoryLocation(SA, LocA.Size, LocA.AATags), AAResultBase::alias(MemoryLocation(SA, LocA.Size, LocA.AATags),
MemoryLocation(SB, LocB.Size, LocB.AATags), AAQI); MemoryLocation(SB, LocB.Size, LocB.AATags), AAQI);
if (Result != MayAlias) if (Result != AliasResult::MayAlias)
return Result; return Result;
// If that failed, climb to the underlying object, including climbing through // If that failed, climb to the underlying object, including climbing through
@ -61,13 +61,13 @@ AliasResult ObjCARCAAResult::alias(const MemoryLocation &LocA,
MemoryLocation::getBeforeOrAfter(UB), AAQI); MemoryLocation::getBeforeOrAfter(UB), AAQI);
// We can't use MustAlias or PartialAlias results here because // We can't use MustAlias or PartialAlias results here because
// GetUnderlyingObjCPtr may return an offsetted pointer value. // GetUnderlyingObjCPtr may return an offsetted pointer value.
if (Result == NoAlias) if (Result == AliasResult::NoAlias)
return NoAlias; return AliasResult::NoAlias;
} }
// If that failed, fail. We don't need to chain here, since that's covered // If that failed, fail. We don't need to chain here, since that's covered
// by the earlier precise query. // by the earlier precise query.
return MayAlias; return AliasResult::MayAlias;
} }
bool ObjCARCAAResult::pointsToConstantMemory(const MemoryLocation &Loc, bool ObjCARCAAResult::pointsToConstantMemory(const MemoryLocation &Loc,

View File

@ -28,7 +28,7 @@ AliasResult SCEVAAResult::alias(const MemoryLocation &LocA,
// pointer values are. This allows the code below to ignore this special // pointer values are. This allows the code below to ignore this special
// case. // case.
if (LocA.Size.isZero() || LocB.Size.isZero()) if (LocA.Size.isZero() || LocB.Size.isZero())
return NoAlias; return AliasResult::NoAlias;
// This is SCEVAAResult. Get the SCEVs! // This is SCEVAAResult. Get the SCEVs!
const SCEV *AS = SE.getSCEV(const_cast<Value *>(LocA.Ptr)); const SCEV *AS = SE.getSCEV(const_cast<Value *>(LocA.Ptr));
@ -36,7 +36,7 @@ AliasResult SCEVAAResult::alias(const MemoryLocation &LocA,
// If they evaluate to the same expression, it's a MustAlias. // If they evaluate to the same expression, it's a MustAlias.
if (AS == BS) if (AS == BS)
return MustAlias; return AliasResult::MustAlias;
// If something is known about the difference between the two addresses, // If something is known about the difference between the two addresses,
// see if it's enough to prove a NoAlias. // see if it's enough to prove a NoAlias.
@ -58,7 +58,7 @@ AliasResult SCEVAAResult::alias(const MemoryLocation &LocA,
// are non-zero, which is special-cased above. // are non-zero, which is special-cased above.
if (ASizeInt.ule(SE.getUnsignedRange(BA).getUnsignedMin()) && if (ASizeInt.ule(SE.getUnsignedRange(BA).getUnsignedMin()) &&
(-BSizeInt).uge(SE.getUnsignedRange(BA).getUnsignedMax())) (-BSizeInt).uge(SE.getUnsignedRange(BA).getUnsignedMax()))
return NoAlias; return AliasResult::NoAlias;
// Folding the subtraction while preserving range information can be tricky // Folding the subtraction while preserving range information can be tricky
// (because of INT_MIN, etc.); if the prior test failed, swap AS and BS // (because of INT_MIN, etc.); if the prior test failed, swap AS and BS
@ -72,7 +72,7 @@ AliasResult SCEVAAResult::alias(const MemoryLocation &LocA,
// are non-zero, which is special-cased above. // are non-zero, which is special-cased above.
if (BSizeInt.ule(SE.getUnsignedRange(AB).getUnsignedMin()) && if (BSizeInt.ule(SE.getUnsignedRange(AB).getUnsignedMin()) &&
(-ASizeInt).uge(SE.getUnsignedRange(AB).getUnsignedMax())) (-ASizeInt).uge(SE.getUnsignedRange(AB).getUnsignedMax()))
return NoAlias; return AliasResult::NoAlias;
} }
// If ScalarEvolution can find an underlying object, form a new query. // If ScalarEvolution can find an underlying object, form a new query.
@ -89,8 +89,8 @@ AliasResult SCEVAAResult::alias(const MemoryLocation &LocA,
BO ? LocationSize::beforeOrAfterPointer() BO ? LocationSize::beforeOrAfterPointer()
: LocB.Size, : LocB.Size,
BO ? AAMDNodes() : LocB.AATags), BO ? AAMDNodes() : LocB.AATags),
AAQI) == NoAlias) AAQI) == AliasResult::NoAlias)
return NoAlias; return AliasResult::NoAlias;
// Forward the query to the next analysis. // Forward the query to the next analysis.
return AAResultBase::alias(LocA, LocB, AAQI); return AAResultBase::alias(LocA, LocB, AAQI);

View File

@ -64,10 +64,10 @@ AliasResult ScopedNoAliasAAResult::alias(const MemoryLocation &LocA,
const MDNode *ANoAlias = LocA.AATags.NoAlias, *BNoAlias = LocB.AATags.NoAlias; const MDNode *ANoAlias = LocA.AATags.NoAlias, *BNoAlias = LocB.AATags.NoAlias;
if (!mayAliasInScopes(AScopes, BNoAlias)) if (!mayAliasInScopes(AScopes, BNoAlias))
return NoAlias; return AliasResult::NoAlias;
if (!mayAliasInScopes(BScopes, ANoAlias)) if (!mayAliasInScopes(BScopes, ANoAlias))
return NoAlias; return AliasResult::NoAlias;
// If they may alias, chain to the next AliasAnalysis. // If they may alias, chain to the next AliasAnalysis.
return AAResultBase::alias(LocA, LocB, AAQI); return AAResultBase::alias(LocA, LocB, AAQI);

View File

@ -379,7 +379,7 @@ AliasResult TypeBasedAAResult::alias(const MemoryLocation &LocA,
return AAResultBase::alias(LocA, LocB, AAQI); return AAResultBase::alias(LocA, LocB, AAQI);
// Otherwise return a definitive result. // Otherwise return a definitive result.
return NoAlias; return AliasResult::NoAlias;
} }
bool TypeBasedAAResult::pointsToConstantMemory(const MemoryLocation &Loc, bool TypeBasedAAResult::pointsToConstantMemory(const MemoryLocation &Loc,

View File

@ -295,7 +295,7 @@ bool VLIWPacketizerList::alias(const MachineMemOperand &Op1,
MemoryLocation(Op2.getValue(), Overlapb, MemoryLocation(Op2.getValue(), Overlapb,
UseTBAA ? Op2.getAAInfo() : AAMDNodes())); UseTBAA ? Op2.getAAInfo() : AAMDNodes()));
return AAResult != NoAlias; return AAResult != AliasResult::NoAlias;
} }
bool VLIWPacketizerList::alias(const MachineInstr &MI1, bool VLIWPacketizerList::alias(const MachineInstr &MI1,

View File

@ -353,10 +353,9 @@ ImplicitNullChecks::areMemoryOpsAliased(const MachineInstr &MI,
return AR_MayAlias; return AR_MayAlias;
continue; continue;
} }
llvm::AliasResult AAResult = AA->alias( if (!AA->isNoAlias(
MemoryLocation::getAfter(MMO1->getValue(), MMO1->getAAInfo()), MemoryLocation::getAfter(MMO1->getValue(), MMO1->getAAInfo()),
MemoryLocation::getAfter(MMO2->getValue(), MMO2->getAAInfo())); MemoryLocation::getAfter(MMO2->getValue(), MMO2->getAAInfo())))
if (AAResult != NoAlias)
return AR_MayAlias; return AR_MayAlias;
} }
} }

View File

@ -1319,12 +1319,10 @@ static bool MemOperandsHaveAlias(const MachineFrameInfo &MFI, AAResults *AA,
int64_t OverlapB = int64_t OverlapB =
KnownWidthB ? WidthB + OffsetB - MinOffset : MemoryLocation::UnknownSize; KnownWidthB ? WidthB + OffsetB - MinOffset : MemoryLocation::UnknownSize;
AliasResult AAResult = AA->alias( return !AA->isNoAlias(
MemoryLocation(ValA, OverlapA, UseTBAA ? MMOa->getAAInfo() : AAMDNodes()), MemoryLocation(ValA, OverlapA, UseTBAA ? MMOa->getAAInfo() : AAMDNodes()),
MemoryLocation(ValB, OverlapB, MemoryLocation(ValB, OverlapB,
UseTBAA ? MMOb->getAAInfo() : AAMDNodes())); UseTBAA ? MMOb->getAAInfo() : AAMDNodes()));
return (AAResult != NoAlias);
} }
bool MachineInstr::mayAlias(AAResults *AA, const MachineInstr &Other, bool MachineInstr::mayAlias(AAResults *AA, const MachineInstr &Other,

View File

@ -813,11 +813,10 @@ void SwingSchedulerDAG::addLoopCarriedDependences(AliasAnalysis *AA) {
SU.addPred(Dep); SU.addPred(Dep);
continue; continue;
} }
AliasResult AAResult = AA->alias( if (!AA->isNoAlias(
MemoryLocation::getAfter(MMO1->getValue(), MMO1->getAAInfo()), MemoryLocation::getAfter(MMO1->getValue(), MMO1->getAAInfo()),
MemoryLocation::getAfter(MMO2->getValue(), MMO2->getAAInfo())); MemoryLocation::getAfter(MMO2->getValue(),
MMO2->getAAInfo()))) {
if (AAResult != NoAlias) {
SDep Dep(Load, SDep::Barrier); SDep Dep(Load, SDep::Barrier);
Dep.setLatency(1); Dep.setLatency(1);
SU.addPred(Dep); SU.addPred(Dep);

View File

@ -22796,12 +22796,11 @@ bool DAGCombiner::isAlias(SDNode *Op0, SDNode *Op1) const {
int64_t MinOffset = std::min(SrcValOffset0, SrcValOffset1); int64_t MinOffset = std::min(SrcValOffset0, SrcValOffset1);
int64_t Overlap0 = *Size0 + SrcValOffset0 - MinOffset; int64_t Overlap0 = *Size0 + SrcValOffset0 - MinOffset;
int64_t Overlap1 = *Size1 + SrcValOffset1 - MinOffset; int64_t Overlap1 = *Size1 + SrcValOffset1 - MinOffset;
AliasResult AAResult = AA->alias( if (AA->isNoAlias(
MemoryLocation(MUC0.MMO->getValue(), Overlap0, MemoryLocation(MUC0.MMO->getValue(), Overlap0,
UseTBAA ? MUC0.MMO->getAAInfo() : AAMDNodes()), UseTBAA ? MUC0.MMO->getAAInfo() : AAMDNodes()),
MemoryLocation(MUC1.MMO->getValue(), Overlap1, MemoryLocation(MUC1.MMO->getValue(), Overlap1,
UseTBAA ? MUC1.MMO->getAAInfo() : AAMDNodes())); UseTBAA ? MUC1.MMO->getAAInfo() : AAMDNodes())))
if (AAResult == NoAlias)
return false; return false;
} }

View File

@ -41,24 +41,28 @@ void AMDGPUAAWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll(); AU.setPreservesAll();
} }
// These arrays are indexed by address space value enum elements 0 ... to 7
static const AliasResult ASAliasRules[8][8] = {
/* Flat Global Region Group Constant Private Constant 32-bit Buffer Fat Ptr */
/* Flat */ {MayAlias, MayAlias, NoAlias, MayAlias, MayAlias, MayAlias, MayAlias, MayAlias},
/* Global */ {MayAlias, MayAlias, NoAlias , NoAlias , MayAlias, NoAlias , MayAlias, MayAlias},
/* Region */ {NoAlias, NoAlias , MayAlias, NoAlias , NoAlias, NoAlias , NoAlias, NoAlias},
/* Group */ {MayAlias, NoAlias , NoAlias , MayAlias, NoAlias , NoAlias , NoAlias , NoAlias},
/* Constant */ {MayAlias, MayAlias, NoAlias, NoAlias , NoAlias , NoAlias , MayAlias, MayAlias},
/* Private */ {MayAlias, NoAlias , NoAlias , NoAlias , NoAlias , MayAlias, NoAlias , NoAlias},
/* Constant 32-bit */ {MayAlias, MayAlias, NoAlias, NoAlias , MayAlias, NoAlias , NoAlias , MayAlias},
/* Buffer Fat Ptr */ {MayAlias, MayAlias, NoAlias , NoAlias , MayAlias, NoAlias , MayAlias, MayAlias}
};
static AliasResult getAliasResult(unsigned AS1, unsigned AS2) { static AliasResult getAliasResult(unsigned AS1, unsigned AS2) {
static_assert(AMDGPUAS::MAX_AMDGPU_ADDRESS <= 7, "Addr space out of range"); static_assert(AMDGPUAS::MAX_AMDGPU_ADDRESS <= 7, "Addr space out of range");
if (AS1 > AMDGPUAS::MAX_AMDGPU_ADDRESS || AS2 > AMDGPUAS::MAX_AMDGPU_ADDRESS) if (AS1 > AMDGPUAS::MAX_AMDGPU_ADDRESS || AS2 > AMDGPUAS::MAX_AMDGPU_ADDRESS)
return MayAlias; return AliasResult::MayAlias;
#define ASMay AliasResult::MayAlias
#define ASNo AliasResult::NoAlias
// This array is indexed by address space value enum elements 0 ... to 7
static const AliasResult ASAliasRules[8][8] = {
/* Flat Global Region Group Constant Private Const32 Buf Fat Ptr */
/* Flat */ {ASMay, ASMay, ASNo, ASMay, ASMay, ASMay, ASMay, ASMay},
/* Global */ {ASMay, ASMay, ASNo, ASNo, ASMay, ASNo, ASMay, ASMay},
/* Region */ {ASNo, ASNo, ASMay, ASNo, ASNo, ASNo, ASNo, ASNo},
/* Group */ {ASMay, ASNo, ASNo, ASMay, ASNo, ASNo, ASNo, ASNo},
/* Constant */ {ASMay, ASMay, ASNo, ASNo, ASNo, ASNo, ASMay, ASMay},
/* Private */ {ASMay, ASNo, ASNo, ASNo, ASNo, ASMay, ASNo, ASNo},
/* Constant 32-bit */ {ASMay, ASMay, ASNo, ASNo, ASMay, ASNo, ASNo, ASMay},
/* Buffer Fat Ptr */ {ASMay, ASMay, ASNo, ASNo, ASMay, ASNo, ASMay, ASMay}
};
#undef ASMay
#undef ASNo
return ASAliasRules[AS1][AS2]; return ASAliasRules[AS1][AS2];
} }
@ -70,7 +74,7 @@ AliasResult AMDGPUAAResult::alias(const MemoryLocation &LocA,
unsigned asB = LocB.Ptr->getType()->getPointerAddressSpace(); unsigned asB = LocB.Ptr->getType()->getPointerAddressSpace();
AliasResult Result = getAliasResult(asA, asB); AliasResult Result = getAliasResult(asA, asB);
if (Result == NoAlias) if (Result == AliasResult::NoAlias)
return Result; return Result;
// In general, FLAT (generic) pointers could be aliased to LOCAL or PRIVATE // In general, FLAT (generic) pointers could be aliased to LOCAL or PRIVATE
@ -94,14 +98,14 @@ AliasResult AMDGPUAAResult::alias(const MemoryLocation &LocA,
// prepared on the host side, where only GLOBAL or CONSTANT variables are // prepared on the host side, where only GLOBAL or CONSTANT variables are
// visible. Note that this even holds for regular functions. // visible. Note that this even holds for regular functions.
if (LI->getPointerAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS) if (LI->getPointerAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS)
return NoAlias; return AliasResult::NoAlias;
} else if (const Argument *Arg = dyn_cast<Argument>(ObjA)) { } else if (const Argument *Arg = dyn_cast<Argument>(ObjA)) {
const Function *F = Arg->getParent(); const Function *F = Arg->getParent();
switch (F->getCallingConv()) { switch (F->getCallingConv()) {
case CallingConv::AMDGPU_KERNEL: case CallingConv::AMDGPU_KERNEL:
// In the kernel function, kernel arguments won't alias to (local) // In the kernel function, kernel arguments won't alias to (local)
// variables in shared or private address space. // variables in shared or private address space.
return NoAlias; return AliasResult::NoAlias;
default: default:
// TODO: In the regular function, if that local variable in the // TODO: In the regular function, if that local variable in the
// location B is not captured, that argument pointer won't alias to it // location B is not captured, that argument pointer won't alias to it

View File

@ -180,7 +180,7 @@ bool HexagonStoreWidening::instrAliased(InstrGroup &Stores,
return true; return true;
MemoryLocation SL(SMO.getValue(), SMO.getSize(), SMO.getAAInfo()); MemoryLocation SL(SMO.getValue(), SMO.getSize(), SMO.getAAInfo());
if (AA->alias(L, SL)) if (!AA->isNoAlias(L, SL))
return true; return true;
} }

View File

@ -1432,8 +1432,8 @@ bool SystemZDAGToDAGISel::canUseBlockOperation(StoreSDNode *Store,
if (V1 == V2 && End1 == End2) if (V1 == V2 && End1 == End2)
return false; return false;
return !AA->alias(MemoryLocation(V1, End1, Load->getAAInfo()), return AA->isNoAlias(MemoryLocation(V1, End1, Load->getAAInfo()),
MemoryLocation(V2, End2, Store->getAAInfo())); MemoryLocation(V2, End2, Store->getAAInfo()));
} }
bool SystemZDAGToDAGISel::storeLoadCanUseMVC(SDNode *N) const { bool SystemZDAGToDAGISel::storeLoadCanUseMVC(SDNode *N) const {

View File

@ -529,10 +529,9 @@ bool X86AvoidSFBPass::alias(const MachineMemOperand &Op1,
int64_t Overlapa = Op1.getSize() + Op1.getOffset() - MinOffset; int64_t Overlapa = Op1.getSize() + Op1.getOffset() - MinOffset;
int64_t Overlapb = Op2.getSize() + Op2.getOffset() - MinOffset; int64_t Overlapb = Op2.getSize() + Op2.getOffset() - MinOffset;
AliasResult AAResult = return !AA->isNoAlias(
AA->alias(MemoryLocation(Op1.getValue(), Overlapa, Op1.getAAInfo()), MemoryLocation(Op1.getValue(), Overlapa, Op1.getAAInfo()),
MemoryLocation(Op2.getValue(), Overlapb, Op2.getAAInfo())); MemoryLocation(Op2.getValue(), Overlapb, Op2.getAAInfo()));
return AAResult != NoAlias;
} }
void X86AvoidSFBPass::findPotentiallylBlockedCopies(MachineFunction &MF) { void X86AvoidSFBPass::findPotentiallylBlockedCopies(MachineFunction &MF) {

View File

@ -71,7 +71,7 @@ static void replaceWithConstant(Constant *Value,
// See if any operand of the call instruction references the coroutine frame. // See if any operand of the call instruction references the coroutine frame.
static bool operandReferences(CallInst *CI, AllocaInst *Frame, AAResults &AA) { static bool operandReferences(CallInst *CI, AllocaInst *Frame, AAResults &AA) {
for (Value *Op : CI->operand_values()) for (Value *Op : CI->operand_values())
if (AA.alias(Op, Frame) != NoAlias) if (!AA.isNoAlias(Op, Frame))
return true; return true;
return false; return false;
} }

View File

@ -2101,7 +2101,7 @@ void ObjCARCOpt::OptimizeWeakCalls(Function &F) {
Value *Arg = Call->getArgOperand(0); Value *Arg = Call->getArgOperand(0);
Value *EarlierArg = EarlierCall->getArgOperand(0); Value *EarlierArg = EarlierCall->getArgOperand(0);
switch (PA.getAA()->alias(Arg, EarlierArg)) { switch (PA.getAA()->alias(Arg, EarlierArg)) {
case MustAlias: case AliasResult::MustAlias:
Changed = true; Changed = true;
// If the load has a builtin retain, insert a plain retain for it. // If the load has a builtin retain, insert a plain retain for it.
if (Class == ARCInstKind::LoadWeakRetained) { if (Class == ARCInstKind::LoadWeakRetained) {
@ -2113,10 +2113,10 @@ void ObjCARCOpt::OptimizeWeakCalls(Function &F) {
Call->replaceAllUsesWith(EarlierCall); Call->replaceAllUsesWith(EarlierCall);
Call->eraseFromParent(); Call->eraseFromParent();
goto clobbered; goto clobbered;
case MayAlias: case AliasResult::MayAlias:
case PartialAlias: case AliasResult::PartialAlias:
goto clobbered; goto clobbered;
case NoAlias: case AliasResult::NoAlias:
break; break;
} }
break; break;
@ -2130,7 +2130,7 @@ void ObjCARCOpt::OptimizeWeakCalls(Function &F) {
Value *Arg = Call->getArgOperand(0); Value *Arg = Call->getArgOperand(0);
Value *EarlierArg = EarlierCall->getArgOperand(0); Value *EarlierArg = EarlierCall->getArgOperand(0);
switch (PA.getAA()->alias(Arg, EarlierArg)) { switch (PA.getAA()->alias(Arg, EarlierArg)) {
case MustAlias: case AliasResult::MustAlias:
Changed = true; Changed = true;
// If the load has a builtin retain, insert a plain retain for it. // If the load has a builtin retain, insert a plain retain for it.
if (Class == ARCInstKind::LoadWeakRetained) { if (Class == ARCInstKind::LoadWeakRetained) {
@ -2142,10 +2142,10 @@ void ObjCARCOpt::OptimizeWeakCalls(Function &F) {
Call->replaceAllUsesWith(EarlierCall->getArgOperand(1)); Call->replaceAllUsesWith(EarlierCall->getArgOperand(1));
Call->eraseFromParent(); Call->eraseFromParent();
goto clobbered; goto clobbered;
case MayAlias: case AliasResult::MayAlias:
case PartialAlias: case AliasResult::PartialAlias:
goto clobbered; goto clobbered;
case NoAlias: case AliasResult::NoAlias:
break; break;
} }
break; break;

View File

@ -112,12 +112,12 @@ static bool IsStoredObjCPointer(const Value *P) {
bool ProvenanceAnalysis::relatedCheck(const Value *A, const Value *B) { bool ProvenanceAnalysis::relatedCheck(const Value *A, const Value *B) {
// Ask regular AliasAnalysis, for a first approximation. // Ask regular AliasAnalysis, for a first approximation.
switch (AA->alias(A, B)) { switch (AA->alias(A, B)) {
case NoAlias: case AliasResult::NoAlias:
return false; return false;
case MustAlias: case AliasResult::MustAlias:
case PartialAlias: case AliasResult::PartialAlias:
return true; return true;
case MayAlias: case AliasResult::MayAlias:
break; break;
} }

View File

@ -1092,10 +1092,8 @@ public:
MemoryLocation StoreLoc = MemoryLocation::get(Store); MemoryLocation StoreLoc = MemoryLocation::get(Store);
MemoryLocation LoadLoc = MemoryLocation::get(Load); MemoryLocation LoadLoc = MemoryLocation::get(Load);
AliasResult LdAliased = AA->alias(LoadLoc, StoreLoc);
// If we can statically determine noalias we're good. // If we can statically determine noalias we're good.
if (!LdAliased) if (AA->isNoAlias(LoadLoc, StoreLoc))
return Load->getPointerOperand(); return Load->getPointerOperand();
// Create code to check if the memory locations of the Load and Store // Create code to check if the memory locations of the Load and Store

View File

@ -360,7 +360,7 @@ bool FlattenCFGOpt::CompareIfRegionBlock(BasicBlock *Block1, BasicBlock *Block2,
for (BasicBlock::iterator BI(PBI2), BE(PTI2); BI != BE; ++BI) { for (BasicBlock::iterator BI(PBI2), BE(PTI2); BI != BE; ++BI) {
if (BI->mayReadFromMemory() || BI->mayWriteToMemory()) { if (BI->mayReadFromMemory() || BI->mayWriteToMemory()) {
// Check alias with Head2. // Check alias with Head2.
if (!AA || AA->alias(&*iter1, &*BI)) if (!AA || !AA->isNoAlias(&*iter1, &*BI))
return false; return false;
} }
} }

View File

@ -1909,7 +1909,7 @@ private:
bool aliased = true; bool aliased = true;
if (Loc1.Ptr && Loc2.Ptr && isSimple(Inst1) && isSimple(Inst2)) { if (Loc1.Ptr && Loc2.Ptr && isSimple(Inst1) && isSimple(Inst2)) {
// Do the alias check. // Do the alias check.
aliased = AA->alias(Loc1, Loc2); aliased = !AA->isNoAlias(Loc1, Loc2);
} }
// Store the result in the cache. // Store the result in the cache.
result = aliased; result = aliased;

View File

@ -89,7 +89,7 @@ struct TestCustomAAResult : AAResultBase<TestCustomAAResult> {
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
AAQueryInfo &AAQI) { AAQueryInfo &AAQI) {
CB(); CB();
return MayAlias; return AliasResult::MayAlias;
} }
}; };
} }
@ -247,19 +247,19 @@ TEST_F(AliasAnalysisTest, BatchAAPhiCycles) {
MemoryLocation S2Loc(S2, LocationSize::precise(1)); MemoryLocation S2Loc(S2, LocationSize::precise(1));
auto &AA = getAAResults(*F); auto &AA = getAAResults(*F);
EXPECT_EQ(NoAlias, AA.alias(A1Loc, A2Loc)); EXPECT_EQ(AliasResult::NoAlias, AA.alias(A1Loc, A2Loc));
EXPECT_EQ(MayAlias, AA.alias(PhiLoc, A1Loc)); EXPECT_EQ(AliasResult::MayAlias, AA.alias(PhiLoc, A1Loc));
EXPECT_EQ(MayAlias, AA.alias(S1Loc, S2Loc)); EXPECT_EQ(AliasResult::MayAlias, AA.alias(S1Loc, S2Loc));
BatchAAResults BatchAA(AA); BatchAAResults BatchAA(AA);
EXPECT_EQ(NoAlias, BatchAA.alias(A1Loc, A2Loc)); EXPECT_EQ(AliasResult::NoAlias, BatchAA.alias(A1Loc, A2Loc));
EXPECT_EQ(MayAlias, BatchAA.alias(PhiLoc, A1Loc)); EXPECT_EQ(AliasResult::MayAlias, BatchAA.alias(PhiLoc, A1Loc));
EXPECT_EQ(MayAlias, BatchAA.alias(S1Loc, S2Loc)); EXPECT_EQ(AliasResult::MayAlias, BatchAA.alias(S1Loc, S2Loc));
BatchAAResults BatchAA2(AA); BatchAAResults BatchAA2(AA);
EXPECT_EQ(NoAlias, BatchAA2.alias(A1Loc, A2Loc)); EXPECT_EQ(AliasResult::NoAlias, BatchAA2.alias(A1Loc, A2Loc));
EXPECT_EQ(MayAlias, BatchAA2.alias(S1Loc, S2Loc)); EXPECT_EQ(AliasResult::MayAlias, BatchAA2.alias(S1Loc, S2Loc));
EXPECT_EQ(MayAlias, BatchAA2.alias(PhiLoc, A1Loc)); EXPECT_EQ(AliasResult::MayAlias, BatchAA2.alias(PhiLoc, A1Loc));
} }
TEST_F(AliasAnalysisTest, BatchAAPhiAssumption) { TEST_F(AliasAnalysisTest, BatchAAPhiAssumption) {
@ -290,12 +290,12 @@ TEST_F(AliasAnalysisTest, BatchAAPhiAssumption) {
MemoryLocation BNextLoc(BNext, LocationSize::precise(1)); MemoryLocation BNextLoc(BNext, LocationSize::precise(1));
auto &AA = getAAResults(*F); auto &AA = getAAResults(*F);
EXPECT_EQ(MayAlias, AA.alias(ALoc, BLoc)); EXPECT_EQ(AliasResult::MayAlias, AA.alias(ALoc, BLoc));
EXPECT_EQ(MayAlias, AA.alias(ANextLoc, BNextLoc)); EXPECT_EQ(AliasResult::MayAlias, AA.alias(ANextLoc, BNextLoc));
BatchAAResults BatchAA(AA); BatchAAResults BatchAA(AA);
EXPECT_EQ(MayAlias, BatchAA.alias(ALoc, BLoc)); EXPECT_EQ(AliasResult::MayAlias, BatchAA.alias(ALoc, BLoc));
EXPECT_EQ(MayAlias, BatchAA.alias(ANextLoc, BNextLoc)); EXPECT_EQ(AliasResult::MayAlias, BatchAA.alias(ANextLoc, BNextLoc));
} }
// Check that two aliased GEPs with non-constant offsets are correctly // Check that two aliased GEPs with non-constant offsets are correctly
@ -329,7 +329,7 @@ TEST_F(AliasAnalysisTest, PartialAliasOffset) {
auto &AA = getAAResults(*F); auto &AA = getAAResults(*F);
BatchAAResults BatchAA(AA, /*CacheOffsets =*/true); BatchAAResults BatchAA(AA, /*CacheOffsets =*/true);
EXPECT_EQ(PartialAlias, BatchAA.alias(Loc1, Loc2)); EXPECT_EQ(AliasResult::PartialAlias, BatchAA.alias(Loc1, Loc2));
EXPECT_EQ(-4, BatchAA.getClobberOffset(Loc1, Loc2).getValueOr(0)); EXPECT_EQ(-4, BatchAA.getClobberOffset(Loc1, Loc2).getValueOr(0));
EXPECT_EQ(4, BatchAA.getClobberOffset(Loc2, Loc1).getValueOr(0)); EXPECT_EQ(4, BatchAA.getClobberOffset(Loc2, Loc1).getValueOr(0));

View File

@ -1038,7 +1038,7 @@ TEST_F(MemorySSATest, TestLoadMustAlias) {
} }
for (LoadInst *V : {LA3, LA4}) { for (LoadInst *V : {LA3, LA4}) {
MemoryUse *MemUse = dyn_cast_or_null<MemoryUse>(MSSA.getMemoryAccess(V)); MemoryUse *MemUse = dyn_cast_or_null<MemoryUse>(MSSA.getMemoryAccess(V));
EXPECT_EQ(MemUse->getOptimizedAccessType(), MustAlias) EXPECT_EQ(MemUse->getOptimizedAccessType(), AliasResult::MustAlias)
<< "Load " << I << " doesn't have the correct alias information"; << "Load " << I << " doesn't have the correct alias information";
// EXPECT_EQ expands such that if we increment I above, it won't get // EXPECT_EQ expands such that if we increment I above, it won't get
// incremented except when we try to print the error message. // incremented except when we try to print the error message.
@ -1087,7 +1087,7 @@ TEST_F(MemorySSATest, TestStoreMustAlias) {
EXPECT_EQ(MemDef->getOptimizedAccessType(), None) EXPECT_EQ(MemDef->getOptimizedAccessType(), None)
<< "Store " << I << " doesn't have the correct alias information"; << "Store " << I << " doesn't have the correct alias information";
else else
EXPECT_EQ(MemDef->getOptimizedAccessType(), MustAlias) EXPECT_EQ(MemDef->getOptimizedAccessType(), AliasResult::MustAlias)
<< "Store " << I << " doesn't have the correct alias information"; << "Store " << I << " doesn't have the correct alias information";
// EXPECT_EQ expands such that if we increment I above, it won't get // EXPECT_EQ expands such that if we increment I above, it won't get
// incremented except when we try to print the error message. // incremented except when we try to print the error message.
@ -1121,7 +1121,7 @@ TEST_F(MemorySSATest, TestLoadMayAlias) {
unsigned I = 0; unsigned I = 0;
for (LoadInst *V : {LA1, LB1}) { for (LoadInst *V : {LA1, LB1}) {
MemoryUse *MemUse = dyn_cast_or_null<MemoryUse>(MSSA.getMemoryAccess(V)); MemoryUse *MemUse = dyn_cast_or_null<MemoryUse>(MSSA.getMemoryAccess(V));
EXPECT_EQ(MemUse->getOptimizedAccessType(), MayAlias) EXPECT_EQ(MemUse->getOptimizedAccessType(), AliasResult::MayAlias)
<< "Load " << I << " doesn't have the correct alias information"; << "Load " << I << " doesn't have the correct alias information";
// EXPECT_EQ expands such that if we increment I above, it won't get // EXPECT_EQ expands such that if we increment I above, it won't get
// incremented except when we try to print the error message. // incremented except when we try to print the error message.
@ -1129,7 +1129,7 @@ TEST_F(MemorySSATest, TestLoadMayAlias) {
} }
for (LoadInst *V : {LA2, LB2}) { for (LoadInst *V : {LA2, LB2}) {
MemoryUse *MemUse = dyn_cast_or_null<MemoryUse>(MSSA.getMemoryAccess(V)); MemoryUse *MemUse = dyn_cast_or_null<MemoryUse>(MSSA.getMemoryAccess(V));
EXPECT_EQ(MemUse->getOptimizedAccessType(), MustAlias) EXPECT_EQ(MemUse->getOptimizedAccessType(), AliasResult::MustAlias)
<< "Load " << I << " doesn't have the correct alias information"; << "Load " << I << " doesn't have the correct alias information";
// EXPECT_EQ expands such that if we increment I above, it won't get // EXPECT_EQ expands such that if we increment I above, it won't get
// incremented except when we try to print the error message. // incremented except when we try to print the error message.
@ -1189,13 +1189,13 @@ TEST_F(MemorySSATest, TestStoreMayAlias) {
EXPECT_EQ(MemDef->isOptimized(), true) EXPECT_EQ(MemDef->isOptimized(), true)
<< "Store " << I << " was not optimized"; << "Store " << I << " was not optimized";
if (I == 1 || I == 3 || I == 4) if (I == 1 || I == 3 || I == 4)
EXPECT_EQ(MemDef->getOptimizedAccessType(), MayAlias) EXPECT_EQ(MemDef->getOptimizedAccessType(), AliasResult::MayAlias)
<< "Store " << I << " doesn't have the correct alias information"; << "Store " << I << " doesn't have the correct alias information";
else if (I == 0 || I == 2) else if (I == 0 || I == 2)
EXPECT_EQ(MemDef->getOptimizedAccessType(), None) EXPECT_EQ(MemDef->getOptimizedAccessType(), None)
<< "Store " << I << " doesn't have the correct alias information"; << "Store " << I << " doesn't have the correct alias information";
else else
EXPECT_EQ(MemDef->getOptimizedAccessType(), MustAlias) EXPECT_EQ(MemDef->getOptimizedAccessType(), AliasResult::MustAlias)
<< "Store " << I << " doesn't have the correct alias information"; << "Store " << I << " doesn't have the correct alias information";
// EXPECT_EQ expands such that if we increment I above, it won't get // EXPECT_EQ expands such that if we increment I above, it won't get
// incremented except when we try to print the error message. // incremented except when we try to print the error message.