diff --git a/llvm/include/llvm/Analysis/AssumptionCache.h b/llvm/include/llvm/Analysis/AssumptionCache.h index 08e630860e5f..06f2a117ac21 100644 --- a/llvm/include/llvm/Analysis/AssumptionCache.h +++ b/llvm/include/llvm/Analysis/AssumptionCache.h @@ -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. diff --git a/llvm/include/llvm/Analysis/CallGraph.h b/llvm/include/llvm/Analysis/CallGraph.h index 565c20569cf7..4ecacb0f0be2 100644 --- a/llvm/include/llvm/Analysis/CallGraph.h +++ b/llvm/include/llvm/Analysis/CallGraph.h @@ -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. diff --git a/llvm/include/llvm/Analysis/LazyCallGraph.h b/llvm/include/llvm/Analysis/LazyCallGraph.h index 4e72052b9b8b..3e63bf59f6cb 100644 --- a/llvm/include/llvm/Analysis/LazyCallGraph.h +++ b/llvm/include/llvm/Analysis/LazyCallGraph.h @@ -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. diff --git a/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h index 06b8cc8d6b19..35dc6bcb6864 100644 --- a/llvm/include/llvm/Analysis/LoopInfo.h +++ b/llvm/include/llvm/Analysis/LoopInfo.h @@ -826,7 +826,7 @@ public: PrintLoopPass(); PrintLoopPass(raw_ostream &OS, const std::string &Banner = ""); - PreservedAnalyses run(Loop &L); + PreservedAnalyses run(Loop &L, AnalysisManager &); }; } // End llvm namespace diff --git a/llvm/include/llvm/Analysis/PostDominators.h b/llvm/include/llvm/Analysis/PostDominators.h index 28a1b0d0dc7a..99240a40408e 100644 --- a/llvm/include/llvm/Analysis/PostDominators.h +++ b/llvm/include/llvm/Analysis/PostDominators.h @@ -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. diff --git a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h index 22a6ae6d9966..cd624c8404da 100644 --- a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h +++ b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h @@ -91,7 +91,7 @@ public: return *this; } - Result run(Module &M); + Result run(Module &M, ModuleAnalysisManager &); private: friend AnalysisInfoMixin; diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h index afe6d8b03772..7efa6f059707 100644 --- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h +++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h @@ -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; diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h index e100cc835336..50c8e8aaec29 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfo.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -995,7 +995,7 @@ public: return *this; } - Result run(const Function &F); + Result run(const Function &F, AnalysisManager &); private: friend AnalysisInfoMixin; diff --git a/llvm/include/llvm/Bitcode/BitcodeWriterPass.h b/llvm/include/llvm/Bitcode/BitcodeWriterPass.h index dd0d57711964..946255b878a6 100644 --- a/llvm/include/llvm/Bitcode/BitcodeWriterPass.h +++ b/llvm/include/llvm/Bitcode/BitcodeWriterPass.h @@ -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"; } }; diff --git a/llvm/include/llvm/IR/Dominators.h b/llvm/include/llvm/IR/Dominators.h index 076a24511468..9d29e207221f 100644 --- a/llvm/include/llvm/IR/Dominators.h +++ b/llvm/include/llvm/IR/Dominators.h @@ -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 &); }; /// \brief Printer pass for the \c DominatorTree. diff --git a/llvm/include/llvm/IR/IRPrintingPasses.h b/llvm/include/llvm/IR/IRPrintingPasses.h index 88b18e826daf..bc6de19a6c3a 100644 --- a/llvm/include/llvm/IR/IRPrintingPasses.h +++ b/llvm/include/llvm/IR/IRPrintingPasses.h @@ -30,6 +30,7 @@ class Module; class ModulePass; class PreservedAnalyses; class raw_ostream; +template 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 &); 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 &); static StringRef name() { return "PrintFunctionPass"; } }; diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h index da4b708c3359..402d04a54a41 100644 --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -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 &) { 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 &) { 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 { /// \brief Run this pass over some unit of IR. - template PreservedAnalyses run(IRUnitT &Arg) { + template + PreservedAnalyses run(IRUnitT &, AnalysisManager &) { return PreservedAnalyses::none(); } }; diff --git a/llvm/include/llvm/IR/PassManagerInternal.h b/llvm/include/llvm/IR/PassManagerInternal.h index e5bdd226a1c4..0c619e8c89e0 100644 --- a/llvm/include/llvm/IR/PassManagerInternal.h +++ b/llvm/include/llvm/IR/PassManagerInternal.h @@ -46,42 +46,14 @@ template struct PassConcept { virtual StringRef name() = 0; }; -/// \brief SFINAE metafunction for computing whether \c PassT has a run method -/// accepting an \c AnalysisManager. -template -class PassRunAcceptsAnalysisManager { - typedef char SmallType; - struct BigType { - char a, b; - }; - - template &)> - struct Checker; - - template static SmallType f(Checker *); - template static BigType f(...); - -public: - enum { Value = sizeof(f(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*, we pass it -/// along. +/// an \c IRUnitT& and an \c AnalysisManager&. It requires the pass to +/// be a copyable object. When the template ::Value> -struct PassModel; - -/// \brief Specialization of \c PassModel for passes that accept an analyis -/// manager. -template -struct PassModel - : PassConcept { + typename PreservedAnalysesT = PreservedAnalyses> +struct PassModel : PassConcept { 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 PassT Pass; }; -/// \brief Specialization of \c PassModel for passes that accept an analyis -/// manager. -template -struct PassModel - : PassConcept { - 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 &) 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 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 ::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& as arguments +/// and produce an object which can be wrapped in a \c AnalysisResultModel. template -struct AnalysisPassModel : AnalysisPassConcept { +struct AnalysisPassModel : AnalysisPassConcept { 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 : AnalysisPassConcept { PassT Pass; }; -/// \brief Specialization of \c AnalysisPassModel which does not pass an -/// \c AnalysisManager to PassT's run method. -template -struct AnalysisPassModel : AnalysisPassConcept { - 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 - ResultModelT; - - /// \brief The model delegates to the \c PassT::run method. - /// - /// The return is wrapped in an \c AnalysisResultModel. - std::unique_ptr> - run(IRUnitT &IR, AnalysisManager &) override { - return make_unique(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 } diff --git a/llvm/include/llvm/IR/Verifier.h b/llvm/include/llvm/IR/Verifier.h index 654b29c5fcbc..fdb6ce400a8d 100644 --- a/llvm/include/llvm/IR/Verifier.h +++ b/llvm/include/llvm/IR/Verifier.h @@ -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. diff --git a/llvm/include/llvm/Transforms/IPO/ConstantMerge.h b/llvm/include/llvm/Transforms/IPO/ConstantMerge.h index f0a31978c097..1d4da43f6a7b 100644 --- a/llvm/include/llvm/Transforms/IPO/ConstantMerge.h +++ b/llvm/include/llvm/Transforms/IPO/ConstantMerge.h @@ -28,7 +28,7 @@ namespace llvm { /// A pass that merges duplicate global constants into a single constant. class ConstantMergePass : public PassInfoMixin { public: - PreservedAnalyses run(Module &M); + PreservedAnalyses run(Module &M, ModuleAnalysisManager &); }; } diff --git a/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h b/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h index 7785a9bff858..e179afa956f6 100644 --- a/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h +++ b/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h @@ -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); diff --git a/llvm/include/llvm/Transforms/IPO/ElimAvailExtern.h b/llvm/include/llvm/Transforms/IPO/ElimAvailExtern.h index 3fc7211cb3ca..88a0e9bd8ce0 100644 --- a/llvm/include/llvm/Transforms/IPO/ElimAvailExtern.h +++ b/llvm/include/llvm/Transforms/IPO/ElimAvailExtern.h @@ -24,7 +24,7 @@ namespace llvm { class EliminateAvailableExternallyPass : public PassInfoMixin { public: - PreservedAnalyses run(Module &M); + PreservedAnalyses run(Module &M, ModuleAnalysisManager &); }; } diff --git a/llvm/include/llvm/Transforms/IPO/ForceFunctionAttrs.h b/llvm/include/llvm/Transforms/IPO/ForceFunctionAttrs.h index 5a6e9b36ef58..ff8a6546f059 100644 --- a/llvm/include/llvm/Transforms/IPO/ForceFunctionAttrs.h +++ b/llvm/include/llvm/Transforms/IPO/ForceFunctionAttrs.h @@ -22,7 +22,7 @@ namespace llvm { /// Pass which forces specific function attributes into the IR, primarily as /// a debugging tool. struct ForceFunctionAttrsPass : PassInfoMixin { - PreservedAnalyses run(Module &M); + PreservedAnalyses run(Module &M, ModuleAnalysisManager &); }; /// Create a legacy pass manager instance of a pass to force function attrs. diff --git a/llvm/include/llvm/Transforms/IPO/GlobalDCE.h b/llvm/include/llvm/Transforms/IPO/GlobalDCE.h index 4bd82e1bdf1e..57e174c2a37f 100644 --- a/llvm/include/llvm/Transforms/IPO/GlobalDCE.h +++ b/llvm/include/llvm/Transforms/IPO/GlobalDCE.h @@ -27,7 +27,7 @@ namespace llvm { /// Pass to remove unused function declarations. class GlobalDCEPass : public PassInfoMixin { public: - PreservedAnalyses run(Module &M); + PreservedAnalyses run(Module &M, ModuleAnalysisManager &); private: SmallPtrSet AliveGlobals; diff --git a/llvm/include/llvm/Transforms/IPO/StripDeadPrototypes.h b/llvm/include/llvm/Transforms/IPO/StripDeadPrototypes.h index 3dad8aa08059..5a05cd75c9d5 100644 --- a/llvm/include/llvm/Transforms/IPO/StripDeadPrototypes.h +++ b/llvm/include/llvm/Transforms/IPO/StripDeadPrototypes.h @@ -24,7 +24,7 @@ namespace llvm { /// Pass to remove unused function declarations. struct StripDeadPrototypesPass : PassInfoMixin { - PreservedAnalyses run(Module &M); + PreservedAnalyses run(Module &M, ModuleAnalysisManager &); }; } diff --git a/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h b/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h index 142e01e3cdcd..bcffb618fdcf 100644 --- a/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h +++ b/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h @@ -214,7 +214,7 @@ void setAfterReturnValues(MutableArrayRef Targets, } // end namespace wholeprogramdevirt struct WholeProgramDevirtPass : public PassInfoMixin { - PreservedAnalyses run(Module &M); + PreservedAnalyses run(Module &M, ModuleAnalysisManager &); }; } // end namespace llvm diff --git a/llvm/include/llvm/Transforms/Scalar/ADCE.h b/llvm/include/llvm/Transforms/Scalar/ADCE.h index 0cd14bde97f0..b9b7e1c0c99f 100644 --- a/llvm/include/llvm/Transforms/Scalar/ADCE.h +++ b/llvm/include/llvm/Transforms/Scalar/ADCE.h @@ -29,7 +29,7 @@ namespace llvm { /// dead computations that other DCE passes do not catch, particularly involving /// loop computations. struct ADCEPass : PassInfoMixin { - PreservedAnalyses run(Function &F); + PreservedAnalyses run(Function &F, FunctionAnalysisManager &); }; } diff --git a/llvm/include/llvm/Transforms/Scalar/LowerAtomic.h b/llvm/include/llvm/Transforms/Scalar/LowerAtomic.h index c34600e4a0dc..a4a2e7aafe44 100644 --- a/llvm/include/llvm/Transforms/Scalar/LowerAtomic.h +++ b/llvm/include/llvm/Transforms/Scalar/LowerAtomic.h @@ -22,7 +22,7 @@ namespace llvm { /// A pass that lowers atomic intrinsic into non-atomic intrinsics. class LowerAtomicPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F); + PreservedAnalyses run(Function &F, FunctionAnalysisManager &); }; } diff --git a/llvm/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h b/llvm/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h index d03e76f51525..f688e7f19986 100644 --- a/llvm/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h +++ b/llvm/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h @@ -29,7 +29,7 @@ struct LowerExpectIntrinsicPass : PassInfoMixin { /// 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 &); }; } diff --git a/llvm/include/llvm/Transforms/Scalar/Reassociate.h b/llvm/include/llvm/Transforms/Scalar/Reassociate.h index d6a54f7bc9ed..7b68b4489306 100644 --- a/llvm/include/llvm/Transforms/Scalar/Reassociate.h +++ b/llvm/include/llvm/Transforms/Scalar/Reassociate.h @@ -62,7 +62,7 @@ class ReassociatePass : public PassInfoMixin { bool MadeChange; public: - PreservedAnalyses run(Function &F); + PreservedAnalyses run(Function &F, FunctionAnalysisManager &); private: void BuildRankMap(Function &F, ReversePostOrderTraversal &RPOT); diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 5575bd6ce88e..2628d651d0c6 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -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 &) { OS << Banner; for (auto *Block : L.blocks()) if (Block) diff --git a/llvm/lib/Analysis/LoopPass.cpp b/llvm/lib/Analysis/LoopPass.cpp index 3181e4f99218..5f9d326d1217 100644 --- a/llvm/lib/Analysis/LoopPass.cpp +++ b/llvm/lib/Analysis/LoopPass.cpp @@ -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 DummyLAM; + P.run(*L, DummyLAM); + } return false; } }; diff --git a/llvm/lib/Analysis/PostDominators.cpp b/llvm/lib/Analysis/PostDominators.cpp index 8d3452e4860c..73550805d5ba 100644 --- a/llvm/lib/Analysis/PostDominators.cpp +++ b/llvm/lib/Analysis/PostDominators.cpp @@ -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; diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp index 7397073a06dc..9cf99af49581 100644 --- a/llvm/lib/Analysis/ProfileSummaryInfo.cpp +++ b/llvm/lib/Analysis/ProfileSummaryInfo.cpp @@ -140,7 +140,8 @@ ProfileSummaryInfoWrapperPass::ProfileSummaryInfoWrapperPass() } char ProfileSummaryAnalysis::PassID; -ProfileSummaryInfo ProfileSummaryAnalysis::run(Module &M) { +ProfileSummaryInfo ProfileSummaryAnalysis::run(Module &M, + ModuleAnalysisManager &) { return ProfileSummaryInfo(M); } diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp index f70b438a06ba..64f5799aacf8 100644 --- a/llvm/lib/Analysis/TargetLibraryInfo.cpp +++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp @@ -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); diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp index 155a698c3998..3d118d3d5ee5 100644 --- a/llvm/lib/Analysis/TargetTransformInfo.cpp +++ b/llvm/lib/Analysis/TargetTransformInfo.cpp @@ -404,7 +404,8 @@ TargetIRAnalysis::TargetIRAnalysis( std::function TTICallback) : TTICallback(std::move(TTICallback)) {} -TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F) { +TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F, + AnalysisManager &) { return TTICallback(F); } @@ -435,7 +436,8 @@ TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass( } TargetTransformInfo &TargetTransformInfoWrapperPass::getTTI(const Function &F) { - TTI = TIRA.run(F); + AnalysisManager DummyFAM; + TTI = TIRA.run(F, DummyFAM); return *TTI; } diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp index 2eeeb5d272ca..3e89ade424a2 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp @@ -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 Index; if (EmitSummaryIndex) Index = ModuleSummaryIndexBuilder(&M).takeIndex(); diff --git a/llvm/lib/IR/Dominators.cpp b/llvm/lib/IR/Dominators.cpp index 0d2c70fe2c72..57e3df76d023 100644 --- a/llvm/lib/IR/Dominators.cpp +++ b/llvm/lib/IR/Dominators.cpp @@ -300,7 +300,8 @@ void DominatorTree::verifyDomTree() const { // //===----------------------------------------------------------------------===// -DominatorTree DominatorTreeAnalysis::run(Function &F) { +DominatorTree DominatorTreeAnalysis::run(Function &F, + AnalysisManager &) { DominatorTree DT; DT.recalculate(F); return DT; diff --git a/llvm/lib/IR/IRPrintingPasses.cpp b/llvm/lib/IR/IRPrintingPasses.cpp index 822dbeb08b33..4d2f9b98911b 100644 --- a/llvm/lib/IR/IRPrintingPasses.cpp +++ b/llvm/lib/IR/IRPrintingPasses.cpp @@ -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 &) { 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 &) { if (isFunctionInPrintList(F.getName())) OS << Banner << static_cast(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; } diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 29550e2e733a..ecba8be7eb89 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -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 }; } diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 668d8d28651c..9af7862b16d9 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -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 &) { + return PreservedAnalyses::all(); + } static StringRef name() { return "NoOpModulePass"; } }; @@ -116,13 +118,14 @@ class NoOpModuleAnalysis : public AnalysisInfoMixin { public: struct Result {}; - Result run(Module &) { return Result(); } + Result run(Module &, AnalysisManager &) { 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 &) { return PreservedAnalyses::all(); } static StringRef name() { return "NoOpCGSCCPass"; } @@ -135,13 +138,17 @@ class NoOpCGSCCAnalysis : public AnalysisInfoMixin { public: struct Result {}; - Result run(LazyCallGraph::SCC &) { return Result(); } + Result run(LazyCallGraph::SCC &, AnalysisManager &) { + 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 &) { + return PreservedAnalyses::all(); + } static StringRef name() { return "NoOpFunctionPass"; } }; @@ -152,13 +159,15 @@ class NoOpFunctionAnalysis : public AnalysisInfoMixin { public: struct Result {}; - Result run(Function &) { return Result(); } + Result run(Function &, AnalysisManager &) { 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 &) { + return PreservedAnalyses::all(); + } static StringRef name() { return "NoOpLoopPass"; } }; @@ -169,7 +178,7 @@ class NoOpLoopAnalysis : public AnalysisInfoMixin { public: struct Result {}; - Result run(Loop &) { return Result(); } + Result run(Loop &, AnalysisManager &) { return Result(); } static StringRef name() { return "NoOpLoopAnalysis"; } }; diff --git a/llvm/lib/Transforms/IPO/ConstantMerge.cpp b/llvm/lib/Transforms/IPO/ConstantMerge.cpp index 65b042534f39..d75ed206ad23 100644 --- a/llvm/lib/Transforms/IPO/ConstantMerge.cpp +++ b/llvm/lib/Transforms/IPO/ConstantMerge.cpp @@ -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(); diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp index 3caaa4a32182..70b0bd8ee642 100644 --- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -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 "..." diff --git a/llvm/lib/Transforms/IPO/ElimAvailExtern.cpp b/llvm/lib/Transforms/IPO/ElimAvailExtern.cpp index b3ca10bd945f..98c4b1740306 100644 --- a/llvm/lib/Transforms/IPO/ElimAvailExtern.cpp +++ b/llvm/lib/Transforms/IPO/ElimAvailExtern.cpp @@ -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(); diff --git a/llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp b/llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp index 6df044762cf4..968712138208 100644 --- a/llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp @@ -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(); diff --git a/llvm/lib/Transforms/IPO/GlobalDCE.cpp b/llvm/lib/Transforms/IPO/GlobalDCE.cpp index fca549947c6c..f30e69ccbcde 100644 --- a/llvm/lib/Transforms/IPO/GlobalDCE.cpp +++ b/llvm/lib/Transforms/IPO/GlobalDCE.cpp @@ -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. diff --git a/llvm/lib/Transforms/IPO/StripDeadPrototypes.cpp b/llvm/lib/Transforms/IPO/StripDeadPrototypes.cpp index 602fdfa8d74a..3c3c5dd19d1f 100644 --- a/llvm/lib/Transforms/IPO/StripDeadPrototypes.cpp +++ b/llvm/lib/Transforms/IPO/StripDeadPrototypes.cpp @@ -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(); diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp index 4a80e4f11c9e..93ee07cf64e7 100644 --- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -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(); diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp index 1c9160e2869d..89e1c50b8c76 100644 --- a/llvm/lib/Transforms/Scalar/ADCE.cpp +++ b/llvm/lib/Transforms/Scalar/ADCE.cpp @@ -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(); diff --git a/llvm/lib/Transforms/Scalar/LowerAtomic.cpp b/llvm/lib/Transforms/Scalar/LowerAtomic.cpp index 5b8579e2eeee..08e60b16bedf 100644 --- a/llvm/lib/Transforms/Scalar/LowerAtomic.cpp +++ b/llvm/lib/Transforms/Scalar/LowerAtomic.cpp @@ -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(); } diff --git a/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp b/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp index 40ba74473590..79f0db1163a4 100644 --- a/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp +++ b/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp @@ -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(); diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp index 67d5ab2b4dd6..8e7eaf844c6c 100644 --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -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(); } diff --git a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp index 7f6e4d13ff8f..431fb62cdc9a 100644 --- a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp +++ b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp @@ -199,7 +199,7 @@ struct TestSCCPass { struct TestFunctionPass { TestFunctionPass(int &RunCount) : RunCount(RunCount) {} - PreservedAnalyses run(Function &M) { + PreservedAnalyses run(Function &F, AnalysisManager &) { ++RunCount; return PreservedAnalyses::none(); } diff --git a/llvm/unittests/IR/PassManagerTest.cpp b/llvm/unittests/IR/PassManagerTest.cpp index 3bfe22cf646f..80ed723ae085 100644 --- a/llvm/unittests/IR/PassManagerTest.cpp +++ b/llvm/unittests/IR/PassManagerTest.cpp @@ -77,7 +77,7 @@ char TestModuleAnalysis::PassID; struct TestModulePass : PassInfoMixin { 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 { }; struct TestPreservingModulePass : PassInfoMixin { - 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(StringRef FunctionName) : Name(FunctionName) {} - PreservedAnalyses run(Function &F) { + PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) { return F.getName() == Name ? PreservedAnalyses::none() : PreservedAnalyses::all(); }