From 04d0fe9c10b2e1337fd99fd61b6917c1e460c301 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Fri, 17 Jun 2016 00:11:01 +0000 Subject: [PATCH] [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 &` 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272978 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/AssumptionCache.h | 4 +- include/llvm/Analysis/CallGraph.h | 2 +- include/llvm/Analysis/LazyCallGraph.h | 4 +- include/llvm/Analysis/LoopInfo.h | 2 +- include/llvm/Analysis/PostDominators.h | 2 +- include/llvm/Analysis/ProfileSummaryInfo.h | 2 +- include/llvm/Analysis/TargetLibraryInfo.h | 4 +- include/llvm/Analysis/TargetTransformInfo.h | 2 +- include/llvm/Bitcode/BitcodeWriterPass.h | 4 +- include/llvm/IR/Dominators.h | 2 +- include/llvm/IR/IRPrintingPasses.h | 5 +- include/llvm/IR/PassManager.h | 7 +- include/llvm/IR/PassManagerInternal.h | 113 ++---------------- include/llvm/IR/Verifier.h | 4 +- include/llvm/Transforms/IPO/ConstantMerge.h | 2 +- .../Transforms/IPO/DeadArgumentElimination.h | 2 +- include/llvm/Transforms/IPO/ElimAvailExtern.h | 2 +- .../llvm/Transforms/IPO/ForceFunctionAttrs.h | 2 +- include/llvm/Transforms/IPO/GlobalDCE.h | 2 +- .../llvm/Transforms/IPO/StripDeadPrototypes.h | 2 +- .../llvm/Transforms/IPO/WholeProgramDevirt.h | 2 +- include/llvm/Transforms/Scalar/ADCE.h | 2 +- include/llvm/Transforms/Scalar/LowerAtomic.h | 2 +- .../Transforms/Scalar/LowerExpectIntrinsic.h | 2 +- include/llvm/Transforms/Scalar/Reassociate.h | 2 +- lib/Analysis/LoopInfo.cpp | 2 +- lib/Analysis/LoopPass.cpp | 6 +- lib/Analysis/PostDominators.cpp | 3 +- lib/Analysis/ProfileSummaryInfo.cpp | 3 +- lib/Analysis/TargetLibraryInfo.cpp | 6 +- lib/Analysis/TargetTransformInfo.cpp | 6 +- lib/Bitcode/Writer/BitcodeWriterPass.cpp | 2 +- lib/IR/Dominators.cpp | 3 +- lib/IR/IRPrintingPasses.cpp | 11 +- lib/IR/Verifier.cpp | 6 +- lib/Passes/PassBuilder.cpp | 25 ++-- lib/Transforms/IPO/ConstantMerge.cpp | 2 +- .../IPO/DeadArgumentElimination.cpp | 6 +- lib/Transforms/IPO/ElimAvailExtern.cpp | 3 +- lib/Transforms/IPO/ForceFunctionAttrs.cpp | 3 +- lib/Transforms/IPO/GlobalDCE.cpp | 5 +- lib/Transforms/IPO/StripDeadPrototypes.cpp | 3 +- lib/Transforms/IPO/WholeProgramDevirt.cpp | 3 +- lib/Transforms/Scalar/ADCE.cpp | 2 +- lib/Transforms/Scalar/LowerAtomic.cpp | 5 +- .../Scalar/LowerExpectIntrinsic.cpp | 3 +- lib/Transforms/Scalar/Reassociate.cpp | 5 +- unittests/Analysis/CGSCCPassManagerTest.cpp | 2 +- unittests/IR/PassManagerTest.cpp | 8 +- 49 files changed, 122 insertions(+), 180 deletions(-) diff --git a/include/llvm/Analysis/AssumptionCache.h b/include/llvm/Analysis/AssumptionCache.h index 08e630860e5..06f2a117ac2 100644 --- a/include/llvm/Analysis/AssumptionCache.h +++ b/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/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index 565c20569cf..4ecacb0f0be 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/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/include/llvm/Analysis/LazyCallGraph.h b/include/llvm/Analysis/LazyCallGraph.h index 4e72052b9b8..3e63bf59f6c 100644 --- a/include/llvm/Analysis/LazyCallGraph.h +++ b/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/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 06b8cc8d6b1..35dc6bcb686 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/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/include/llvm/Analysis/PostDominators.h b/include/llvm/Analysis/PostDominators.h index 28a1b0d0dc7..99240a40408 100644 --- a/include/llvm/Analysis/PostDominators.h +++ b/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/include/llvm/Analysis/ProfileSummaryInfo.h b/include/llvm/Analysis/ProfileSummaryInfo.h index 22a6ae6d996..cd624c8404d 100644 --- a/include/llvm/Analysis/ProfileSummaryInfo.h +++ b/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/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h index afe6d8b0377..7efa6f05970 100644 --- a/include/llvm/Analysis/TargetLibraryInfo.h +++ b/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/include/llvm/Analysis/TargetTransformInfo.h b/include/llvm/Analysis/TargetTransformInfo.h index e100cc83533..50c8e8aaec2 100644 --- a/include/llvm/Analysis/TargetTransformInfo.h +++ b/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/include/llvm/Bitcode/BitcodeWriterPass.h b/include/llvm/Bitcode/BitcodeWriterPass.h index dd0d5771196..946255b878a 100644 --- a/include/llvm/Bitcode/BitcodeWriterPass.h +++ b/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/include/llvm/IR/Dominators.h b/include/llvm/IR/Dominators.h index 076a2451146..9d29e207221 100644 --- a/include/llvm/IR/Dominators.h +++ b/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/include/llvm/IR/IRPrintingPasses.h b/include/llvm/IR/IRPrintingPasses.h index 88b18e826da..bc6de19a6c3 100644 --- a/include/llvm/IR/IRPrintingPasses.h +++ b/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/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index da4b708c335..402d04a54a4 100644 --- a/include/llvm/IR/PassManager.h +++ b/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/include/llvm/IR/PassManagerInternal.h b/include/llvm/IR/PassManagerInternal.h index e5bdd226a1c..0c619e8c89e 100644 --- a/include/llvm/IR/PassManagerInternal.h +++ b/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/include/llvm/IR/Verifier.h b/include/llvm/IR/Verifier.h index 654b29c5fcb..fdb6ce400a8 100644 --- a/include/llvm/IR/Verifier.h +++ b/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/include/llvm/Transforms/IPO/ConstantMerge.h b/include/llvm/Transforms/IPO/ConstantMerge.h index f0a31978c09..1d4da43f6a7 100644 --- a/include/llvm/Transforms/IPO/ConstantMerge.h +++ b/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/include/llvm/Transforms/IPO/DeadArgumentElimination.h b/include/llvm/Transforms/IPO/DeadArgumentElimination.h index 7785a9bff85..e179afa956f 100644 --- a/include/llvm/Transforms/IPO/DeadArgumentElimination.h +++ b/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/include/llvm/Transforms/IPO/ElimAvailExtern.h b/include/llvm/Transforms/IPO/ElimAvailExtern.h index 3fc7211cb3c..88a0e9bd8ce 100644 --- a/include/llvm/Transforms/IPO/ElimAvailExtern.h +++ b/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/include/llvm/Transforms/IPO/ForceFunctionAttrs.h b/include/llvm/Transforms/IPO/ForceFunctionAttrs.h index 5a6e9b36ef5..ff8a6546f05 100644 --- a/include/llvm/Transforms/IPO/ForceFunctionAttrs.h +++ b/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/include/llvm/Transforms/IPO/GlobalDCE.h b/include/llvm/Transforms/IPO/GlobalDCE.h index 4bd82e1bdf1..57e174c2a37 100644 --- a/include/llvm/Transforms/IPO/GlobalDCE.h +++ b/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/include/llvm/Transforms/IPO/StripDeadPrototypes.h b/include/llvm/Transforms/IPO/StripDeadPrototypes.h index 3dad8aa0805..5a05cd75c9d 100644 --- a/include/llvm/Transforms/IPO/StripDeadPrototypes.h +++ b/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/include/llvm/Transforms/IPO/WholeProgramDevirt.h b/include/llvm/Transforms/IPO/WholeProgramDevirt.h index 142e01e3cdc..bcffb618fdc 100644 --- a/include/llvm/Transforms/IPO/WholeProgramDevirt.h +++ b/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/include/llvm/Transforms/Scalar/ADCE.h b/include/llvm/Transforms/Scalar/ADCE.h index 0cd14bde97f..b9b7e1c0c99 100644 --- a/include/llvm/Transforms/Scalar/ADCE.h +++ b/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/include/llvm/Transforms/Scalar/LowerAtomic.h b/include/llvm/Transforms/Scalar/LowerAtomic.h index c34600e4a0d..a4a2e7aafe4 100644 --- a/include/llvm/Transforms/Scalar/LowerAtomic.h +++ b/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/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h b/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h index d03e76f5152..f688e7f1998 100644 --- a/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h +++ b/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/include/llvm/Transforms/Scalar/Reassociate.h b/include/llvm/Transforms/Scalar/Reassociate.h index d6a54f7bc9e..7b68b448930 100644 --- a/include/llvm/Transforms/Scalar/Reassociate.h +++ b/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/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index 5575bd6ce88..2628d651d0c 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/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/lib/Analysis/LoopPass.cpp b/lib/Analysis/LoopPass.cpp index 3181e4f9921..5f9d326d121 100644 --- a/lib/Analysis/LoopPass.cpp +++ b/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/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index 8d3452e4860..73550805d5b 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/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/lib/Analysis/ProfileSummaryInfo.cpp b/lib/Analysis/ProfileSummaryInfo.cpp index 7397073a06d..9cf99af4958 100644 --- a/lib/Analysis/ProfileSummaryInfo.cpp +++ b/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/lib/Analysis/TargetLibraryInfo.cpp b/lib/Analysis/TargetLibraryInfo.cpp index f70b438a06b..64f5799aacf 100644 --- a/lib/Analysis/TargetLibraryInfo.cpp +++ b/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/lib/Analysis/TargetTransformInfo.cpp b/lib/Analysis/TargetTransformInfo.cpp index 155a698c399..3d118d3d5ee 100644 --- a/lib/Analysis/TargetTransformInfo.cpp +++ b/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/lib/Bitcode/Writer/BitcodeWriterPass.cpp b/lib/Bitcode/Writer/BitcodeWriterPass.cpp index 2eeeb5d272c..3e89ade424a 100644 --- a/lib/Bitcode/Writer/BitcodeWriterPass.cpp +++ b/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/lib/IR/Dominators.cpp b/lib/IR/Dominators.cpp index 0d2c70fe2c7..57e3df76d02 100644 --- a/lib/IR/Dominators.cpp +++ b/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/lib/IR/IRPrintingPasses.cpp b/lib/IR/IRPrintingPasses.cpp index 822dbeb08b3..4d2f9b98911 100644 --- a/lib/IR/IRPrintingPasses.cpp +++ b/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/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index 29550e2e733..ecba8be7eb8 100644 --- a/lib/IR/Verifier.cpp +++ b/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/lib/Passes/PassBuilder.cpp b/lib/Passes/PassBuilder.cpp index 668d8d28651..9af7862b16d 100644 --- a/lib/Passes/PassBuilder.cpp +++ b/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/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index 65b042534f3..d75ed206ad2 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/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/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index 3caaa4a3218..70b0bd8ee64 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/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/lib/Transforms/IPO/ElimAvailExtern.cpp b/lib/Transforms/IPO/ElimAvailExtern.cpp index b3ca10bd945..98c4b174030 100644 --- a/lib/Transforms/IPO/ElimAvailExtern.cpp +++ b/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/lib/Transforms/IPO/ForceFunctionAttrs.cpp b/lib/Transforms/IPO/ForceFunctionAttrs.cpp index 6df044762cf..96871213820 100644 --- a/lib/Transforms/IPO/ForceFunctionAttrs.cpp +++ b/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/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index fca549947c6..f30e69ccbcd 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/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/lib/Transforms/IPO/StripDeadPrototypes.cpp b/lib/Transforms/IPO/StripDeadPrototypes.cpp index 602fdfa8d74..3c3c5dd19d1 100644 --- a/lib/Transforms/IPO/StripDeadPrototypes.cpp +++ b/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/lib/Transforms/IPO/WholeProgramDevirt.cpp b/lib/Transforms/IPO/WholeProgramDevirt.cpp index 4a80e4f11c9..93ee07cf64e 100644 --- a/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/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/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 1c9160e2869..89e1c50b8c7 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/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/lib/Transforms/Scalar/LowerAtomic.cpp b/lib/Transforms/Scalar/LowerAtomic.cpp index 5b8579e2eee..08e60b16bed 100644 --- a/lib/Transforms/Scalar/LowerAtomic.cpp +++ b/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/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp b/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp index 40ba7447359..79f0db1163a 100644 --- a/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp +++ b/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/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index 67d5ab2b4dd..8e7eaf844c6 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/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/unittests/Analysis/CGSCCPassManagerTest.cpp b/unittests/Analysis/CGSCCPassManagerTest.cpp index 7f6e4d13ff8..431fb62cdc9 100644 --- a/unittests/Analysis/CGSCCPassManagerTest.cpp +++ b/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/unittests/IR/PassManagerTest.cpp b/unittests/IR/PassManagerTest.cpp index 3bfe22cf646..80ed723ae08 100644 --- a/unittests/IR/PassManagerTest.cpp +++ b/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(); }