[PM] Remove support for omitting the AnalysisManager argument to new

pass manager passes' `run` methods.

This removes a bunch of SFINAE goop from the pass manager and just
requires pass authors to accept `AnalysisManager<IRUnitT> &` as a dead
argument. This is a small price to pay for the simplicity of the system
as a whole, despite the noise that changing it causes at this stage.

This will also helpfull allow us to make the signature of the run
methods much more flexible for different kinds af passes to support
things like intelligently updating the pass's progression over IR units.

While this touches many, many, files, the changes are really boring.
Mostly made with the help of my trusty perl one liners.

Thanks to Sean and Hal for bouncing ideas for this with me in IRC.

llvm-svn: 272978
This commit is contained in:
Chandler Carruth 2016-06-17 00:11:01 +00:00
parent 5078f94690
commit 164a2aa6f4
49 changed files with 122 additions and 180 deletions

View File

@ -106,7 +106,9 @@ public:
AssumptionAnalysis &operator=(const AssumptionAnalysis &RHS) { return *this; }
AssumptionAnalysis &operator=(AssumptionAnalysis &&RHS) { return *this; }
AssumptionCache run(Function &F) { return AssumptionCache(F); }
AssumptionCache run(Function &F, FunctionAnalysisManager &) {
return AssumptionCache(F);
}
};
/// \brief Printer pass for the \c AssumptionAnalysis results.

View File

@ -306,7 +306,7 @@ public:
/// \brief Compute the \c CallGraph for the module \c M.
///
/// The real work here is done in the \c CallGraph constructor.
CallGraph run(Module &M) { return CallGraph(M); }
CallGraph run(Module &M, ModuleAnalysisManager &) { return CallGraph(M); }
};
/// \brief Printer pass for the \c CallGraphAnalysis results.

View File

@ -907,7 +907,9 @@ public:
///
/// This just builds the set of entry points to the call graph. The rest is
/// built lazily as it is walked.
LazyCallGraph run(Module &M) { return LazyCallGraph(M); }
LazyCallGraph run(Module &M, ModuleAnalysisManager &) {
return LazyCallGraph(M);
}
};
/// A pass which prints the call graph to a \c raw_ostream.

View File

@ -826,7 +826,7 @@ public:
PrintLoopPass();
PrintLoopPass(raw_ostream &OS, const std::string &Banner = "");
PreservedAnalyses run(Loop &L);
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &);
};
} // End llvm namespace

View File

@ -48,7 +48,7 @@ public:
/// \brief Run the analysis pass over a function and produce a post dominator
/// tree.
PostDominatorTree run(Function &F);
PostDominatorTree run(Function &F, FunctionAnalysisManager &);
};
/// \brief Printer pass for the \c PostDominatorTree.

View File

@ -91,7 +91,7 @@ public:
return *this;
}
Result run(Module &M);
Result run(Module &M, ModuleAnalysisManager &);
private:
friend AnalysisInfoMixin<ProfileSummaryAnalysis>;

View File

@ -304,8 +304,8 @@ public:
return *this;
}
TargetLibraryInfo run(Module &M);
TargetLibraryInfo run(Function &F);
TargetLibraryInfo run(Module &M, ModuleAnalysisManager &);
TargetLibraryInfo run(Function &F, FunctionAnalysisManager &);
private:
friend AnalysisInfoMixin<TargetLibraryAnalysis>;

View File

@ -995,7 +995,7 @@ public:
return *this;
}
Result run(const Function &F);
Result run(const Function &F, AnalysisManager<Function> &);
private:
friend AnalysisInfoMixin<TargetIRAnalysis>;

View File

@ -16,12 +16,12 @@
#define LLVM_BITCODE_BITCODEWRITERPASS_H
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/PassManager.h"
namespace llvm {
class Module;
class ModulePass;
class raw_ostream;
class PreservedAnalyses;
/// \brief Create and return a pass that writes the module to the specified
/// ostream. Note that this pass is designed for use with the legacy pass
@ -67,7 +67,7 @@ public:
/// \brief Run the bitcode writer pass, and output the module to the selected
/// output stream.
PreservedAnalyses run(Module &M);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
static StringRef name() { return "BitcodeWriterPass"; }
};

