diff options
author | David Goldblatt <davidgoldblatt@fb.com> | 2022-12-15 19:33:10 -0800 |
---|---|---|
committer | Wenlei He <aktoon@gmail.com> | 2022-12-15 21:04:38 -0800 |
commit | 02988fce76d8a95e2bc33e80b581c3b0b2c92755 (patch) | |
tree | 8e49de3c5b99f557ae3f6e27ecc8421f053c2673 /llvm/lib/Analysis/AliasAnalysis.cpp | |
parent | b6772e6e2045ab491b41d3767f788250800f97ea (diff) | |
download | llvm-02988fce76d8a95e2bc33e80b581c3b0b2c92755.zip llvm-02988fce76d8a95e2bc33e80b581c3b0b2c92755.tar.gz llvm-02988fce76d8a95e2bc33e80b581c3b0b2c92755.tar.bz2 |
[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
Diffstat (limited to 'llvm/lib/Analysis/AliasAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/AliasAnalysis.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp index 73de6fa..9e24f6b 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 |