diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index 70618c53ac5..dfd0f1ab313 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -243,13 +243,11 @@ public: private: // Pull in the concept type and model template specialized for modules. - typedef detail::PassConcept> PassConcept; + typedef detail::PassConcept PassConcept; template - struct PassModel - : detail::PassModel, PassT> { + struct PassModel : detail::PassModel { PassModel(PassT Pass) - : detail::PassModel, PassT>( - std::move(Pass)) {} + : detail::PassModel(std::move(Pass)) {} }; PassManager(const PassManager &) LLVM_DELETED_FUNCTION; @@ -295,7 +293,7 @@ template class AnalysisManagerBase { protected: typedef detail::AnalysisResultConcept ResultConceptT; - typedef detail::AnalysisPassConcept PassConceptT; + typedef detail::AnalysisPassConcept PassConceptT; // FIXME: Provide template aliases for the models when we're using C++11 in // a mode supporting them. @@ -354,7 +352,7 @@ public: template void registerPass(PassT Pass) { assert(!AnalysisPasses.count(PassT::ID()) && "Registered the same analysis pass twice!"); - typedef detail::AnalysisPassModel PassModelT; + typedef detail::AnalysisPassModel PassModelT; AnalysisPasses[PassT::ID()].reset(new PassModelT(std::move(Pass))); } @@ -823,8 +821,8 @@ template struct RequireAnalysisPass { /// provided they satisfy the basic API requirements. When this pass is /// created, these methods can be instantiated to satisfy whatever the /// context requires. - template - PreservedAnalyses run(IRUnitT &Arg, AnalysisManagerT *AM) { + template + PreservedAnalyses run(IRUnitT &Arg, AnalysisManager *AM) { if (AM) (void)AM->template getResult(Arg); @@ -846,8 +844,8 @@ template struct InvalidateAnalysisPass { /// provided they satisfy the basic API requirements. When this pass is /// created, these methods can be instantiated to satisfy whatever the /// context requires. - template - PreservedAnalyses run(IRUnitT &Arg, AnalysisManagerT *AM) { + template + PreservedAnalyses run(IRUnitT &Arg, AnalysisManager *AM) { if (AM) // We have to directly invalidate the analysis result as we can't // enumerate all other analyses and use the preserved set to control it. diff --git a/include/llvm/IR/PassManagerInternal.h b/include/llvm/IR/PassManagerInternal.h index 0d0f178c95c..297f5f4e07f 100644 --- a/include/llvm/IR/PassManagerInternal.h +++ b/include/llvm/IR/PassManagerInternal.h @@ -22,8 +22,7 @@ namespace llvm { -class Function; -class Module; +template class AnalysisManager; class PreservedAnalyses; /// \brief Implementation details of the pass manager interfaces. @@ -31,7 +30,7 @@ namespace detail { /// \brief Template for the abstract base class used to dispatch /// polymorphically over pass objects. -template struct PassConcept { +template struct PassConcept { // Boiler plate necessary for the container of derived classes. virtual ~PassConcept() {} @@ -40,23 +39,22 @@ template struct PassConcept { /// Note that actual pass object can omit the analysis manager argument if /// desired. Also that the analysis manager may be null if there is no /// analysis manager in the pass pipeline. - virtual PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT *AM) = 0; + virtual PreservedAnalyses run(IRUnitT &IR, AnalysisManager *AM) = 0; /// \brief Polymorphic method to access the name of a pass. virtual StringRef name() = 0; }; /// \brief SFINAE metafunction for computing whether \c PassT has a run method -/// accepting an \c AnalysisManagerT. -template +/// accepting an \c AnalysisManager. +template class PassRunAcceptsAnalysisManager { typedef char SmallType; struct BigType { char a, b; }; - template + template *)> struct Checker; template static SmallType f(Checker *); @@ -70,19 +68,19 @@ public: /// /// 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 AnalysisManagerT*, we pass it along. -template *, we pass it +/// along. +template ::Value> + IRUnitT, PassT, PreservedAnalysesT>::Value> struct PassModel; /// \brief Specialization of \c PassModel for passes that accept an analyis /// manager. -template -struct PassModel - : PassConcept { +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. @@ -97,7 +95,7 @@ struct PassModel return *this; } - PreservedAnalysesT run(IRUnitT &IR, AnalysisManagerT *AM) override { + PreservedAnalysesT run(IRUnitT &IR, AnalysisManager *AM) override { return Pass.run(IR, AM); } StringRef name() override { return PassT::name(); } @@ -106,10 +104,9 @@ struct PassModel /// \brief Specialization of \c PassModel for passes that accept an analyis /// manager. -template -struct PassModel - : PassConcept { +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. @@ -124,7 +121,7 @@ struct PassModel return *this; } - PreservedAnalysesT run(IRUnitT &IR, AnalysisManagerT *AM) override { + PreservedAnalysesT run(IRUnitT &IR, AnalysisManager *AM) override { return Pass.run(IR); } StringRef name() override { return PassT::name(); } @@ -247,15 +244,14 @@ struct AnalysisResultModel /// /// This concept is parameterized over the IR unit that it can run over and /// produce an analysis result. -template -struct AnalysisPassConcept { +template struct AnalysisPassConcept { virtual ~AnalysisPassConcept() {} /// \brief Method to run this analysis over a unit of IR. /// \returns A unique_ptr to the analysis result object to be queried by /// users. virtual std::unique_ptr> - run(IRUnitT &IR, AnalysisManagerT *AM) = 0; + run(IRUnitT &IR, AnalysisManager *AM) = 0; /// \brief Polymorphic method to access the name of a pass. virtual StringRef name() = 0; @@ -266,16 +262,15 @@ struct AnalysisPassConcept { /// 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> + IRUnitT, PassT, typename PassT::Result>::Value> struct AnalysisPassModel; /// \brief Specialization of \c AnalysisPassModel which passes an /// \c AnalysisManager to PassT's run method. -template -struct AnalysisPassModel - : AnalysisPassConcept { +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. @@ -298,7 +293,7 @@ struct AnalysisPassModel /// /// The return is wrapped in an \c AnalysisResultModel. std::unique_ptr> - run(IRUnitT &IR, AnalysisManagerT *AM) override { + run(IRUnitT &IR, AnalysisManager *AM) override { return make_unique(Pass.run(IR, AM)); } @@ -312,9 +307,8 @@ struct AnalysisPassModel /// \brief Specialization of \c AnalysisPassModel which does not pass an /// \c AnalysisManager to PassT's run method. -template -struct AnalysisPassModel - : AnalysisPassConcept { +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. @@ -337,7 +331,7 @@ struct AnalysisPassModel /// /// The return is wrapped in an \c AnalysisResultModel. std::unique_ptr> - run(IRUnitT &IR, AnalysisManagerT *) override { + run(IRUnitT &IR, AnalysisManager *) override { return make_unique(Pass.run(IR)); }