Consistently use LoopAnalysisManager

One exception here is LoopInfo which must forward-declare it (because
the typedef is in LoopPassManager.h which depends on LoopInfo).

Also, some includes for LoopPassManager.h were needed since that file
provides the typedef.

Besides a general consistently benefit, the extra layer of indirection
allows the mechanical part of https://reviews.llvm.org/D23256 that
requires touching every transformation and analysis to be factored out
cleanly.

Thanks to David for the suggestion.

llvm-svn: 278079
This commit is contained in:
Sean Silva 2016-08-09 00:28:52 +00:00
parent beb273cb73
commit 8e46796ab9
25 changed files with 43 additions and 32 deletions

View File

@ -16,6 +16,7 @@
#define LLVM_ANALYSIS_IVUSERS_H
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/Analysis/ScalarEvolutionNormalization.h"
#include "llvm/IR/ValueHandle.h"
@ -208,7 +209,7 @@ class IVUsersAnalysis : public AnalysisInfoMixin<IVUsersAnalysis> {
public:
typedef IVUsers Result;
IVUsers run(Loop &L, AnalysisManager<Loop> &AM);
IVUsers run(Loop &L, LoopAnalysisManager &AM);
};
/// Printer pass for the \c IVUsers for a loop.
@ -217,7 +218,7 @@ class IVUsersPrinterPass : public PassInfoMixin<IVUsersPrinterPass> {
public:
explicit IVUsersPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &AM);
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM);
};
}

View File

@ -20,6 +20,7 @@
#include "llvm/ADT/SetVector.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AliasSetTracker.h"
#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Pass.h"
@ -775,7 +776,7 @@ class LoopAccessAnalysis
public:
typedef LoopAccessInfo Result;
Result run(Loop &, AnalysisManager<Loop> &);
Result run(Loop &, LoopAnalysisManager &);
static StringRef name() { return "LoopAccessAnalysis"; }
};
@ -786,7 +787,7 @@ class LoopAccessInfoPrinterPass
public:
explicit LoopAccessInfoPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &AM);
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM);
};
inline Instruction *MemoryDepChecker::Dependence::getSource(

View File

@ -16,13 +16,14 @@
#define LLVM_TRANSFORMS_SCALAR_INDVARSIMPLIFY_H
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/IR/PassManager.h"
namespace llvm {
class IndVarSimplifyPass : public PassInfoMixin<IndVarSimplifyPass> {
public:
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &AM);
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM);
};
}

View File

@ -34,6 +34,7 @@
#define LLVM_TRANSFORMS_SCALAR_LICM_H
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/IR/PassManager.h"
namespace llvm {
@ -41,7 +42,7 @@ namespace llvm {
/// Performs Loop Invariant Code Motion Pass.
class LICMPass : public PassInfoMixin<LICMPass> {
public:
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &AM);
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM);
};
} // end namespace llvm

View File

@ -15,6 +15,7 @@
#define LLVM_TRANSFORMS_SCALAR_LOOPDELETION_H
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/IR/PassManager.h"
@ -23,7 +24,7 @@ namespace llvm {
class LoopDeletionPass : public PassInfoMixin<LoopDeletionPass> {
public:
LoopDeletionPass() {}
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &AM);
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM);
bool runImpl(Loop *L, DominatorTree &DT, ScalarEvolution &SE,
LoopInfo &loopInfo);

View File

@ -17,6 +17,7 @@
#define LLVM_TRANSFORMS_SCALAR_LOOPIDIOMRECOGNIZE_H
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/IR/PassManager.h"
namespace llvm {
@ -24,7 +25,7 @@ namespace llvm {
/// Performs Loop Idiom Recognize Pass.
class LoopIdiomRecognizePass : public PassInfoMixin<LoopIdiomRecognizePass> {
public:
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &AM);
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM);
};
} // end namespace llvm

View File

@ -15,6 +15,7 @@
#define LLVM_TRANSFORMS_SCALAR_LOOPINSTSIMPLIFY_H
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/IR/PassManager.h"
namespace llvm {
@ -22,7 +23,7 @@ namespace llvm {
/// Performs Loop Inst Simplify Pass.
class LoopInstSimplifyPass : public PassInfoMixin<LoopInstSimplifyPass> {
public:
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &AM);
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM);
};
} // end namespace llvm

View File

@ -15,6 +15,7 @@
#define LLVM_TRANSFORMS_SCALAR_LOOPROTATION_H
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/IR/PassManager.h"
namespace llvm {
@ -23,7 +24,7 @@ namespace llvm {
class LoopRotatePass : public PassInfoMixin<LoopRotatePass> {
public:
LoopRotatePass();
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &AM);
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM);
};
}

View File

