[PATCH] D134608: [LAA] Use LoopAccessInfoManager in legacy pass.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 4 00:43:59 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb720dc17ca4: [LAA] Use LoopAccessInfoManager in legacy pass. (authored by fhahn).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134608/new/
https://reviews.llvm.org/D134608
Files:
llvm/include/llvm/Analysis/LoopAccessAnalysis.h
llvm/lib/Analysis/LoopAccessAnalysis.cpp
Index: llvm/lib/Analysis/LoopAccessAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -2683,34 +2683,14 @@
initializeLoopAccessLegacyAnalysisPass(*PassRegistry::getPassRegistry());
}
-const LoopAccessInfo &LoopAccessLegacyAnalysis::getInfo(Loop *L) {
- auto &LAI = LoopAccessInfoMap[L];
-
- if (!LAI)
- LAI = std::make_unique<LoopAccessInfo>(L, SE, TLI, AA, DT, LI);
-
- return *LAI;
-}
-
-void LoopAccessLegacyAnalysis::print(raw_ostream &OS, const Module *M) const {
- LoopAccessLegacyAnalysis &LAA = *const_cast<LoopAccessLegacyAnalysis *>(this);
-
- for (Loop *TopLevelLoop : *LI)
- for (Loop *L : depth_first(TopLevelLoop)) {
- OS.indent(2) << L->getHeader()->getName() << ":\n";
- auto &LAI = LAA.getInfo(L);
- LAI.print(OS, 4);
- }
-}
-
bool LoopAccessLegacyAnalysis::runOnFunction(Function &F) {
- SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
+ auto &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
- TLI = TLIP ? &TLIP->getTLI(F) : nullptr;
- AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
- DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
- LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
-
+ auto *TLI = TLIP ? &TLIP->getTLI(F) : nullptr;
+ auto &AA = getAnalysis<AAResultsWrapperPass>().getAAResults();
+ auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
+ auto &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
+ LAIs = std::make_unique<LoopAccessInfoManager>(SE, AA, DT, LI, TLI);
return false;
}
Index: llvm/include/llvm/Analysis/LoopAccessAnalysis.h
===================================================================
--- llvm/include/llvm/Analysis/LoopAccessAnalysis.h
+++ llvm/include/llvm/Analysis/LoopAccessAnalysis.h
@@ -781,6 +781,8 @@
: SE(SE), AA(AA), DT(DT), LI(LI), TLI(TLI) {}
const LoopAccessInfo &getInfo(Loop &L);
+
+ void clear() { LoopAccessInfoMap.clear(); }
};
/// This analysis provides dependence information for the memory accesses
@@ -803,26 +805,15 @@
/// Query the result of the loop access information for the loop \p L.
///
/// If there is no cached result available run the analysis.
- const LoopAccessInfo &getInfo(Loop *L);
+ const LoopAccessInfo &getInfo(Loop *L) { return LAIs->getInfo(*L); }
void releaseMemory() override {
// Invalidate the cache when the pass is freed.
- LoopAccessInfoMap.clear();
+ LAIs->clear();
}
- /// Print the result of the analysis when invoked with -analyze.
- void print(raw_ostream &OS, const Module *M = nullptr) const override;
-
private:
- /// The cache.
- DenseMap<Loop *, std::unique_ptr<LoopAccessInfo>> LoopAccessInfoMap;
-
- // The used analysis passes.
- ScalarEvolution *SE = nullptr;
- const TargetLibraryInfo *TLI = nullptr;
- AAResults *AA = nullptr;
- DominatorTree *DT = nullptr;
- LoopInfo *LI = nullptr;
+ std::unique_ptr<LoopAccessInfoManager> LAIs;
};
/// This analysis provides dependence information for the memory
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134608.464903.patch
Type: text/x-patch
Size: 3199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221004/e3e9f997/attachment.bin>
More information about the llvm-commits
mailing list