diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2021-01-09 18:09:20 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2022-10-06 10:10:19 +0200 |
commit | c5bf452022a50002d9f2d5310e8eb33515e86166 (patch) | |
tree | 6587fa47757a21eead7fbccbc5812a702ec77ddf /llvm/lib/Analysis/AliasAnalysis.cpp | |
parent | d1f13c54f172875d9a14c46c09afb1f22d78cdf8 (diff) | |
download | llvm-c5bf452022a50002d9f2d5310e8eb33515e86166.zip llvm-c5bf452022a50002d9f2d5310e8eb33515e86166.tar.gz llvm-c5bf452022a50002d9f2d5310e8eb33515e86166.tar.bz2 |
[AA] Pass AAResults through AAQueryInfo
Currently, AAResultBase (from which alias analysis providers inherit)
stores a reference back to the AAResults aggregation it is part of,
so it can perform recursive alias analysis queries via
getBestAAResults().
This patch removes the back-reference from AAResultBase to AAResults,
and instead passes the used aggregation through the AAQueryInfo.
This can be used to perform recursive AA queries using the full
aggregation.
Differential Revision: https://reviews.llvm.org/D94363
Diffstat (limited to 'llvm/lib/Analysis/AliasAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/AliasAnalysis.cpp | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp index 5f477ed..c21cf86 100644 --- a/llvm/lib/Analysis/AliasAnalysis.cpp +++ b/llvm/lib/Analysis/AliasAnalysis.cpp @@ -76,21 +76,9 @@ static const bool EnableAATrace = false; #endif AAResults::AAResults(AAResults &&Arg) - : TLI(Arg.TLI), AAs(std::move(Arg.AAs)), AADeps(std::move(Arg.AADeps)) { - for (auto &AA : AAs) - AA->setAAResults(this); -} + : TLI(Arg.TLI), AAs(std::move(Arg.AAs)), AADeps(std::move(Arg.AADeps)) {} -AAResults::~AAResults() { -// FIXME; It would be nice to at least clear out the pointers back to this -// aggregation here, but we end up with non-nesting lifetimes in the legacy -// pass manager that prevent this from working. In the legacy pass manager -// we'll end up with dangling references here in some cases. -#if 0 - for (auto &AA : AAs) - AA->setAAResults(nullptr); -#endif -} +AAResults::~AAResults() {} bool AAResults::invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv) { @@ -118,7 +106,7 @@ bool AAResults::invalidate(Function &F, const PreservedAnalyses &PA, AliasResult AAResults::alias(const MemoryLocation &LocA, const MemoryLocation &LocB) { - SimpleAAQueryInfo AAQIP; + SimpleAAQueryInfo AAQIP(*this); return alias(LocA, LocB, AAQIP); } @@ -161,7 +149,7 @@ AliasResult AAResults::alias(const MemoryLocation &LocA, bool AAResults::pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) { - SimpleAAQueryInfo AAQIP; + SimpleAAQueryInfo AAQIP(*this); return pointsToConstantMemory(Loc, AAQIP, OrLocal); } @@ -189,7 +177,7 @@ ModRefInfo AAResults::getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) { } ModRefInfo AAResults::getModRefInfo(Instruction *I, const CallBase *Call2) { - SimpleAAQueryInfo AAQIP; + SimpleAAQueryInfo AAQIP(*this); return getModRefInfo(I, Call2, AAQIP); } @@ -216,7 +204,7 @@ ModRefInfo AAResults::getModRefInfo(Instruction *I, const CallBase *Call2, ModRefInfo AAResults::getModRefInfo(const CallBase *Call, const MemoryLocation &Loc) { - SimpleAAQueryInfo AAQIP; + SimpleAAQueryInfo AAQIP(*this); return getModRefInfo(Call, Loc, AAQIP); } @@ -276,7 +264,7 @@ ModRefInfo AAResults::getModRefInfo(const CallBase *Call, ModRefInfo AAResults::getModRefInfo(const CallBase *Call1, const CallBase *Call2) { - SimpleAAQueryInfo AAQIP; + SimpleAAQueryInfo AAQIP(*this); return getModRefInfo(Call1, Call2, AAQIP); } @@ -403,7 +391,7 @@ FunctionModRefBehavior AAResults::getModRefBehavior(const CallBase *Call, } FunctionModRefBehavior AAResults::getModRefBehavior(const CallBase *Call) { - SimpleAAQueryInfo AAQI; + SimpleAAQueryInfo AAQI(*this); return getModRefBehavior(Call, AAQI); } @@ -484,7 +472,7 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, FunctionModRefBehavior FMRB) { ModRefInfo AAResults::getModRefInfo(const LoadInst *L, const MemoryLocation &Loc) { - SimpleAAQueryInfo AAQIP; + SimpleAAQueryInfo AAQIP(*this); return getModRefInfo(L, Loc, AAQIP); } ModRefInfo AAResults::getModRefInfo(const LoadInst *L, @@ -507,7 +495,7 @@ ModRefInfo AAResults::getModRefInfo(const LoadInst *L, ModRefInfo AAResults::getModRefInfo(const StoreInst *S, const MemoryLocation &Loc) { - SimpleAAQueryInfo AAQIP; + SimpleAAQueryInfo AAQIP(*this); return getModRefInfo(S, Loc, AAQIP); } ModRefInfo AAResults::getModRefInfo(const StoreInst *S, @@ -534,8 +522,9 @@ ModRefInfo AAResults::getModRefInfo(const StoreInst *S, return ModRefInfo::Mod; } -ModRefInfo AAResults::getModRefInfo(const FenceInst *S, const MemoryLocation &Loc) { - SimpleAAQueryInfo AAQIP; +ModRefInfo AAResults::getModRefInfo(const FenceInst *S, + const MemoryLocation &Loc) { + SimpleAAQueryInfo AAQIP(*this); return getModRefInfo(S, Loc, AAQIP); } @@ -551,7 +540,7 @@ ModRefInfo AAResults::getModRefInfo(const FenceInst *S, ModRefInfo AAResults::getModRefInfo(const VAArgInst *V, const MemoryLocation &Loc) { - SimpleAAQueryInfo AAQIP; + SimpleAAQueryInfo AAQIP(*this); return getModRefInfo(V, Loc, AAQIP); } @@ -577,7 +566,7 @@ ModRefInfo AAResults::getModRefInfo(const VAArgInst *V, ModRefInfo AAResults::getModRefInfo(const CatchPadInst *CatchPad, const MemoryLocation &Loc) { - SimpleAAQueryInfo AAQIP; + SimpleAAQueryInfo AAQIP(*this); return getModRefInfo(CatchPad, Loc, AAQIP); } @@ -597,7 +586,7 @@ ModRefInfo AAResults::getModRefInfo(const CatchPadInst *CatchPad, ModRefInfo AAResults::getModRefInfo(const CatchReturnInst *CatchRet, const MemoryLocation &Loc) { - SimpleAAQueryInfo AAQIP; + SimpleAAQueryInfo AAQIP(*this); return getModRefInfo(CatchRet, Loc, AAQIP); } @@ -617,7 +606,7 @@ ModRefInfo AAResults::getModRefInfo(const CatchReturnInst *CatchRet, ModRefInfo AAResults::getModRefInfo(const AtomicCmpXchgInst *CX, const MemoryLocation &Loc) { - SimpleAAQueryInfo AAQIP; + SimpleAAQueryInfo AAQIP(*this); return getModRefInfo(CX, Loc, AAQIP); } @@ -641,7 +630,7 @@ ModRefInfo AAResults::getModRefInfo(const AtomicCmpXchgInst *CX, ModRefInfo AAResults::getModRefInfo(const AtomicRMWInst *RMW, const MemoryLocation &Loc) { - SimpleAAQueryInfo AAQIP; + SimpleAAQueryInfo AAQIP(*this); return getModRefInfo(RMW, Loc, AAQIP); } |