@ -18,6 +18,7 @@
#define LLVM_TRANSFORMS_SCALAR_LOOPSIMPLIFYCFG_H
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/IR/PassManager.h"
namespace llvm {
@ -25,7 +26,7 @@ namespace llvm {
/// Performs basic CFG simplifications to assist other loop passes.
class LoopSimplifyCFGPass : public PassInfoMixin<LoopSimplifyCFGPass> {
public:
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &AM);
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM);
};
} // end namespace llvm

View File

@ -23,6 +23,7 @@
#define LLVM_TRANSFORMS_SCALAR_LOOPSTRENGTHREDUCE_H
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/IR/PassManager.h"
namespace llvm {
@ -30,7 +31,7 @@ namespace llvm {
/// Performs Loop Strength Reduce Pass.
class LoopStrengthReducePass : public PassInfoMixin<LoopStrengthReducePass> {
public:
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &AM);
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM);
};
} // end namespace llvm

View File

@ -11,6 +11,7 @@
#define LLVM_TRANSFORMS_SCALAR_LOOPUNROLLPASS_H
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/IR/PassManager.h"
namespace llvm {
@ -21,7 +22,7 @@ struct LoopUnrollPass : public PassInfoMixin<LoopUnrollPass> {
Optional<bool> ProvidedAllowPartial;
Optional<bool> ProvidedRuntime;
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &AM);
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM);
};
} // end namespace llvm

View File