View File

@ -187,7 +187,7 @@ public:
typedef DominatorTree Result;
/// \brief Run the analysis pass over a function and produce a dominator tree.
DominatorTree run(Function &F);
DominatorTree run(Function &F, AnalysisManager<Function> &);
};
/// \brief Printer pass for the \c DominatorTree.

View File

@ -30,6 +30,7 @@ class Module;
class ModulePass;
class PreservedAnalyses;
class raw_ostream;
template <typename IRUnitT> class AnalysisManager;
/// \brief Create and return a pass that writes the module to the specified
/// \c raw_ostream.
@ -67,7 +68,7 @@ public:
PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
bool ShouldPreserveUseListOrder = false);
PreservedAnalyses run(Module &M);
PreservedAnalyses run(Module &M, AnalysisManager<Module> &);
static StringRef name() { return "PrintModulePass"; }
};
@ -84,7 +85,7 @@ public:
PrintFunctionPass();
PrintFunctionPass(raw_ostream &OS, const std::string &Banner = "");
PreservedAnalyses run(Function &F);
PreservedAnalyses run(Function &F, AnalysisManager<Function> &);
static StringRef name() { return "PrintFunctionPass"; }
};

View File

@ -750,7 +750,7 @@ public:
/// In debug builds, it will also assert that the analysis manager is empty
/// as no queries should arrive at the function analysis manager prior to
/// this analysis being requested.
Result run(IRUnitT &IR) { return Result(*AM); }
Result run(IRUnitT &IR, AnalysisManager<IRUnitT> &) { return Result(*AM); }
private:
friend AnalysisInfoMixin<
@ -823,7 +823,7 @@ public:
/// \brief Run the analysis pass and create our proxy result object.
/// Nothing to see here, it just forwards the \c AM reference into the
/// result.
Result run(IRUnitT &) { return Result(*AM); }
Result run(IRUnitT &, AnalysisManager<IRUnitT> &) { return Result(*AM); }
private:
friend AnalysisInfoMixin<
@ -981,7 +981,8 @@ struct InvalidateAnalysisPass
/// analysis passes to be re-run to produce fresh results if any are needed.
struct InvalidateAllAnalysesPass : PassInfoMixin<InvalidateAllAnalysesPass> {
/// \brief Run this pass over some unit of IR.
template <typename IRUnitT> PreservedAnalyses run(IRUnitT &Arg) {
template <typename IRUnitT>
PreservedAnalyses run(IRUnitT &, AnalysisManager<IRUnitT> &) {
return PreservedAnalyses::none();
}
};

View File

@ -46,42 +46,14 @@ template <typename IRUnitT> struct PassConcept {
virtual StringRef name() = 0;
};
/// \brief SFINAE metafunction for computing whether \c PassT has a run method
/// accepting an \c AnalysisManager<IRUnitT>.
template <typename IRUnitT, typename PassT, typename ResultT>
class PassRunAcceptsAnalysisManager {
typedef char SmallType;
struct BigType {
char a, b;
};
template <typename T, ResultT (T::*)(IRUnitT &, AnalysisManager<IRUnitT> &)>
struct Checker;
template <typename T> static SmallType f(Checker<T, &T::run> *);
template <typename T> static BigType f(...);
public:
enum { Value = sizeof(f<PassT>(nullptr)) == sizeof(SmallType) };
};
/// \brief A template wrapper used to implement the polymorphic API.
///
/// Can be instantiated for any object which provides a \c run method accepting
/// an \c IRUnitT. It requires the pass to be a copyable object. When the
/// \c run method also accepts an \c AnalysisManager<IRUnitT>*, we pass it
/// along.
/// an \c IRUnitT& and an \c AnalysisManager<IRUnit>&. It requires the pass to
/// be a copyable object. When the
template <typename IRUnitT, typename PassT,
typename PreservedAnalysesT = PreservedAnalyses,
bool AcceptsAnalysisManager = PassRunAcceptsAnalysisManager<
IRUnitT, PassT, PreservedAnalysesT>::Value>
struct PassModel;
/// \brief Specialization of \c PassModel for passes that accept an analyis
/// manager.
template <typename IRUnitT, typename PassT, typename PreservedAnalysesT>
struct PassModel<IRUnitT, PassT, PreservedAnalysesT, true>
: PassConcept<IRUnitT> {
typename PreservedAnalysesT = PreservedAnalyses>
struct PassModel : PassConcept<IRUnitT> {
explicit PassModel(PassT Pass) : Pass(std::move(Pass)) {}
// We have to explicitly define all the special member functions because MSVC
// refuses to generate them.
@ -103,32 +75,6 @@ struct PassModel<IRUnitT, PassT, PreservedAnalysesT, true>
PassT Pass;
};
/// \brief Specialization of \c PassModel for passes that accept an analyis
/// manager.
template <typename IRUnitT, typename PassT, typename PreservedAnalysesT>
struct PassModel<IRUnitT, PassT, PreservedAnalysesT, false>
: PassConcept<IRUnitT> {
explicit PassModel(PassT Pass) : Pass(std::move(Pass)) {}
// We have to explicitly define all the special member functions because MSVC
// refuses to generate them.
PassModel(const PassModel &Arg) : Pass(Arg.Pass) {}
PassModel(PassModel &&Arg) : Pass(std::move(Arg.Pass)) {}
friend void swap(PassModel &LHS, PassModel &RHS) {
using std::swap;
swap(LHS.Pass, RHS.Pass);
}
PassModel &operator=(PassModel RHS) {
swap(*this, RHS);
return *this;
}
PreservedAnalysesT run(IRUnitT &IR, AnalysisManager<IRUnitT> &) override {
return Pass.run(IR);
}
StringRef name() override { return PassT::name(); }
PassT Pass;
};
/// \brief Abstract concept of an analysis result.
///
/// This concept is parameterized over the IR unit that this result pertains
@ -261,17 +207,10 @@ template <typename IRUnitT> struct AnalysisPassConcept {
/// \brief Wrapper to model the analysis pass concept.
///
/// Can wrap any type which implements a suitable \c run method. The method
/// must accept the IRUnitT as an argument and produce an object which can be
/// wrapped in a \c AnalysisResultModel.
template <typename IRUnitT, typename PassT,
bool AcceptsAnalysisManager = PassRunAcceptsAnalysisManager<
IRUnitT, PassT, typename PassT::Result>::Value>
struct AnalysisPassModel;
/// \brief Specialization of \c AnalysisPassModel which passes an
/// \c AnalysisManager to PassT's run method.
/// must accept an \c IRUnitT& and an \c AnalysisManager<IRUnitT>& as arguments
/// and produce an object which can be wrapped in a \c AnalysisResultModel.
template <typename IRUnitT, typename PassT>
struct AnalysisPassModel<IRUnitT, PassT, true> : AnalysisPassConcept<IRUnitT> {
struct AnalysisPassModel : AnalysisPassConcept<IRUnitT> {
explicit AnalysisPassModel(PassT Pass) : Pass(std::move(Pass)) {}
// We have to explicitly define all the special member functions because MSVC
// refuses to generate them.
@ -306,44 +245,6 @@ struct AnalysisPassModel<IRUnitT, PassT, true> : AnalysisPassConcept<IRUnitT> {
PassT Pass;
};
/// \brief Specialization of \c AnalysisPassModel which does not pass an
/// \c AnalysisManager to PassT's run method.
template <typename IRUnitT, typename PassT>
struct AnalysisPassModel<IRUnitT, PassT, false> : AnalysisPassConcept<IRUnitT> {
explicit AnalysisPassModel(PassT Pass) : Pass(std::move(Pass)) {}
// We have to explicitly define all the special member functions because MSVC
// refuses to generate them.
AnalysisPassModel(const AnalysisPassModel &Arg) : Pass(Arg.Pass) {}
AnalysisPassModel(AnalysisPassModel &&Arg) : Pass(std::move(Arg.Pass)) {}
friend void swap(AnalysisPassModel &LHS, AnalysisPassModel &RHS) {
using std::swap;
swap(LHS.Pass, RHS.Pass);
}
AnalysisPassModel &operator=(AnalysisPassModel RHS) {
swap(*this, RHS);
return *this;
}
// FIXME: Replace PassT::Result with type traits when we use C++11.
typedef AnalysisResultModel<IRUnitT, PassT, typename PassT::Result>
ResultModelT;
/// \brief The model delegates to the \c PassT::run method.
///
/// The return is wrapped in an \c AnalysisResultModel.
std::unique_ptr<AnalysisResultConcept<IRUnitT>>
run(IRUnitT &IR, AnalysisManager<IRUnitT> &) override {
return make_unique<ResultModelT>(Pass.run(IR));
}
/// \brief The model delegates to a static \c PassT::name method.
///
/// The returned string ref must point to constant immutable data!
StringRef name() override { return PassT::name(); }
PassT Pass;
};
} // End namespace detail
}

View File

@ -65,8 +65,8 @@ public:
bool IRBroken, DebugInfoBroken;
};
static void *ID() { return (void *)&PassID; }
Result run(Module &M);
Result run(Function &F);
Result run(Module &M, ModuleAnalysisManager &);
Result run(Function &F, FunctionAnalysisManager &);
};
/// Check a module for errors, but report debug info errors separately.

View File

@ -28,7 +28,7 @@ namespace llvm {
/// A pass that merges duplicate global constants into a single constant.
class ConstantMergePass : public PassInfoMixin<ConstantMergePass> {
public:
PreservedAnalyses run(Module &M);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
};
}

View File

@ -110,7 +110,7 @@ public:
public:
DeadArgumentEliminationPass(bool ShouldHackArguments_ = false)
: ShouldHackArguments(ShouldHackArguments_) {}
PreservedAnalyses run(Module &M);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
private:
Liveness MarkIfNotLive(RetOrArg Use, UseVector &MaybeLiveUses);

View File

@ -24,7 +24,7 @@ namespace llvm {
class EliminateAvailableExternallyPass
: public PassInfoMixin<EliminateAvailableExternallyPass> {
public:
PreservedAnalyses run(Module &M);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
};
}

View File

@ -22,7 +22,7 @@ namespace llvm {
/// Pass which forces specific function attributes into the IR, primarily as
/// a debugging tool.
struct ForceFunctionAttrsPass : PassInfoMixin<ForceFunctionAttrsPass> {
PreservedAnalyses run(Module &M);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
};
/// Create a legacy pass manager instance of a pass to force function attrs.

View File

@ -27,7 +27,7 @@ namespace llvm {
/// Pass to remove unused function declarations.
class GlobalDCEPass : public PassInfoMixin<GlobalDCEPass> {
public:
PreservedAnalyses run(Module &M);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
private:
SmallPtrSet<GlobalValue*, 32> AliveGlobals;

View File

@ -24,7 +24,7 @@ namespace llvm {
/// Pass to remove unused function declarations.
struct StripDeadPrototypesPass : PassInfoMixin<StripDeadPrototypesPass> {
PreservedAnalyses run(Module &M);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
};
}

View File

@ -214,7 +214,7 @@ void setAfterReturnValues(MutableArrayRef<VirtualCallTarget> Targets,
} // end namespace wholeprogramdevirt
struct WholeProgramDevirtPass : public PassInfoMixin<WholeProgramDevirtPass> {
PreservedAnalyses run(Module &M);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
};
} // end namespace llvm

View File

@ -29,7 +29,7 @@ namespace llvm {
/// dead computations that other DCE passes do not catch, particularly involving
/// loop computations.
struct ADCEPass : PassInfoMixin<ADCEPass> {
PreservedAnalyses run(Function &F);
PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
};
}

View File

@ -22,7 +22,7 @@ namespace llvm {
/// A pass that lowers atomic intrinsic into non-atomic intrinsics.
class LowerAtomicPass : public PassInfoMixin<LowerAtomicPass> {
public:
PreservedAnalyses run(Function &F);
PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
};
}

View File

@ -29,7 +29,7 @@ struct LowerExpectIntrinsicPass : PassInfoMixin<LowerExpectIntrinsicPass> {
/// of the probabilities and frequencies of the CFG. After running this pass,
/// no more expect intrinsics remain, allowing the rest of the optimizer to
/// ignore them.
PreservedAnalyses run(Function &F);
PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
};
}

View File

@ -62,7 +62,7 @@ class ReassociatePass : public PassInfoMixin<ReassociatePass> {
bool MadeChange;
public:
PreservedAnalyses run(Function &F);
PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
private:
void BuildRankMap(Function &F, ReversePostOrderTraversal<Function *> &RPOT);

View File

@ -670,7 +670,7 @@ PrintLoopPass::PrintLoopPass() : OS(dbgs()) {}
PrintLoopPass::PrintLoopPass(raw_ostream &OS, const std::string &Banner)
: OS(OS), Banner(Banner) {}
PreservedAnalyses PrintLoopPass::run(Loop &L) {
PreservedAnalyses PrintLoopPass::run(Loop &L, AnalysisManager<Loop> &) {
OS << Banner;
for (auto *Block : L.blocks())
if (Block)

View File

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

View File

@ -46,7 +46,8 @@ FunctionPass* llvm::createPostDomTree() {
char PostDominatorTreeAnalysis::PassID;
PostDominatorTree PostDominatorTreeAnalysis::run(Function &F) {
PostDominatorTree PostDominatorTreeAnalysis::run(Function &F,
FunctionAnalysisManager &) {
PostDominatorTree PDT;
PDT.recalculate(F);
return PDT;

View File

@ -140,7 +140,8 @@ ProfileSummaryInfoWrapperPass::ProfileSummaryInfoWrapperPass()
}
char ProfileSummaryAnalysis::PassID;
ProfileSummaryInfo ProfileSummaryAnalysis::run(Module &M) {
ProfileSummaryInfo ProfileSummaryAnalysis::run(Module &M,
ModuleAnalysisManager &) {
return ProfileSummaryInfo(M);
}

View File

@ -1127,14 +1127,16 @@ StringRef TargetLibraryInfoImpl::getScalarizedFunction(StringRef F,
return I->ScalarFnName;
}
TargetLibraryInfo TargetLibraryAnalysis::run(Module &M) {
TargetLibraryInfo TargetLibraryAnalysis::run(Module &M,
ModuleAnalysisManager &) {
if (PresetInfoImpl)
return TargetLibraryInfo(*PresetInfoImpl);
return TargetLibraryInfo(lookupInfoImpl(Triple(M.getTargetTriple())));
}
TargetLibraryInfo TargetLibraryAnalysis::run(Function &F) {
TargetLibraryInfo TargetLibraryAnalysis::run(Function &F,
FunctionAnalysisManager &) {
if (PresetInfoImpl)
return TargetLibraryInfo(*PresetInfoImpl);

View File

@ -404,7 +404,8 @@ TargetIRAnalysis::TargetIRAnalysis(
std::function<Result(const Function &)> TTICallback)
: TTICallback(std::move(TTICallback)) {}
TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F) {
TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F,
AnalysisManager<Function> &) {
return TTICallback(F);
}
@ -435,7 +436,8 @@ TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass(
}
TargetTransformInfo &TargetTransformInfoWrapperPass::getTTI(const Function &F) {
TTI = TIRA.run(F);
AnalysisManager<Function> DummyFAM;
TTI = TIRA.run(F, DummyFAM);
return *TTI;
}

View File

@ -19,7 +19,7 @@
#include "llvm/Pass.h"
using namespace llvm;
PreservedAnalyses BitcodeWriterPass::run(Module &M) {
PreservedAnalyses BitcodeWriterPass::run(Module &M, ModuleAnalysisManager &) {
std::unique_ptr<ModuleSummaryIndex> Index;
if (EmitSummaryIndex)
Index = ModuleSummaryIndexBuilder(&M).takeIndex();

View File

@ -300,7 +300,8 @@ void DominatorTree::verifyDomTree() const {
//
//===----------------------------------------------------------------------===//
DominatorTree DominatorTreeAnalysis::run(Function &F) {
DominatorTree DominatorTreeAnalysis::run(Function &F,
AnalysisManager<Function> &) {
DominatorTree DT;
DT.recalculate(F);
return DT;

View File

@ -26,7 +26,7 @@ PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
: OS(OS), Banner(Banner),
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
PreservedAnalyses PrintModulePass::run(Module &M) {
PreservedAnalyses PrintModulePass::run(Module &M, AnalysisManager<Module> &) {
OS << Banner;
if (llvm::isFunctionInPrintList("*"))
M.print(OS, nullptr, ShouldPreserveUseListOrder);
@ -42,7 +42,8 @@ PrintFunctionPass::PrintFunctionPass() : OS(dbgs()) {}
PrintFunctionPass::PrintFunctionPass(raw_ostream &OS, const std::string &Banner)
: OS(OS), Banner(Banner) {}
PreservedAnalyses PrintFunctionPass::run(Function &F) {
PreservedAnalyses PrintFunctionPass::run(Function &F,
AnalysisManager<Function> &) {
if (isFunctionInPrintList(F.getName()))
OS << Banner << static_cast<Value &>(F);
return PreservedAnalyses::all();
@ -61,7 +62,8 @@ public:
: ModulePass(ID), P(OS, Banner, ShouldPreserveUseListOrder) {}
bool runOnModule(Module &M) override {
P.run(M);
ModuleAnalysisManager DummyMAM;
P.run(M, DummyMAM);
return false;
}
@ -81,7 +83,8 @@ public:
// This pass just prints a banner followed by the function as it's processed.
bool runOnFunction(Function &F) override {
P.run(F);
FunctionAnalysisManager DummyFAM;
P.run(F, DummyFAM);
return false;
}

View File

@ -4512,13 +4512,15 @@ FunctionPass *llvm::createVerifierPass(bool FatalErrors) {
}
char VerifierAnalysis::PassID;
VerifierAnalysis::Result VerifierAnalysis::run(Module &M) {
VerifierAnalysis::Result VerifierAnalysis::run(Module &M,
ModuleAnalysisManager &) {
Result Res;
Res.IRBroken = llvm::verifyModule(M, &dbgs(), &Res.DebugInfoBroken);
return Res;
}
VerifierAnalysis::Result VerifierAnalysis::run(Function &F) {
VerifierAnalysis::Result VerifierAnalysis::run(Function &F,
FunctionAnalysisManager &) {
return { llvm::verifyFunction(F, &dbgs()), false };
}

View File

@ -105,7 +105,9 @@ namespace {
/// \brief No-op module pass which does nothing.
struct NoOpModulePass {
PreservedAnalyses run(Module &M) { return PreservedAnalyses::all(); }
PreservedAnalyses run(Module &M, AnalysisManager<Module> &) {
return PreservedAnalyses::all();
}
static StringRef name() { return "NoOpModulePass"; }
};
@ -116,13 +118,14 @@ class NoOpModuleAnalysis : public AnalysisInfoMixin<NoOpModuleAnalysis> {
public:
struct Result {};
Result run(Module &) { return Result(); }
Result run(Module &, AnalysisManager<Module> &) { return Result(); }
static StringRef name() { return "NoOpModuleAnalysis"; }
};
/// \brief No-op CGSCC pass which does nothing.
struct NoOpCGSCCPass {
PreservedAnalyses run(LazyCallGraph::SCC &C) {
PreservedAnalyses run(LazyCallGraph::SCC &C,
AnalysisManager<LazyCallGraph::SCC> &) {
return PreservedAnalyses::all();
}
static StringRef name() { return "NoOpCGSCCPass"; }
@ -135,13 +138,17 @@ class NoOpCGSCCAnalysis : public AnalysisInfoMixin<NoOpCGSCCAnalysis> {
public:
struct Result {};
Result run(LazyCallGraph::SCC &) { return Result(); }
Result run(LazyCallGraph::SCC &, AnalysisManager<LazyCallGraph::SCC> &) {
return Result();
}
static StringRef name() { return "NoOpCGSCCAnalysis"; }
};
/// \brief No-op function pass which does nothing.
struct NoOpFunctionPass {
PreservedAnalyses run(Function &F) { return PreservedAnalyses::all(); }
PreservedAnalyses run(Function &F, AnalysisManager<Function> &) {
return PreservedAnalyses::all();
}
static StringRef name() { return "NoOpFunctionPass"; }
};
@ -152,13 +159,15 @@ class NoOpFunctionAnalysis : public AnalysisInfoMixin<NoOpFunctionAnalysis> {
public:
struct Result {};
Result run(Function &) { return Result(); }
Result run(Function &, AnalysisManager<Function> &) { return Result(); }
static StringRef name() { return "NoOpFunctionAnalysis"; }
};
/// \brief No-op loop pass which does nothing.
struct NoOpLoopPass {
PreservedAnalyses run(Loop &L) { return PreservedAnalyses::all(); }
PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &) {
return PreservedAnalyses::all();
}
static StringRef name() { return "NoOpLoopPass"; }
};
@ -169,7 +178,7 @@ class NoOpLoopAnalysis : public AnalysisInfoMixin<NoOpLoopAnalysis> {
public:
struct Result {};
Result run(Loop &) { return Result(); }
Result run(Loop &, AnalysisManager<Loop> &) { return Result(); }
static StringRef name() { return "NoOpLoopAnalysis"; }
};

View File

@ -192,7 +192,7 @@ static bool mergeConstants(Module &M) {
}
}
PreservedAnalyses ConstantMergePass::run(Module &M) {
PreservedAnalyses ConstantMergePass::run(Module &M, ModuleAnalysisManager &) {
if (!mergeConstants(M))
return PreservedAnalyses::all();
return PreservedAnalyses::none();

View File

@ -64,7 +64,8 @@ namespace {
if (skipModule(M))
return false;
DeadArgumentEliminationPass DAEP(ShouldHackArguments());
PreservedAnalyses PA = DAEP.run(M);
ModuleAnalysisManager DummyMAM;
PreservedAnalyses PA = DAEP.run(M, DummyMAM);
return !PA.areAllPreserved();
}
@ -1029,7 +1030,8 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
return true;
}
PreservedAnalyses DeadArgumentEliminationPass::run(Module &M) {
PreservedAnalyses DeadArgumentEliminationPass::run(Module &M,
ModuleAnalysisManager &) {
bool Changed = false;
// First pass: Do a simple check to see if any functions can have their "..."

View File

@ -61,7 +61,8 @@ static bool eliminateAvailableExternally(Module &M) {
return Changed;
}
PreservedAnalyses EliminateAvailableExternallyPass::run(Module &M) {
PreservedAnalyses
EliminateAvailableExternallyPass::run(Module &M, ModuleAnalysisManager &) {
if (!eliminateAvailableExternally(M))
return PreservedAnalyses::all();
return PreservedAnalyses::none();

View File

@ -80,7 +80,8 @@ static void addForcedAttributes(Function &F) {
}
}
PreservedAnalyses ForceFunctionAttrsPass::run(Module &M) {
PreservedAnalyses ForceFunctionAttrsPass::run(Module &M,
ModuleAnalysisManager &) {
if (ForceAttributes.empty())
return PreservedAnalyses::all();

View File

@ -50,7 +50,8 @@ namespace {
if (skipModule(M))
return false;
auto PA = Impl.run(M);
ModuleAnalysisManager DummyMAM;
auto PA = Impl.run(M, DummyMAM);
return !PA.areAllPreserved();
}
@ -77,7 +78,7 @@ static bool isEmptyFunction(Function *F) {
return RI.getReturnValue() == nullptr;
}
PreservedAnalyses GlobalDCEPass::run(Module &M) {
PreservedAnalyses GlobalDCEPass::run(Module &M, ModuleAnalysisManager &) {
bool Changed = false;
// Remove empty functions from the global ctors list.

View File

@ -53,7 +53,8 @@ static bool stripDeadPrototypes(Module &M) {
return MadeChange;
}
PreservedAnalyses StripDeadPrototypesPass::run(Module &M) {
PreservedAnalyses StripDeadPrototypesPass::run(Module &M,
ModuleAnalysisManager &) {
if (stripDeadPrototypes(M))
return PreservedAnalyses::none();
return PreservedAnalyses::all();

View File

@ -280,7 +280,8 @@ ModulePass *llvm::createWholeProgramDevirtPass() {
return new WholeProgramDevirt;
}
PreservedAnalyses WholeProgramDevirtPass::run(Module &M) {
PreservedAnalyses WholeProgramDevirtPass::run(Module &M,
ModuleAnalysisManager &) {
if (!DevirtModule(M).run())
return PreservedAnalyses::all();
return PreservedAnalyses::none();

View File

@ -145,7 +145,7 @@ static bool aggressiveDCE(Function& F) {
return !Worklist.empty();
}
PreservedAnalyses ADCEPass::run(Function &F) {
PreservedAnalyses ADCEPass::run(Function &F, FunctionAnalysisManager &) {
if (!aggressiveDCE(F))
return PreservedAnalyses::all();

View File

@ -139,7 +139,7 @@ static bool lowerAtomics(Function &F) {
return Changed;
}
PreservedAnalyses LowerAtomicPass::run(Function &F) {
PreservedAnalyses LowerAtomicPass::run(Function &F, FunctionAnalysisManager &) {
if (lowerAtomics(F))
return PreservedAnalyses::none();
return PreservedAnalyses::all();
@ -157,7 +157,8 @@ public:
bool runOnFunction(Function &F) override {
if (skipFunction(F))
return false;
auto PA = Impl.run(F);
FunctionAnalysisManager DummyFAM;
auto PA = Impl.run(F, DummyFAM);
return !PA.areAllPreserved();
}

View File

@ -170,7 +170,8 @@ static bool lowerExpectIntrinsic(Function &F) {
return Changed;
}
PreservedAnalyses LowerExpectIntrinsicPass::run(Function &F) {
PreservedAnalyses LowerExpectIntrinsicPass::run(Function &F,
FunctionAnalysisManager &) {
if (lowerExpectIntrinsic(F))
return PreservedAnalyses::none();

View File

@ -2173,7 +2173,7 @@ void ReassociatePass::ReassociateExpression(BinaryOperator *I) {
RewriteExprTree(I, Ops);
}
PreservedAnalyses ReassociatePass::run(Function &F) {
PreservedAnalyses ReassociatePass::run(Function &F, FunctionAnalysisManager &) {
// Reassociate needs for each instruction to have its operands already
// processed, so we first perform a RPOT of the basic blocks so that
// when we process a basic block, all its dominators have been processed
@ -2251,7 +2251,8 @@ namespace {
if (skipFunction(F))
return false;
auto PA = Impl.run(F);
FunctionAnalysisManager DummyFAM;
auto PA = Impl.run(F, DummyFAM);
return !PA.areAllPreserved();
}

View File

@ -199,7 +199,7 @@ struct TestSCCPass {
struct TestFunctionPass {
TestFunctionPass(int &RunCount) : RunCount(RunCount) {}
PreservedAnalyses run(Function &M) {
PreservedAnalyses run(Function &F, AnalysisManager<Function> &) {
++RunCount;
return PreservedAnalyses::none();
}

View File

@ -77,7 +77,7 @@ char TestModuleAnalysis::PassID;
struct TestModulePass : PassInfoMixin<TestModulePass> {
TestModulePass(int &RunCount) : RunCount(RunCount) {}
PreservedAnalyses run(Module &M) {
PreservedAnalyses run(Module &M, ModuleAnalysisManager &) {
++RunCount;
return PreservedAnalyses::none();
}
@ -86,7 +86,9 @@ struct TestModulePass : PassInfoMixin<TestModulePass> {
};
struct TestPreservingModulePass : PassInfoMixin<TestPreservingModulePass> {
PreservedAnalyses run(Module &M) { return PreservedAnalyses::all(); }
PreservedAnalyses run(Module &M, ModuleAnalysisManager &) {
return PreservedAnalyses::all();
}
};
struct TestMinPreservingModulePass
@ -145,7 +147,7 @@ struct TestInvalidationFunctionPass
: PassInfoMixin<TestInvalidationFunctionPass> {
TestInvalidationFunctionPass(StringRef FunctionName) : Name(FunctionName) {}
PreservedAnalyses run(Function &F) {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) {
return F.getName() == Name ? PreservedAnalyses::none()
: PreservedAnalyses::all();
}