[llvm] 02988fc - [AA] Allow for flow-sensitive analyses.
Wenlei He via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 15 21:19:24 PST 2022
Author: David Goldblatt
Date: 2022-12-15T21:04:38-08:00
New Revision: 02988fce76d8a95e2bc33e80b581c3b0b2c92755
URL: https://github.com/llvm/llvm-project/commit/02988fce76d8a95e2bc33e80b581c3b0b2c92755
DIFF: https://github.com/llvm/llvm-project/commit/02988fce76d8a95e2bc33e80b581c3b0b2c92755.diff
LOG: [AA] Allow for flow-sensitive analyses.
All current analyses ignore the context. We make the argument mandatory
for analyses, but optional for the query interface.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D136512
Added:
Modified:
llvm/include/llvm/Analysis/AliasAnalysis.h
llvm/include/llvm/Analysis/BasicAliasAnalysis.h
llvm/include/llvm/Analysis/GlobalsModRef.h
llvm/include/llvm/Analysis/ObjCARCAliasAnalysis.h
llvm/include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h
llvm/include/llvm/Analysis/ScopedNoAliasAA.h
llvm/include/llvm/Analysis/TypeBasedAliasAnalysis.h
llvm/lib/Analysis/AliasAnalysis.cpp
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/lib/Analysis/GlobalsModRef.cpp
llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp
llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp
llvm/lib/Analysis/ScopedNoAliasAA.cpp
llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.h
llvm/unittests/Analysis/AliasAnalysisTest.cpp
llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/AliasAnalysis.h b/llvm/include/llvm/Analysis/AliasAnalysis.h
index 1c033d729fb84..953e15e358f12 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -548,8 +548,11 @@ class AAResults {
return canInstructionRangeModRef(I1, I2, MemoryLocation(Ptr, Size), Mode);
}
+ // CtxI can be nullptr, in which case the query is whether or not the aliasing
+ // relationship holds through the entire function.
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
- AAQueryInfo &AAQI);
+ AAQueryInfo &AAQI, const Instruction *CtxI = nullptr);
+
bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI,
bool OrLocal = false);
ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI,
@@ -684,7 +687,8 @@ class AAResults::Concept {
/// each other. This is the interface that must be implemented by specific
/// alias analysis implementations.
virtual AliasResult alias(const MemoryLocation &LocA,
- const MemoryLocation &LocB, AAQueryInfo &AAQI) = 0;
+ const MemoryLocation &LocB, AAQueryInfo &AAQI,
+ const Instruction *CtxI) = 0;
/// @}
//===--------------------------------------------------------------------===//
@@ -743,8 +747,8 @@ template <typename AAResultT> class AAResults::Model final : public Concept {
~Model() override = default;
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
- AAQueryInfo &AAQI) override {
- return Result.alias(LocA, LocB, AAQI);
+ AAQueryInfo &AAQI, const Instruction *CtxI) override {
+ return Result.alias(LocA, LocB, AAQI, CtxI);
}
ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI,
@@ -798,7 +802,7 @@ class AAResultBase {
public:
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
- AAQueryInfo &AAQI) {
+ AAQueryInfo &AAQI, const Instruction *I) {
return AliasResult::MayAlias;
}
diff --git a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
index 9f8f2853a5401..70cf7045a12c4 100644
--- a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
@@ -65,7 +65,7 @@ class BasicAAResult : public AAResultBase {
FunctionAnalysisManager::Invalidator &Inv);
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
- AAQueryInfo &AAQI);
+ AAQueryInfo &AAQI, const Instruction *CtxI);
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
AAQueryInfo &AAQI);
diff --git a/llvm/include/llvm/Analysis/GlobalsModRef.h b/llvm/include/llvm/Analysis/GlobalsModRef.h
index 1aabcf07dbd06..ab8ab8295b556 100644
--- a/llvm/include/llvm/Analysis/GlobalsModRef.h
+++ b/llvm/include/llvm/Analysis/GlobalsModRef.h
@@ -94,7 +94,7 @@ class GlobalsAAResult : public AAResultBase {
// Implement the AliasAnalysis API
//
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
- AAQueryInfo &AAQI);
+ AAQueryInfo &AAQI, const Instruction *CtxI);
using AAResultBase::getModRefInfo;
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
diff --git a/llvm/include/llvm/Analysis/ObjCARCAliasAnalysis.h b/llvm/include/llvm/Analysis/ObjCARCAliasAnalysis.h
index 790fbaf07e7f3..1a154c648fe61 100644
--- a/llvm/include/llvm/Analysis/ObjCARCAliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/ObjCARCAliasAnalysis.h
@@ -51,7 +51,7 @@ class ObjCARCAAResult : public AAResultBase {
}
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
- AAQueryInfo &AAQI);
+ AAQueryInfo &AAQI, const Instruction *CtxI);
ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI,
bool IgnoreLocals);
diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h b/llvm/include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h
index 7ba62c87505fc..53959b6c69ca5 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h
@@ -32,7 +32,7 @@ class SCEVAAResult : public AAResultBase {
SCEVAAResult(SCEVAAResult &&Arg) : AAResultBase(std::move(Arg)), SE(Arg.SE) {}
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
- AAQueryInfo &AAQI);
+ AAQueryInfo &AAQI, const Instruction *CtxI);
bool invalidate(Function &F, const PreservedAnalyses &PA,
FunctionAnalysisManager::Invalidator &Inv);
diff --git a/llvm/include/llvm/Analysis/ScopedNoAliasAA.h b/llvm/include/llvm/Analysis/ScopedNoAliasAA.h
index e318aa0644270..f6ade7c83a61a 100644
--- a/llvm/include/llvm/Analysis/ScopedNoAliasAA.h
+++ b/llvm/include/llvm/Analysis/ScopedNoAliasAA.h
@@ -37,7 +37,7 @@ class ScopedNoAliasAAResult : public AAResultBase {
}
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
- AAQueryInfo &AAQI);
+ AAQueryInfo &AAQI, const Instruction *CtxI);
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
AAQueryInfo &AAQI);
ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
diff --git a/llvm/include/llvm/Analysis/TypeBasedAliasAnalysis.h b/llvm/include/llvm/Analysis/TypeBasedAliasAnalysis.h
index 791ec65990e2b..36dd39c033aa6 100644
--- a/llvm/include/llvm/Analysis/TypeBasedAliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/TypeBasedAliasAnalysis.h
@@ -39,9 +39,10 @@ class TypeBasedAAResult : public AAResultBase {
}
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
- AAQueryInfo &AAQI);
+ AAQueryInfo &AAQI, const Instruction *CtxI);
ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI,
bool IgnoreLocals);
+
MemoryEffects getMemoryEffects(const CallBase *Call, AAQueryInfo &AAQI);
MemoryEffects getMemoryEffects(const Function *F);
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index 73de6faf8b18f..9e24f6b87bdb1 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -105,11 +105,12 @@ bool AAResults::invalidate(Function &F, const PreservedAnalyses &PA,
AliasResult AAResults::alias(const MemoryLocation &LocA,
const MemoryLocation &LocB) {
SimpleAAQueryInfo AAQIP(*this);
- return alias(LocA, LocB, AAQIP);
+ return alias(LocA, LocB, AAQIP, nullptr);
}
AliasResult AAResults::alias(const MemoryLocation &LocA,
- const MemoryLocation &LocB, AAQueryInfo &AAQI) {
+ const MemoryLocation &LocB, AAQueryInfo &AAQI,
+ const Instruction *CtxI) {
AliasResult Result = AliasResult::MayAlias;
if (EnableAATrace) {
@@ -121,7 +122,7 @@ AliasResult AAResults::alias(const MemoryLocation &LocA,
AAQI.Depth++;
for (const auto &AA : AAs) {
- Result = AA->alias(LocA, LocB, AAQI);
+ Result = AA->alias(LocA, LocB, AAQI, CtxI);
if (Result != AliasResult::MayAlias)
break;
}
@@ -243,7 +244,7 @@ ModRefInfo AAResults::getModRefInfo(const CallBase *Call,
continue;
unsigned ArgIdx = I.index();
MemoryLocation ArgLoc = MemoryLocation::getForArgument(Call, ArgIdx, TLI);
- AliasResult ArgAlias = alias(ArgLoc, Loc, AAQI);
+ AliasResult ArgAlias = alias(ArgLoc, Loc, AAQI, Call);
if (ArgAlias != AliasResult::NoAlias)
AllArgsMask |= getArgModRefInfo(Call, ArgIdx);
}
@@ -472,7 +473,7 @@ ModRefInfo AAResults::getModRefInfo(const LoadInst *L,
// If the load address doesn't alias the given address, it doesn't read
// or write the specified memory.
if (Loc.Ptr) {
- AliasResult AR = alias(MemoryLocation::get(L), Loc, AAQI);
+ AliasResult AR = alias(MemoryLocation::get(L), Loc, AAQI, L);
if (AR == AliasResult::NoAlias)
return ModRefInfo::NoModRef;
}
@@ -488,7 +489,7 @@ ModRefInfo AAResults::getModRefInfo(const StoreInst *S,
return ModRefInfo::ModRef;
if (Loc.Ptr) {
- AliasResult AR = alias(MemoryLocation::get(S), Loc, AAQI);
+ AliasResult AR = alias(MemoryLocation::get(S), Loc, AAQI, S);
// If the store address cannot alias the pointer in question, then the
// specified memory cannot be modified by the store.
if (AR == AliasResult::NoAlias)
@@ -521,7 +522,7 @@ ModRefInfo AAResults::getModRefInfo(const VAArgInst *V,
const MemoryLocation &Loc,
AAQueryInfo &AAQI) {
if (Loc.Ptr) {
- AliasResult AR = alias(MemoryLocation::get(V), Loc, AAQI);
+ AliasResult AR = alias(MemoryLocation::get(V), Loc, AAQI, V);
// If the va_arg address cannot alias the pointer in question, then the
// specified memory cannot be accessed by the va_arg.
if (AR == AliasResult::NoAlias)
@@ -570,7 +571,7 @@ ModRefInfo AAResults::getModRefInfo(const AtomicCmpXchgInst *CX,
return ModRefInfo::ModRef;
if (Loc.Ptr) {
- AliasResult AR = alias(MemoryLocation::get(CX), Loc, AAQI);
+ AliasResult AR = alias(MemoryLocation::get(CX), Loc, AAQI, CX);
// If the cmpxchg address does not alias the location, it does not access
// it.
if (AR == AliasResult::NoAlias)
@@ -588,7 +589,7 @@ ModRefInfo AAResults::getModRefInfo(const AtomicRMWInst *RMW,
return ModRefInfo::ModRef;
if (Loc.Ptr) {
- AliasResult AR = alias(MemoryLocation::get(RMW), Loc, AAQI);
+ AliasResult AR = alias(MemoryLocation::get(RMW), Loc, AAQI, RMW);
// If the atomicrmw address does not alias the location, it does not access
// it.
if (AR == AliasResult::NoAlias)
@@ -676,9 +677,9 @@ ModRefInfo AAResults::callCapturesBefore(const Instruction *I,
!Call->isByValArgument(ArgNo)))
continue;
- AliasResult AR = alias(
- MemoryLocation::getBeforeOrAfter(*CI),
- MemoryLocation::getBeforeOrAfter(Object), AAQI);
+ AliasResult AR =
+ alias(MemoryLocation::getBeforeOrAfter(*CI),
+ MemoryLocation::getBeforeOrAfter(Object), AAQI, Call);
// If this is a no-capture pointer argument, see if we can tell that it
// 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
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index f7b0edd7163a9..03774b706c82f 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -823,8 +823,8 @@ static bool notDifferentParent(const Value *O1, const Value *O2) {
#endif
AliasResult BasicAAResult::alias(const MemoryLocation &LocA,
- const MemoryLocation &LocB,
- AAQueryInfo &AAQI) {
+ const MemoryLocation &LocB, AAQueryInfo &AAQI,
+ const Instruction *) {
assert(notDifferentParent(LocA.Ptr, LocB.Ptr) &&
"BasicAliasAnalysis doesn't support interprocedural queries.");
return aliasCheck(LocA.Ptr, LocA.Size, LocB.Ptr, LocB.Size, AAQI);
diff --git a/llvm/lib/Analysis/GlobalsModRef.cpp b/llvm/lib/Analysis/GlobalsModRef.cpp
index 96f41c36001de..9947ef602be0f 100644
--- a/llvm/lib/Analysis/GlobalsModRef.cpp
+++ b/llvm/lib/Analysis/GlobalsModRef.cpp
@@ -828,7 +828,7 @@ bool GlobalsAAResult::invalidate(Module &, const PreservedAnalyses &PA,
/// address of the global isn't taken.
AliasResult GlobalsAAResult::alias(const MemoryLocation &LocA,
const MemoryLocation &LocB,
- AAQueryInfo &AAQI) {
+ AAQueryInfo &AAQI, const Instruction *) {
// Get the base object these pointers point to.
const Value *UV1 =
getUnderlyingObject(LocA.Ptr->stripPointerCastsForAliasAnalysis());
@@ -905,7 +905,7 @@ AliasResult GlobalsAAResult::alias(const MemoryLocation &LocA,
if ((GV1 || GV2) && GV1 != GV2)
return AliasResult::NoAlias;
- return AAResultBase::alias(LocA, LocB, AAQI);
+ return AAResultBase::alias(LocA, LocB, AAQI, nullptr);
}
ModRefInfo GlobalsAAResult::getModRefInfoForArgument(const CallBase *Call,
@@ -927,8 +927,8 @@ ModRefInfo GlobalsAAResult::getModRefInfoForArgument(const CallBase *Call,
// Try ::alias to see if all objects are known not to alias GV.
!all_of(Objects, [&](const Value *V) {
return this->alias(MemoryLocation::getBeforeOrAfter(V),
- MemoryLocation::getBeforeOrAfter(GV),
- AAQI) == AliasResult::NoAlias;
+ MemoryLocation::getBeforeOrAfter(GV), AAQI,
+ nullptr) == AliasResult::NoAlias;
}))
return ConservativeResult;
diff --git a/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp b/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp
index 93d56931d01c7..1ccf792d2f8c6 100644
--- a/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp
@@ -36,17 +36,17 @@ using namespace llvm::objcarc;
AliasResult ObjCARCAAResult::alias(const MemoryLocation &LocA,
const MemoryLocation &LocB,
- AAQueryInfo &AAQI) {
+ AAQueryInfo &AAQI, const Instruction *) {
if (!EnableARCOpts)
- return AAResultBase::alias(LocA, LocB, AAQI);
+ return AAResultBase::alias(LocA, LocB, AAQI, nullptr);
// First, strip off no-ops, including ObjC-specific no-ops, and try making a
// precise alias query.
const Value *SA = GetRCIdentityRoot(LocA.Ptr);
const Value *SB = GetRCIdentityRoot(LocB.Ptr);
- AliasResult Result =
- AAResultBase::alias(MemoryLocation(SA, LocA.Size, LocA.AATags),
- MemoryLocation(SB, LocB.Size, LocB.AATags), AAQI);
+ AliasResult Result = AAResultBase::alias(
+ MemoryLocation(SA, LocA.Size, LocA.AATags),
+ MemoryLocation(SB, LocB.Size, LocB.AATags), AAQI, nullptr);
if (Result != AliasResult::MayAlias)
return Result;
@@ -56,7 +56,8 @@ AliasResult ObjCARCAAResult::alias(const MemoryLocation &LocA,
const Value *UB = GetUnderlyingObjCPtr(SB);
if (UA != SA || UB != SB) {
Result = AAResultBase::alias(MemoryLocation::getBeforeOrAfter(UA),
- MemoryLocation::getBeforeOrAfter(UB), AAQI);
+ MemoryLocation::getBeforeOrAfter(UB), AAQI,
+ nullptr);
// We can't use MustAlias or PartialAlias results here because
// GetUnderlyingObjCPtr may return an offsetted pointer value.
if (Result == AliasResult::NoAlias)
diff --git a/llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp b/llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp
index 3d47dc6b30df8..08f7a91ff9b28 100644
--- a/llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp
@@ -34,7 +34,8 @@ static bool canComputePointerDiff(ScalarEvolution &SE,
}
AliasResult SCEVAAResult::alias(const MemoryLocation &LocA,
- const MemoryLocation &LocB, AAQueryInfo &AAQI) {
+ const MemoryLocation &LocB, AAQueryInfo &AAQI,
+ const Instruction *) {
// If either of the memory references is empty, it doesn't matter what the
// pointer values are. This allows the code below to ignore this special
// case.
@@ -101,11 +102,11 @@ AliasResult SCEVAAResult::alias(const MemoryLocation &LocA,
BO ? LocationSize::beforeOrAfterPointer()
: LocB.Size,
BO ? AAMDNodes() : LocB.AATags),
- AAQI) == AliasResult::NoAlias)
+ AAQI, nullptr) == AliasResult::NoAlias)
return AliasResult::NoAlias;
// Forward the query to the next analysis.
- return AAResultBase::alias(LocA, LocB, AAQI);
+ return AAResultBase::alias(LocA, LocB, AAQI, nullptr);
}
/// Given an expression, try to find a base value.
diff --git a/llvm/lib/Analysis/ScopedNoAliasAA.cpp b/llvm/lib/Analysis/ScopedNoAliasAA.cpp
index f510991b44633..f16ac0ab04166 100644
--- a/llvm/lib/Analysis/ScopedNoAliasAA.cpp
+++ b/llvm/lib/Analysis/ScopedNoAliasAA.cpp
@@ -53,9 +53,10 @@ static cl::opt<bool> EnableScopedNoAlias("enable-scoped-noalias",
AliasResult ScopedNoAliasAAResult::alias(const MemoryLocation &LocA,
const MemoryLocation &LocB,
- AAQueryInfo &AAQI) {
+ AAQueryInfo &AAQI,
+ const Instruction *) {
if (!EnableScopedNoAlias)
- return AAResultBase::alias(LocA, LocB, AAQI);
+ return AAResultBase::alias(LocA, LocB, AAQI, nullptr);
// Get the attached MDNodes.
const MDNode *AScopes = LocA.AATags.Scope, *BScopes = LocB.AATags.Scope;
@@ -69,7 +70,7 @@ AliasResult ScopedNoAliasAAResult::alias(const MemoryLocation &LocA,
return AliasResult::NoAlias;
// If they may alias, chain to the next AliasAnalysis.
- return AAResultBase::alias(LocA, LocB, AAQI);
+ return AAResultBase::alias(LocA, LocB, AAQI, nullptr);
}
ModRefInfo ScopedNoAliasAAResult::getModRefInfo(const CallBase *Call,
diff --git a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
index 5a50e0afae2cf..529f3a76d23e5 100644
--- a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
@@ -373,13 +373,13 @@ static bool isStructPathTBAA(const MDNode *MD) {
AliasResult TypeBasedAAResult::alias(const MemoryLocation &LocA,
const MemoryLocation &LocB,
- AAQueryInfo &AAQI) {
+ AAQueryInfo &AAQI, const Instruction *) {
if (!EnableTBAA)
- return AAResultBase::alias(LocA, LocB, AAQI);
+ return AAResultBase::alias(LocA, LocB, AAQI, nullptr);
// If accesses may alias, chain to the next AliasAnalysis.
if (Aliases(LocA.AATags.TBAA, LocB.AATags.TBAA))
- return AAResultBase::alias(LocA, LocB, AAQI);
+ return AAResultBase::alias(LocA, LocB, AAQI, nullptr);
// Otherwise return a definitive result.
return AliasResult::NoAlias;
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
index e97c993f4b25a..8155c895e3669 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
@@ -73,8 +73,8 @@ static AliasResult getAliasResult(unsigned AS1, unsigned AS2) {
}
AliasResult AMDGPUAAResult::alias(const MemoryLocation &LocA,
- const MemoryLocation &LocB,
- AAQueryInfo &AAQI) {
+ const MemoryLocation &LocB, AAQueryInfo &AAQI,
+ const Instruction *) {
unsigned asA = LocA.Ptr->getType()->getPointerAddressSpace();
unsigned asB = LocB.Ptr->getType()->getPointerAddressSpace();
@@ -121,7 +121,7 @@ AliasResult AMDGPUAAResult::alias(const MemoryLocation &LocA,
}
// Forward the query to the next alias analysis.
- return AAResultBase::alias(LocA, LocB, AAQI);
+ return AAResultBase::alias(LocA, LocB, AAQI, nullptr);
}
ModRefInfo AMDGPUAAResult::getModRefInfoMask(const MemoryLocation &Loc,
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.h b/llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.h
index acd437e8987ce..8ce7000222fa0 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.h
@@ -37,7 +37,7 @@ class AMDGPUAAResult : public AAResultBase {
}
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
- AAQueryInfo &AAQI);
+ AAQueryInfo &AAQI, const Instruction *CtxI);
ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI,
bool IgnoreLocals);
};
diff --git a/llvm/unittests/Analysis/AliasAnalysisTest.cpp b/llvm/unittests/Analysis/AliasAnalysisTest.cpp
index 96569fe07019c..7ad2cf67f1310 100644
--- a/llvm/unittests/Analysis/AliasAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/AliasAnalysisTest.cpp
@@ -85,7 +85,7 @@ struct TestCustomAAResult : AAResultBase {
bool invalidate(Function &, const PreservedAnalyses &) { return false; }
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
- AAQueryInfo &AAQI) {
+ AAQueryInfo &AAQI, const Instruction *) {
CB();
return AliasResult::MayAlias;
}
diff --git a/llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp b/llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
index d2ffff15fdd14..a84d65eb781af 100644
--- a/llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
@@ -96,12 +96,14 @@ TEST_F(BasicAATest, AliasInstWithObjectOfImpreciseSize) {
AAQueryInfo &AAQI = AllAnalyses.AAQI;
ASSERT_EQ(
BasicAA.alias(MemoryLocation(IncomingI32Ptr, LocationSize::precise(4)),
- MemoryLocation(GlobalPtr, LocationSize::precise(1)), AAQI),
+ MemoryLocation(GlobalPtr, LocationSize::precise(1)), AAQI,
+ nullptr),
AliasResult::NoAlias);
ASSERT_EQ(
BasicAA.alias(MemoryLocation(IncomingI32Ptr, LocationSize::upperBound(4)),
- MemoryLocation(GlobalPtr, LocationSize::precise(1)), AAQI),
+ MemoryLocation(GlobalPtr, LocationSize::precise(1)), AAQI,
+ nullptr),
AliasResult::MayAlias);
}
@@ -126,13 +128,13 @@ TEST_F(BasicAATest, AliasInstWithFullObjectOfImpreciseSize) {
ASSERT_EQ(BasicAA.alias(
MemoryLocation(I8, LocationSize::precise(2)),
MemoryLocation(I8AtUncertainOffset, LocationSize::precise(1)),
- AAQI),
+ AAQI, nullptr),
AliasResult::PartialAlias);
ASSERT_EQ(BasicAA.alias(
MemoryLocation(I8, LocationSize::upperBound(2)),
MemoryLocation(I8AtUncertainOffset, LocationSize::precise(1)),
- AAQI),
+ AAQI, nullptr),
AliasResult::MayAlias);
}
@@ -171,9 +173,9 @@ TEST_F(BasicAATest, PartialAliasOffsetPhi) {
auto &AllAnalyses = setupAnalyses();
BasicAAResult &BasicAA = AllAnalyses.BAA;
AAQueryInfo &AAQI = AllAnalyses.AAQI;
- AliasResult AR =
- BasicAA.alias(MemoryLocation(Ptr, LocationSize::precise(2)),
- MemoryLocation(Phi, LocationSize::precise(1)), AAQI);
+ AliasResult AR = BasicAA.alias(MemoryLocation(Ptr, LocationSize::precise(2)),
+ MemoryLocation(Phi, LocationSize::precise(1)),
+ AAQI, nullptr);
ASSERT_EQ(AR.getOffset(), 1);
}
@@ -198,8 +200,8 @@ TEST_F(BasicAATest, PartialAliasOffsetSelect) {
auto &AllAnalyses = setupAnalyses();
BasicAAResult &BasicAA = AllAnalyses.BAA;
AAQueryInfo &AAQI = AllAnalyses.AAQI;
- AliasResult AR =
- BasicAA.alias(MemoryLocation(Ptr, LocationSize::precise(2)),
- MemoryLocation(Select, LocationSize::precise(1)), AAQI);
+ AliasResult AR = BasicAA.alias(
+ MemoryLocation(Ptr, LocationSize::precise(2)),
+ MemoryLocation(Select, LocationSize::precise(1)), AAQI, nullptr);
ASSERT_EQ(AR.getOffset(), 1);
}
More information about the llvm-commits
mailing list