@ -36,7 +36,7 @@ using namespace llvm;
char IVUsersAnalysis::PassID;
IVUsers IVUsersAnalysis::run(Loop &L, AnalysisManager<Loop> &AM) {
IVUsers IVUsersAnalysis::run(Loop &L, LoopAnalysisManager &AM) {
const auto &FAM =
AM.getResult<FunctionAnalysisManagerLoopProxy>(L).getManager();
Function *F = L.getHeader()->getParent();
@ -47,7 +47,7 @@ IVUsers IVUsersAnalysis::run(Loop &L, AnalysisManager<Loop> &AM) {
FAM.getCachedResult<ScalarEvolutionAnalysis>(*F));
}
PreservedAnalyses IVUsersPrinterPass::run(Loop &L, AnalysisManager<Loop> &AM) {
PreservedAnalyses IVUsersPrinterPass::run(Loop &L, LoopAnalysisManager &AM) {
AM.getResult<IVUsersAnalysis>(L).print(OS);
return PreservedAnalyses::all();
}

View File

@ -2030,7 +2030,7 @@ INITIALIZE_PASS_END(LoopAccessLegacyAnalysis, LAA_NAME, laa_name, false, true)
char LoopAccessAnalysis::PassID;
LoopAccessInfo LoopAccessAnalysis::run(Loop &L, AnalysisManager<Loop> &AM) {
LoopAccessInfo LoopAccessAnalysis::run(Loop &L, LoopAnalysisManager &AM) {
const FunctionAnalysisManager &FAM =
AM.getResult<FunctionAnalysisManagerLoopProxy>(L).getManager();
Function &F = *L.getHeader()->getParent();
@ -2052,7 +2052,7 @@ LoopAccessInfo LoopAccessAnalysis::run(Loop &L, AnalysisManager<Loop> &AM) {
}
PreservedAnalyses LoopAccessInfoPrinterPass::run(Loop &L,
AnalysisManager<Loop> &AM) {
LoopAnalysisManager &AM) {
Function &F = *L.getHeader()->getParent();
auto &LAI = AM.getResult<LoopAccessAnalysis>(L);
OS << "Loop access info in function '" << F.getName() << "':\n";

View File

@ -48,7 +48,7 @@ public:
[](BasicBlock *BB) { return BB; });
if (BBI != L->blocks().end() &&
isFunctionInPrintList((*BBI)->getParent()->getName())) {
AnalysisManager<Loop> DummyLAM;
LoopAnalysisManager DummyLAM;
P.run(*L, DummyLAM);
}
return false;

View File

@ -195,7 +195,7 @@ public:
/// \brief No-op loop pass which does nothing.
struct NoOpLoopPass {
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &) {
PreservedAnalyses run(Loop &L, LoopAnalysisManager &) {
return PreservedAnalyses::all();
}
static StringRef name() { return "NoOpLoopPass"; }
@ -208,7 +208,7 @@ class NoOpLoopAnalysis : public AnalysisInfoMixin<NoOpLoopAnalysis> {
public:
struct Result {};
Result run(Loop &, AnalysisManager<Loop> &) { return Result(); }
Result run(Loop &, LoopAnalysisManager &) { return Result(); }
static StringRef name() { return "NoOpLoopAnalysis"; }
};

View File

@ -2213,7 +2213,7 @@ bool IndVarSimplify::run(Loop *L) {
return Changed;
}
PreservedAnalyses IndVarSimplifyPass::run(Loop &L, AnalysisManager<Loop> &AM) {
PreservedAnalyses IndVarSimplifyPass::run(Loop &L, LoopAnalysisManager &AM) {
auto &FAM = AM.getResult<FunctionAnalysisManagerLoopProxy>(L).getManager();
Function *F = L.getHeader()->getParent();
const DataLayout &DL = F->getParent()->getDataLayout();

View File

@ -173,7 +173,7 @@ private:
};
}
PreservedAnalyses LICMPass::run(Loop &L, AnalysisManager<Loop> &AM) {
PreservedAnalyses LICMPass::run(Loop &L, LoopAnalysisManager &AM) {
const auto &FAM =
AM.getResult<FunctionAnalysisManagerLoopProxy>(L).getManager();
Function *F = L.getHeader()->getParent();

View File

@ -215,7 +215,7 @@ bool LoopDeletionPass::runImpl(Loop *L, DominatorTree &DT, ScalarEvolution &SE,
return Changed;
}
PreservedAnalyses LoopDeletionPass::run(Loop &L, AnalysisManager<Loop> &AM) {
PreservedAnalyses LoopDeletionPass::run(Loop &L, LoopAnalysisManager &AM) {
auto &FAM = AM.getResult<FunctionAnalysisManagerLoopProxy>(L).getManager();
Function *F = L.getHeader()->getParent();

View File

@ -172,7 +172,7 @@ public:
} // End anonymous namespace.
PreservedAnalyses LoopIdiomRecognizePass::run(Loop &L,
AnalysisManager<Loop> &AM) {
LoopAnalysisManager &AM) {
const auto &FAM =
AM.getResult<FunctionAnalysisManagerLoopProxy>(L).getManager();
Function *F = L.getHeader()->getParent();

View File

@ -184,7 +184,7 @@ public:
}
PreservedAnalyses LoopInstSimplifyPass::run(Loop &L,
AnalysisManager<Loop> &AM) {
LoopAnalysisManager &AM) {
const auto &FAM =
AM.getResult<FunctionAnalysisManagerLoopProxy>(L).getManager();
Function *F = L.getHeader()->getParent();

View File

@ -619,7 +619,7 @@ bool LoopRotate::processLoop(Loop *L) {
LoopRotatePass::LoopRotatePass() {}
PreservedAnalyses LoopRotatePass::run(Loop &L, AnalysisManager<Loop> &AM) {
PreservedAnalyses LoopRotatePass::run(Loop &L, LoopAnalysisManager &AM) {
auto &FAM = AM.getResult<FunctionAnalysisManagerLoopProxy>(L).getManager();
Function *F = L.getHeader()->getParent();

View File

@ -64,7 +64,7 @@ static bool simplifyLoopCFG(Loop &L, DominatorTree &DT, LoopInfo &LI) {
return Changed;
}
PreservedAnalyses LoopSimplifyCFGPass::run(Loop &L, AnalysisManager<Loop> &AM) {
PreservedAnalyses LoopSimplifyCFGPass::run(Loop &L, LoopAnalysisManager &AM) {
const auto &FAM =
AM.getResult<FunctionAnalysisManagerLoopProxy>(L).getManager();
Function *F = L.getHeader()->getParent();

View File

@ -5023,7 +5023,7 @@ bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager & /*LPM*/) {
}
PreservedAnalyses LoopStrengthReducePass::run(Loop &L,
AnalysisManager<Loop> &AM) {
LoopAnalysisManager &AM) {
const auto &FAM =
AM.getResult<FunctionAnalysisManagerLoopProxy>(L).getManager();
Function *F = L.getHeader()->getParent();

View File

@ -1058,7 +1058,7 @@ Pass *llvm::createSimpleLoopUnrollPass() {
return llvm::createLoopUnrollPass(-1, -1, 0, 0);
}
PreservedAnalyses LoopUnrollPass::run(Loop &L, AnalysisManager<Loop> &AM) {
PreservedAnalyses LoopUnrollPass::run(Loop &L, LoopAnalysisManager &AM) {
const auto &FAM =
AM.getResult<FunctionAnalysisManagerLoopProxy>(L).getManager();
Function *F = L.getHeader()->getParent();

View File

@ -42,7 +42,7 @@ public:
TestLoopAnalysis(int &Runs) : Runs(Runs) {}
/// \brief Run the analysis pass over the loop and return a result.
Result run(Loop &L, AnalysisManager<Loop> &AM) {
Result run(Loop &L, LoopAnalysisManager &AM) {
++Runs;
int Count = 0;
@ -65,7 +65,7 @@ public:
: VisitedLoops(VisitedLoops), AnalyzedBlockCount(AnalyzedBlockCount),
OnlyUseCachedResults(OnlyUseCachedResults) {}
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &AM) {
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM) {
VisitedLoops.push_back(L.getName());
if (OnlyUseCachedResults) {
@ -91,7 +91,7 @@ class TestLoopInvalidatingPass {
public:
TestLoopInvalidatingPass(StringRef LoopName) : Name(LoopName) {}
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &AM) {
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM) {
return L.getName() == Name ? getLoopPassPreservedAnalyses()
: PreservedAnalyses::all();
}