[LAA] Use LoopAccessInfoManager in legacy pass.
Simplify LoopAccessLegacyAnalysis by using LoopAccessInfoManager from D134606. As a side-effect this also removes printing support from LoopAccessLegacyAnalysis. Depends on D134606. Reviewed By: aeubanks Differential Revision: https://reviews.llvm.org/D134608
This commit is contained in:
parent
1303abe658
commit
db720dc17c
|
@ -781,6 +781,8 @@ public:
|
||||||
: SE(SE), AA(AA), DT(DT), LI(LI), TLI(TLI) {}
|
: SE(SE), AA(AA), DT(DT), LI(LI), TLI(TLI) {}
|
||||||
|
|
||||||
const LoopAccessInfo &getInfo(Loop &L);
|
const LoopAccessInfo &getInfo(Loop &L);
|
||||||
|
|
||||||
|
void clear() { LoopAccessInfoMap.clear(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This analysis provides dependence information for the memory accesses
|
/// This analysis provides dependence information for the memory accesses
|
||||||
|
@ -803,26 +805,15 @@ public:
|
||||||
/// Query the result of the loop access information for the loop \p L.
|
/// Query the result of the loop access information for the loop \p L.
|
||||||
///
|
///
|
||||||
/// If there is no cached result available run the analysis.
|
/// 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 {
|
void releaseMemory() override {
|
||||||
// Invalidate the cache when the pass is freed.
|
// 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:
|
private:
|
||||||
/// The cache.
|
std::unique_ptr<LoopAccessInfoManager> LAIs;
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This analysis provides dependence information for the memory
|
/// This analysis provides dependence information for the memory
|
||||||
|
|
|
@ -2683,34 +2683,14 @@ LoopAccessLegacyAnalysis::LoopAccessLegacyAnalysis() : FunctionPass(ID) {
|
||||||
initializeLoopAccessLegacyAnalysisPass(*PassRegistry::getPassRegistry());
|
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) {
|
bool LoopAccessLegacyAnalysis::runOnFunction(Function &F) {
|
||||||
SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
|
auto &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
|
||||||
auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
|
auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
|
||||||
TLI = TLIP ? &TLIP->getTLI(F) : nullptr;
|
auto *TLI = TLIP ? &TLIP->getTLI(F) : nullptr;
|
||||||
AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
|
auto &AA = getAnalysis<AAResultsWrapperPass>().getAAResults();
|
||||||
DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
|
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
|
||||||
LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
|
auto &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
|
||||||
|
LAIs = std::make_unique<LoopAccessInfoManager>(SE, AA, DT, LI, TLI);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue