/// 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.
/// 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
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;
public:
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
AAQueryInfo &AAQI) {
- return MayAlias;
+ return AliasResult::MayAlias;
}
bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI,
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.
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;
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);
}
}
void setDefiningAccess(MemoryAccess *DMA, bool Optimized = false,
- Optional<AliasResult> AR = MayAlias) {
+ Optional<AliasResult> AR = AliasResult::MayAlias) {
if (!Optimized) {
setOperand(0, DMA);
return;
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)
AAQI.Depth++;
for (const auto &AA : AAs) {
Result = AA->alias(LocA, LocB, AAQI);
- if (Result != MayAlias)
+ if (Result != AliasResult::MayAlias)
break;
}
AAQI.Depth--;
}
if (AAQI.Depth == 0) {
- if (Result == NoAlias)
+ if (Result == AliasResult::NoAlias)
++NumNoAlias;
- else if (Result == MustAlias)
+ else if (Result == AliasResult::MustAlias)
++NumMustAlias;
else
++NumMayAlias;
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.
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;
}
// 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.
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
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;
}
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
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;
}
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;
}
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;
}
// 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;
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;
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;
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;
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;
}
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);
}
const AAMDNodes &AAInfo,
AliasAnalysis &AA) const {
if (AliasAny)
- return MayAlias;
+ return AliasResult::MayAlias;
if (Alias == SetMustAlias) {
assert(UnknownInsts.empty() && "Illegal must alias 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...
- 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()) {
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,
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) {
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.
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;
}
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;
}
// 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 "
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
// 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;
}
AAQI.setClobberOffset(LeftPtr, RightPtr, LSize, RSize,
Off.getSExtValue());
}
- return PartialAlias;
+ return AliasResult::PartialAlias;
}
- return NoAlias;
+ return AliasResult::NoAlias;
}
}
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:
// 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.
// 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) {
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
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);
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),
*Alias = MergeAliasResults(*Alias, ThisAlias);
else
Alias = ThisAlias;
- if (*Alias == MayAlias)
+ if (*Alias == AliasResult::MayAlias)
break;
}
return *Alias;
// 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))
// 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;
}
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
// 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.
AliasResult ThisAlias = getBestAAResults().alias(
MemoryLocation(V2, V2Size), MemoryLocation(V, PNSize), *UseAAQI);
Alias = MergeAliasResults(ThisAlias, Alias);
- if (Alias == MayAlias)
+ if (Alias == AliasResult::MayAlias)
break;
}
// 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();
// 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
// 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);
// 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
// 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
(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
// 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.
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()) {
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;
// 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;
}
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;
}
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.
auto *ValB = LocB.Ptr;
if (!ValA->getType()->isPointerTy() || !ValB->getType()->isPointerTy())
- return NoAlias;
+ return AliasResult::NoAlias;
auto *Fn = parentFunctionOfValue(ValA);
if (!Fn) {
LLVM_DEBUG(
dbgs()
<< "CFLAndersAA: could not extract parent function information.\n");
- return MayAlias;
+ return AliasResult::MayAlias;
}
} else {
assert(!parentFunctionOfValue(ValB) || parentFunctionOfValue(ValB) == Fn);
// 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.
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;
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));
LLVM_DEBUG(
dbgs()
<< "CFLSteensAA: could not extract parent function information.\n");
- return MayAlias;
+ return AliasResult::MayAlias;
}
if (MaybeFnA) {
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;
// - 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;
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);
// 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;
}
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.
}
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);
// 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.
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
// 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);
}
!all_of(Objects, [&](const Value *V) {
return this->alias(MemoryLocation::getBeforeOrAfter(V),
MemoryLocation::getBeforeOrAfter(GV),
- AAQI) == NoAlias;
+ AAQI) == AliasResult::NoAlias;
}))
return ConservativeResult;
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);
}
}
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;
}
// 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;
}
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;
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
// 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
}
// 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.
// 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;
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:
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};
}
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;
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);
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,
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
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();
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
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,
// 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));
// 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.
// 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
// 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.
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);
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);
return AAResultBase::alias(LocA, LocB, AAQI);
// Otherwise return a definitive result.
- return NoAlias;
+ return AliasResult::NoAlias;
}
bool TypeBasedAAResult::pointsToConstantMemory(const MemoryLocation &Loc,
MemoryLocation(Op2.getValue(), Overlapb,
UseTBAA ? Op2.getAAInfo() : AAMDNodes()));
- return AAResult != NoAlias;
+ return AAResult != AliasResult::NoAlias;
}
bool VLIWPacketizerList::alias(const MachineInstr &MI1,
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;
}
}
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,
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);
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;
}
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];
}
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
// 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
return true;
MemoryLocation SL(SMO.getValue(), SMO.getSize(), SMO.getAAInfo());
- if (AA->alias(L, SL))
+ if (!AA->isNoAlias(L, SL))
return true;
}
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 {
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) {
// 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;
}
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) {
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;
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) {
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;
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;
}
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
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;
}
}
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;
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
AAQueryInfo &AAQI) {
CB();
- return MayAlias;
+ return AliasResult::MayAlias;
}
};
}
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) {
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
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));
}
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.
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.
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.
}
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.
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.