1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 10:32:48 +02: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
/// no-alias.
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.
@ -522,13 +522,13 @@ public:
/// A trivial helper function to check to see if the specified pointers are
/// must-alias.
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.
bool isMustAlias(const Value *V1, const Value *V2) {
return alias(V1, LocationSize::precise(1), V2, LocationSize::precise(1)) ==
MustAlias;
AliasResult::MustAlias;
}
/// Checks whether the given location points to constant memory, or if
@ -915,11 +915,12 @@ public:
return AA.getModRefBehavior(Call);
}
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) {
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,
const MemoryLocation &LocB) const;
@ -1149,7 +1150,7 @@ protected:
public:
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
AAQueryInfo &AAQI) {
return MayAlias;
return AliasResult::MayAlias;
}
bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -850,10 +850,10 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call,
AliasResult AR = getBestAAResults().alias(
MemoryLocation::getBeforeOrAfter(*CI),
MemoryLocation::getBeforeOrAfter(Object), AAQI);
if (AR != MustAlias)
if (AR != AliasResult::MustAlias)
IsMustAlias = false;
// Operand doesn't alias 'Object', continue looking for other aliases
if (AR == NoAlias)
if (AR == AliasResult::NoAlias)
continue;
// Operand aliases 'Object', but call doesn't modify it. Strengthen
// 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)) {
// Be conservative if the accessed pointer may alias the allocation -
// fallback to the generic handling below.
if (getBestAAResults().alias(MemoryLocation::getBeforeOrAfter(Call),
Loc, AAQI) == NoAlias)
if (getBestAAResults().alias(MemoryLocation::getBeforeOrAfter(Call), Loc,
AAQI) == AliasResult::NoAlias)
return ModRefInfo::NoModRef;
}
@ -910,9 +910,9 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call,
getBestAAResults().alias(MemoryLocation::getForDest(Inst), Loc, AAQI);
// It's also possible for Loc to alias both src and dest, or neither.
ModRefInfo rv = ModRefInfo::NoModRef;
if (SrcAA != NoAlias)
if (SrcAA != AliasResult::NoAlias)
rv = setRef(rv);
if (DestAA != NoAlias)
if (DestAA != AliasResult::NoAlias)
rv = setMod(rv);
return rv;
}
@ -1032,7 +1032,7 @@ AliasResult BasicAAResult::aliasGEP(
// compile-time constant.
if (!DecompGEP1.HasCompileTimeConstantScale ||
!DecompGEP2.HasCompileTimeConstantScale)
return MayAlias;
return AliasResult::MayAlias;
assert(DecompGEP1.Base == UnderlyingV1 && DecompGEP2.Base == UnderlyingV2 &&
"DecomposeGEPExpression returned a result different from "
@ -1048,14 +1048,14 @@ AliasResult BasicAAResult::aliasGEP(
if (*DecompGEP1.InBounds && DecompGEP1.VarIndices.empty() &&
V2Size.hasValue() && DecompGEP1.Offset.sge(V2Size.getValue()) &&
isBaseOfObject(DecompGEP2.Base))
return NoAlias;
return AliasResult::NoAlias;
if (isa<GEPOperator>(V2)) {
// Symmetric case to above.
if (*DecompGEP2.InBounds && DecompGEP1.VarIndices.empty() &&
V1Size.hasValue() && DecompGEP1.Offset.sle(-V1Size.getValue()) &&
isBaseOfObject(DecompGEP1.Base))
return NoAlias;
return AliasResult::NoAlias;
}
// 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
// will improve this situation.
if (BaseAlias != MustAlias) {
assert(BaseAlias == NoAlias || BaseAlias == MayAlias);
if (BaseAlias != AliasResult::MustAlias) {
assert(BaseAlias == AliasResult::NoAlias ||
BaseAlias == AliasResult::MayAlias);
return BaseAlias;
}
@ -1116,9 +1117,9 @@ AliasResult BasicAAResult::aliasGEP(
AAQI.setClobberOffset(LeftPtr, RightPtr, LSize, RSize,
Off.getSExtValue());
}
return PartialAlias;
return AliasResult::PartialAlias;
}
return NoAlias;
return AliasResult::NoAlias;
}
}
@ -1169,7 +1170,7 @@ AliasResult BasicAAResult::aliasGEP(
if (V1Size.hasValue() && V2Size.hasValue() &&
ModOffset.uge(V2Size.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
// 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 (AllNonNegative && V2Size.hasValue() &&
DecompGEP1.Offset.uge(V2Size.getValue()))
return NoAlias;
return AliasResult::NoAlias;
// Similarly, if the variables are non-positive, then the total offset is
// also non-positive and <= DecompGEP1.Offset. We have the following layout:
// [TotalOffset, TotalOffset+V1Size) ... [0, V2Size)
// If -DecompGEP1.Offset >= V1Size, the accesses don't alias.
if (AllNonPositive && V1Size.hasValue() &&
(-DecompGEP1.Offset).uge(V1Size.getValue()))
return NoAlias;
return AliasResult::NoAlias;
if (V1Size.hasValue() && V2Size.hasValue()) {
// Try to determine whether abs(VarIndex) > 0.
@ -1215,19 +1216,19 @@ AliasResult BasicAAResult::aliasGEP(
// or higher both do not alias.
if (OffsetLo.isNegative() && (-OffsetLo).uge(V1Size.getValue()) &&
OffsetHi.isNonNegative() && OffsetHi.uge(V2Size.getValue()))
return NoAlias;
return AliasResult::NoAlias;
}
}
if (constantOffsetHeuristic(DecompGEP1.VarIndices, V1Size, V2Size,
DecompGEP1.Offset, &AC, DT))
return NoAlias;
return AliasResult::NoAlias;
}
// Statically, we can see that the base objects are the same, but the
// pointers have dynamic offsets which we can't resolve. And none of our
// little tricks above worked.
return MayAlias;
return AliasResult::MayAlias;
}
static AliasResult MergeAliasResults(AliasResult A, AliasResult B) {
@ -1235,11 +1236,11 @@ static AliasResult MergeAliasResults(AliasResult A, AliasResult B) {
if (A == B)
return A;
// A mix of PartialAlias and MustAlias is PartialAlias.
if ((A == PartialAlias && B == MustAlias) ||
(B == PartialAlias && A == MustAlias))
return PartialAlias;
if ((A == AliasResult::PartialAlias && B == AliasResult::MustAlias) ||
(B == AliasResult::PartialAlias && A == AliasResult::MustAlias))
return AliasResult::PartialAlias;
// Otherwise, we don't know anything.
return MayAlias;
return AliasResult::MayAlias;
}
/// 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(
MemoryLocation(SI->getTrueValue(), SISize),
MemoryLocation(SI2->getTrueValue(), V2Size), AAQI);
if (Alias == MayAlias)
return MayAlias;
if (Alias == AliasResult::MayAlias)
return AliasResult::MayAlias;
AliasResult ThisAlias = getBestAAResults().alias(
MemoryLocation(SI->getFalseValue(), SISize),
MemoryLocation(SI2->getFalseValue(), V2Size), AAQI);
@ -1268,8 +1269,8 @@ BasicAAResult::aliasSelect(const SelectInst *SI, LocationSize SISize,
AliasResult Alias = getBestAAResults().alias(
MemoryLocation(V2, V2Size),
MemoryLocation(SI->getTrueValue(), SISize), AAQI);
if (Alias == MayAlias)
return MayAlias;
if (Alias == AliasResult::MayAlias)
return AliasResult::MayAlias;
AliasResult ThisAlias = getBestAAResults().alias(
MemoryLocation(V2, V2Size),
@ -1298,7 +1299,7 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
*Alias = MergeAliasResults(*Alias, ThisAlias);
else
Alias = ThisAlias;
if (*Alias == MayAlias)
if (*Alias == AliasResult::MayAlias)
break;
}
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
// where 'm' and 'n' are the number of PHI sources.
if (PhiValueSet.size() > MaxLookupSearchDepth)
return MayAlias;
return AliasResult::MayAlias;
// Add the values to V1Srcs
for (Value *PV1 : PhiValueSet) {
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
// phi nodes and (combined with the recursive phi handling) simple
// pointer induction variable patterns.
return MayAlias;
return AliasResult::MayAlias;
}
OnePhi = PV1;
}
@ -1362,14 +1363,14 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
if (OnePhi && UniqueSrc.size() > 1)
// Out of an abundance of caution, allow only the trivial lcssa and
// recursive phi cases.
return MayAlias;
return AliasResult::MayAlias;
}
// 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
// block, but return MayAlias just in case.
if (V1Srcs.empty())
return MayAlias;
return AliasResult::MayAlias;
// If this PHI node is recursive, indicate that the pointer may be moved
// 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.
// Other results are not possible.
if (Alias == MayAlias)
return MayAlias;
if (Alias == AliasResult::MayAlias)
return AliasResult::MayAlias;
// With recursive phis we cannot guarantee that MustAlias/PartialAlias will
// remain valid to all elements and needs to conservatively return MayAlias.
if (isRecursive && Alias != NoAlias)
return MayAlias;
if (isRecursive && Alias != AliasResult::NoAlias)
return AliasResult::MayAlias;
// If all sources of the PHI node NoAlias or MustAlias V2, then returns
// NoAlias / MustAlias. Otherwise, returns MayAlias.
@ -1413,7 +1414,7 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
AliasResult ThisAlias = getBestAAResults().alias(
MemoryLocation(V2, V2Size), MemoryLocation(V, PNSize), *UseAAQI);
Alias = MergeAliasResults(ThisAlias, Alias);
if (Alias == MayAlias)
if (Alias == AliasResult::MayAlias)
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
// pointer values are.
if (V1Size.isZero() || V2Size.isZero())
return NoAlias;
return AliasResult::NoAlias;
// Strip off any casts if they exist.
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
// value for undef that aliases nothing in the program.
if (isa<UndefValue>(V1) || isa<UndefValue>(V2))
return NoAlias;
return AliasResult::NoAlias;
// Are we checking for alias of the same value?
// 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
// reach the value.
if (isValueEqualInPotentialCycles(V1, V2))
return MustAlias;
return AliasResult::MustAlias;
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.
const Value *O1 = getUnderlyingObject(V1, MaxLookupSearchDepth);
@ -1459,26 +1460,26 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
// don't alias any other pointer.
if (const ConstantPointerNull *CPN = dyn_cast<ConstantPointerNull>(O1))
if (!NullPointerIsDefined(&F, CPN->getType()->getAddressSpace()))
return NoAlias;
return AliasResult::NoAlias;
if (const ConstantPointerNull *CPN = dyn_cast<ConstantPointerNull>(O2))
if (!NullPointerIsDefined(&F, CPN->getType()->getAddressSpace()))
return NoAlias;
return AliasResult::NoAlias;
if (O1 != O2) {
// If V1/V2 point to two different objects, we know that we have no alias.
if (isIdentifiedObject(O1) && isIdentifiedObject(O2))
return NoAlias;
return AliasResult::NoAlias;
// Constant pointers can't alias with non-const isIdentifiedObject objects.
if ((isa<Constant>(O1) && isIdentifiedObject(O2) && !isa<Constant>(O2)) ||
(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
// unambigously identified at the function level.
if ((isa<Argument>(O1) && isIdentifiedFunctionLocal(O2)) ||
(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
// 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.
if (isEscapeSource(O1) &&
isNonEscapingLocalObject(O2, &AAQI.IsCapturedCache))
return NoAlias;
return AliasResult::NoAlias;
if (isEscapeSource(O2) &&
isNonEscapingLocalObject(O1, &AAQI.IsCapturedCache))
return NoAlias;
return AliasResult::NoAlias;
}
// 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(
O1, getMinimalExtentFrom(*V2, V2Size, DL, NullIsValidLocation), DL,
TLI, NullIsValidLocation)))
return NoAlias;
return AliasResult::NoAlias;
// If one the accesses may be before the accessed pointer, canonicalize this
// 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
// stack overflows.
if (AAQI.Depth >= 512)
return MayAlias;
return AliasResult::MayAlias;
// Check the cache before climbing up use-def chains. This also terminates
// otherwise infinitely recursive queries.
@ -1533,7 +1534,7 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
if (V1 > V2)
std::swap(Locs.first, Locs.second);
const auto &Pair = AAQI.AliasCache.try_emplace(
Locs, AAQueryInfo::CacheEntry{NoAlias, 0});
Locs, AAQueryInfo::CacheEntry{AliasResult::NoAlias, 0});
if (!Pair.second) {
auto &Entry = Pair.first->second;
if (!Entry.isDefinitive()) {
@ -1554,9 +1555,10 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
auto &Entry = It->second;
// 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)
Result = MayAlias;
Result = AliasResult::MayAlias;
// This is a definitive result now, when considered as a root query.
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.
// 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);
return Result;
}
@ -1583,31 +1586,31 @@ AliasResult BasicAAResult::aliasCheckRecursive(
AAQueryInfo &AAQI, const Value *O1, const Value *O2) {
if (const GEPOperator *GV1 = dyn_cast<GEPOperator>(V1)) {
AliasResult Result = aliasGEP(GV1, V1Size, V2, V2Size, O1, O2, AAQI);
if (Result != MayAlias)
if (Result != AliasResult::MayAlias)
return Result;
} else if (const GEPOperator *GV2 = dyn_cast<GEPOperator>(V2)) {
AliasResult Result = aliasGEP(GV2, V2Size, V1, V1Size, O2, O1, AAQI);
if (Result != MayAlias)
if (Result != AliasResult::MayAlias)
return Result;
}
if (const PHINode *PN = dyn_cast<PHINode>(V1)) {
AliasResult Result = aliasPHI(PN, V1Size, V2, V2Size, AAQI);
if (Result != MayAlias)
if (Result != AliasResult::MayAlias)
return Result;
} else if (const PHINode *PN = dyn_cast<PHINode>(V2)) {
AliasResult Result = aliasPHI(PN, V2Size, V1, V1Size, AAQI);
if (Result != MayAlias)
if (Result != AliasResult::MayAlias)
return Result;
}
if (const SelectInst *S1 = dyn_cast<SelectInst>(V1)) {
AliasResult Result = aliasSelect(S1, V1Size, V2, V2Size, AAQI);
if (Result != MayAlias)
if (Result != AliasResult::MayAlias)
return Result;
} else if (const SelectInst *S2 = dyn_cast<SelectInst>(V2)) {
AliasResult Result = aliasSelect(S2, V2Size, V1, V1Size, AAQI);
if (Result != MayAlias)
if (Result != AliasResult::MayAlias)
return Result;
}
@ -1618,10 +1621,10 @@ AliasResult BasicAAResult::aliasCheckRecursive(
if (V1Size.isPrecise() && V2Size.isPrecise() &&
(isObjectSize(O1, V1Size.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.

View File

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

View File

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

View File

@ -657,8 +657,8 @@ static AliasResult underlyingObjectsAlias(AAResults *AA,
MemoryLocation::getBeforeOrAfter(LocA.Ptr, LocA.AATags);
MemoryLocation LocBS =
MemoryLocation::getBeforeOrAfter(LocB.Ptr, LocB.AATags);
if (AA->alias(LocAS, LocBS) == NoAlias)
return NoAlias;
if (AA->isNoAlias(LocAS, LocBS))
return AliasResult::NoAlias;
// Check the underlying objects are the same
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 (AObj == BObj)
return MustAlias;
return AliasResult::MustAlias;
// We may have hit the recursion limit for underlying objects, or have
// underlying objects where we don't know they will alias.
if (!isIdentifiedObject(AObj) || !isIdentifiedObject(BObj))
return MayAlias;
return AliasResult::MayAlias;
// Otherwise we know the objects are different and both identified objects so
// must not alias.
return NoAlias;
return AliasResult::NoAlias;
}
@ -3501,16 +3501,16 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
switch (underlyingObjectsAlias(AA, F->getParent()->getDataLayout(),
MemoryLocation::get(Dst),
MemoryLocation::get(Src))) {
case MayAlias:
case PartialAlias:
case AliasResult::MayAlias:
case AliasResult::PartialAlias:
// cannot analyse objects if we don't understand their aliasing.
LLVM_DEBUG(dbgs() << "can't analyze may or partial alias\n");
return std::make_unique<Dependence>(Src, Dst);
case NoAlias:
case AliasResult::NoAlias:
// If the objects noalias, they are distinct, accesses are independent.
LLVM_DEBUG(dbgs() << "no alias\n");
return nullptr;
case MustAlias:
case AliasResult::MustAlias:
break; // The underlying objects alias; test accesses for dependence.
}
@ -3914,9 +3914,9 @@ const SCEV *DependenceInfo::getSplitIteration(const Dependence &Dep,
assert(isLoadOrStore(Dst));
Value *SrcPtr = getLoadStorePointerOperand(Src);
Value *DstPtr = getLoadStorePointerOperand(Dst);
assert(underlyingObjectsAlias(AA, F->getParent()->getDataLayout(),
MemoryLocation::get(Dst),
MemoryLocation::get(Src)) == MustAlias);
assert(underlyingObjectsAlias(
AA, F->getParent()->getDataLayout(), MemoryLocation::get(Dst),
MemoryLocation::get(Src)) == AliasResult::MustAlias);
// establish loop nesting levels
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
// globals we know these can't alias.
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
// this result if necessary for performance. This does not appear to be
// a common problem in practice.
if (EnableUnsafeGlobalsModRefAliasResults)
if ((GV1 || GV2) && GV1 != GV2)
return NoAlias;
return AliasResult::NoAlias;
// Check for a special case where a non-escaping global can be used to
// conclude no-alias.
@ -862,7 +862,7 @@ AliasResult GlobalsAAResult::alias(const MemoryLocation &LocA,
const GlobalValue *GV = GV1 ? GV1 : GV2;
const Value *UV = GV1 ? UV2 : UV1;
if (isNonEscapingGlobalNoAlias(GV, UV))
return NoAlias;
return AliasResult::NoAlias;
}
// 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
// different indirect globals they cannot alias.
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
// strictly safe but we can fake this result if necessary for performance.
// This does not appear to be a common problem in practice.
if (EnableUnsafeGlobalsModRefAliasResults)
if ((GV1 || GV2) && GV1 != GV2)
return NoAlias;
return AliasResult::NoAlias;
return AAResultBase::alias(LocA, LocB, AAQI);
}
@ -925,7 +925,7 @@ ModRefInfo GlobalsAAResult::getModRefInfoForArgument(const CallBase *Call,
!all_of(Objects, [&](const Value *V) {
return this->alias(MemoryLocation::getBeforeOrAfter(V),
MemoryLocation::getBeforeOrAfter(GV),
AAQI) == NoAlias;
AAQI) == AliasResult::NoAlias;
}))
return ConservativeResult;

View File

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

View File

@ -457,9 +457,9 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom(
MemoryLocation Loc;
/*ModRefInfo MR =*/ GetLocation(II, Loc, TLI);
AliasResult R = BatchAA.alias(Loc, MemLoc);
if (R == NoAlias)
if (R == AliasResult::NoAlias)
continue;
if (R == MustAlias)
if (R == AliasResult::MustAlias)
return MemDepResult::getDef(II);
if (ID == Intrinsic::masked_load)
continue;
@ -505,11 +505,11 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom(
AliasResult R = BatchAA.alias(LoadLoc, MemLoc);
if (isLoad) {
if (R == NoAlias)
if (R == AliasResult::NoAlias)
continue;
// Must aliased loads are defs of each other.
if (R == MustAlias)
if (R == AliasResult::MustAlias)
return MemDepResult::getDef(Inst);
#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
// client to handle.
if (R == PartialAlias)
if (R == AliasResult::PartialAlias)
return MemDepResult::getClobber(Inst);
#endif
@ -529,7 +529,7 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom(
}
// Stores don't depend on other no-aliased accesses.
if (R == NoAlias)
if (R == AliasResult::NoAlias)
continue;
// 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.
AliasResult R = BatchAA.alias(StoreLoc, MemLoc);
if (R == NoAlias)
if (R == AliasResult::NoAlias)
continue;
if (R == MustAlias)
if (R == AliasResult::MustAlias)
return MemDepResult::getDef(Inst);
if (isInvariantLoad)
continue;

View File

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

View File

@ -49,7 +49,7 @@ AliasResult ObjCARCAAResult::alias(const MemoryLocation &LocA,
AliasResult Result =
AAResultBase::alias(MemoryLocation(SA, LocA.Size, LocA.AATags),
MemoryLocation(SB, LocB.Size, LocB.AATags), AAQI);
if (Result != MayAlias)
if (Result != AliasResult::MayAlias)
return Result;
// 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);
// We can't use MustAlias or PartialAlias results here because
// GetUnderlyingObjCPtr may return an offsetted pointer value.
if (Result == NoAlias)
return NoAlias;
if (Result == AliasResult::NoAlias)
return AliasResult::NoAlias;
}
// If that failed, fail. We don't need to chain here, since that's covered
// by the earlier precise query.
return MayAlias;
return AliasResult::MayAlias;
}
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
// case.
if (LocA.Size.isZero() || LocB.Size.isZero())
return NoAlias;
return AliasResult::NoAlias;
// This is SCEVAAResult. Get the SCEVs!
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 (AS == BS)
return MustAlias;
return AliasResult::MustAlias;
// If something is known about the difference between the two addresses,
// 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.
if (ASizeInt.ule(SE.getUnsignedRange(BA).getUnsignedMin()) &&
(-BSizeInt).uge(SE.getUnsignedRange(BA).getUnsignedMax()))
return NoAlias;
return AliasResult::NoAlias;
// Folding the subtraction while preserving range information can be tricky
// (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.
if (BSizeInt.ule(SE.getUnsignedRange(AB).getUnsignedMin()) &&
(-ASizeInt).uge(SE.getUnsignedRange(AB).getUnsignedMax()))
return NoAlias;
return AliasResult::NoAlias;
}
// If ScalarEvolution can find an underlying object, form a new query.
@ -89,8 +89,8 @@ AliasResult SCEVAAResult::alias(const MemoryLocation &LocA,
BO ? LocationSize::beforeOrAfterPointer()
: LocB.Size,
BO ? AAMDNodes() : LocB.AATags),
AAQI) == NoAlias)
return NoAlias;
AAQI) == AliasResult::NoAlias)
return AliasResult::NoAlias;
// Forward the query to the next analysis.
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;
if (!mayAliasInScopes(AScopes, BNoAlias))
return NoAlias;
return AliasResult::NoAlias;
if (!mayAliasInScopes(BScopes, ANoAlias))
return NoAlias;
return AliasResult::NoAlias;
// If they may alias, chain to the next AliasAnalysis.
return AAResultBase::alias(LocA, LocB, AAQI);

View File

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

View File

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

View File

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

View File

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

View File

@ -813,11 +813,10 @@ void SwingSchedulerDAG::addLoopCarriedDependences(AliasAnalysis *AA) {
SU.addPred(Dep);
continue;
}
AliasResult AAResult = AA->alias(
MemoryLocation::getAfter(MMO1->getValue(), MMO1->getAAInfo()),
MemoryLocation::getAfter(MMO2->getValue(), MMO2->getAAInfo()));
if (AAResult != NoAlias) {
if (!AA->isNoAlias(
MemoryLocation::getAfter(MMO1->getValue(), MMO1->getAAInfo()),
MemoryLocation::getAfter(MMO2->getValue(),
MMO2->getAAInfo()))) {
SDep Dep(Load, SDep::Barrier);
Dep.setLatency(1);
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 Overlap0 = *Size0 + SrcValOffset0 - MinOffset;
int64_t Overlap1 = *Size1 + SrcValOffset1 - MinOffset;
AliasResult AAResult = AA->alias(
MemoryLocation(MUC0.MMO->getValue(), Overlap0,
UseTBAA ? MUC0.MMO->getAAInfo() : AAMDNodes()),
MemoryLocation(MUC1.MMO->getValue(), Overlap1,
UseTBAA ? MUC1.MMO->getAAInfo() : AAMDNodes()));
if (AAResult == NoAlias)
if (AA->isNoAlias(
MemoryLocation(MUC0.MMO->getValue(), Overlap0,
UseTBAA ? MUC0.MMO->getAAInfo() : AAMDNodes()),
MemoryLocation(MUC1.MMO->getValue(), Overlap1,
UseTBAA ? MUC1.MMO->getAAInfo() : AAMDNodes())))
return false;
}

View File

@ -41,24 +41,28 @@ void AMDGPUAAWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
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_assert(AMDGPUAS::MAX_AMDGPU_ADDRESS <= 7, "Addr space out of range");
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];
}
@ -70,7 +74,7 @@ AliasResult AMDGPUAAResult::alias(const MemoryLocation &LocA,
unsigned asB = LocB.Ptr->getType()->getPointerAddressSpace();
AliasResult Result = getAliasResult(asA, asB);
if (Result == NoAlias)
if (Result == AliasResult::NoAlias)
return Result;
// 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
// visible. Note that this even holds for regular functions.
if (LI->getPointerAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS)
return NoAlias;
return AliasResult::NoAlias;
} else if (const Argument *Arg = dyn_cast<Argument>(ObjA)) {
const Function *F = Arg->getParent();
switch (F->getCallingConv()) {
case CallingConv::AMDGPU_KERNEL:
// In the kernel function, kernel arguments won't alias to (local)
// variables in shared or private address space.
return NoAlias;
return AliasResult::NoAlias;
default:
// TODO: In the regular function, if that local variable in the
// 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;
MemoryLocation SL(SMO.getValue(), SMO.getSize(), SMO.getAAInfo());
if (AA->alias(L, SL))
if (!AA->isNoAlias(L, SL))
return true;
}

View File

@ -1432,8 +1432,8 @@ bool SystemZDAGToDAGISel::canUseBlockOperation(StoreSDNode *Store,
if (V1 == V2 && End1 == End2)
return false;
return !AA->alias(MemoryLocation(V1, End1, Load->getAAInfo()),
MemoryLocation(V2, End2, Store->getAAInfo()));
return AA->isNoAlias(MemoryLocation(V1, End1, Load->getAAInfo()),
MemoryLocation(V2, End2, Store->getAAInfo()));
}
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 Overlapb = Op2.getSize() + Op2.getOffset() - MinOffset;
AliasResult AAResult =
AA->alias(MemoryLocation(Op1.getValue(), Overlapa, Op1.getAAInfo()),
MemoryLocation(Op2.getValue(), Overlapb, Op2.getAAInfo()));
return AAResult != NoAlias;
return !AA->isNoAlias(
MemoryLocation(Op1.getValue(), Overlapa, Op1.getAAInfo()),
MemoryLocation(Op2.getValue(), Overlapb, Op2.getAAInfo()));
}
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.
static bool operandReferences(CallInst *CI, AllocaInst *Frame, AAResults &AA) {
for (Value *Op : CI->operand_values())
if (AA.alias(Op, Frame) != NoAlias)
if (!AA.isNoAlias(Op, Frame))
return true;
return false;
}

View File

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

View File

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

View File

@ -1092,10 +1092,8 @@ public:
MemoryLocation StoreLoc = MemoryLocation::get(Store);
MemoryLocation LoadLoc = MemoryLocation::get(Load);
AliasResult LdAliased = AA->alias(LoadLoc, StoreLoc);
// If we can statically determine noalias we're good.
if (!LdAliased)
if (AA->isNoAlias(LoadLoc, StoreLoc))
return Load->getPointerOperand();
// 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) {
if (BI->mayReadFromMemory() || BI->mayWriteToMemory()) {
// Check alias with Head2.
if (!AA || AA->alias(&*iter1, &*BI))
if (!AA || !AA->isNoAlias(&*iter1, &*BI))
return false;
}
}

View File

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

View File

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

View File

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