From 18e9a2b6237519f3ab16e40130f866c3ca53580e Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Fri, 11 Mar 2016 10:33:22 +0000 Subject: [PATCH] [PM] Rename the CRTP mixin base classes for the new pass manager to clarify their purpose. Firstly, call them "...Mixin" types so it is clear that there is no type hierarchy being formed here. Secondly, use the term 'Info' to clarify that they aren't adding any interesting *semantics* to the passes or analyses, just exposing APIs used by the management layer to get information about the pass or analysis. Thanks to Manuel for helping pin down the naming confusion here and come up with effective names to address it. In case you already have some out-of-tree stuff, the following should be roughly what you want to update: perl -pi -e 's/\b(Pass|Analysis)Base\b/\1InfoMixin/g' git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263217 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/AliasAnalysis.h | 4 +-- .../llvm/Analysis/AliasAnalysisEvaluator.h | 2 +- include/llvm/Analysis/AssumptionCache.h | 6 ++-- include/llvm/Analysis/BasicAliasAnalysis.h | 4 +-- include/llvm/Analysis/CFLAliasAnalysis.h | 4 +-- include/llvm/Analysis/CGSCCPassManager.h | 4 +-- include/llvm/Analysis/CallGraph.h | 6 ++-- include/llvm/Analysis/DominanceFrontier.h | 6 ++-- include/llvm/Analysis/GlobalsModRef.h | 4 +-- include/llvm/Analysis/LazyCallGraph.h | 7 ++-- include/llvm/Analysis/LoopInfo.h | 8 ++--- include/llvm/Analysis/LoopPassManager.h | 2 +- .../llvm/Analysis/MemoryDependenceAnalysis.h | 5 +-- include/llvm/Analysis/ObjCARCAliasAnalysis.h | 4 +-- include/llvm/Analysis/PostDominators.h | 6 ++-- include/llvm/Analysis/RegionInfo.h | 8 ++--- include/llvm/Analysis/ScalarEvolution.h | 7 ++-- .../Analysis/ScalarEvolutionAliasAnalysis.h | 4 +-- include/llvm/Analysis/ScopedNoAliasAA.h | 4 +-- include/llvm/Analysis/TargetLibraryInfo.h | 4 +-- include/llvm/Analysis/TargetTransformInfo.h | 4 +-- .../llvm/Analysis/TypeBasedAliasAnalysis.h | 4 +-- include/llvm/IR/Dominators.h | 9 ++--- include/llvm/IR/PassManager.h | 36 +++++++++++-------- include/llvm/IR/Verifier.h | 2 +- .../llvm/Transforms/IPO/ForceFunctionAttrs.h | 2 +- include/llvm/Transforms/IPO/FunctionAttrs.h | 2 +- .../llvm/Transforms/IPO/InferFunctionAttrs.h | 2 +- .../llvm/Transforms/IPO/StripDeadPrototypes.h | 2 +- .../llvm/Transforms/InstCombine/InstCombine.h | 2 +- include/llvm/Transforms/Scalar/ADCE.h | 2 +- include/llvm/Transforms/Scalar/EarlyCSE.h | 2 +- include/llvm/Transforms/Scalar/GVN.h | 2 +- .../Transforms/Scalar/LowerExpectIntrinsic.h | 2 +- include/llvm/Transforms/Scalar/SROA.h | 2 +- include/llvm/Transforms/Scalar/SimplifyCFG.h | 2 +- lib/Passes/PassBuilder.cpp | 16 ++++----- unittests/IR/PassManagerTest.cpp | 20 ++++++----- 38 files changed, 113 insertions(+), 99 deletions(-) diff --git a/include/llvm/Analysis/AliasAnalysis.h b/include/llvm/Analysis/AliasAnalysis.h index 53c0b18fa22..424ea0f74d6 100644 --- a/include/llvm/Analysis/AliasAnalysis.h +++ b/include/llvm/Analysis/AliasAnalysis.h @@ -838,7 +838,7 @@ bool isIdentifiedFunctionLocal(const Value *V); /// This manager effectively wraps the AnalysisManager for registering alias /// analyses. When you register your alias analysis with this manager, it will /// ensure the analysis itself is registered with its AnalysisManager. -class AAManager : public AnalysisBase { +class AAManager : public AnalysisInfoMixin { public: typedef AAResults Result; @@ -874,7 +874,7 @@ public: } private: - friend AnalysisBase; + friend AnalysisInfoMixin; static char PassID; SmallVector &AM, diff --git a/include/llvm/Analysis/AliasAnalysisEvaluator.h b/include/llvm/Analysis/AliasAnalysisEvaluator.h index 2021fdfb4f4..2b9573e8b7b 100644 --- a/include/llvm/Analysis/AliasAnalysisEvaluator.h +++ b/include/llvm/Analysis/AliasAnalysisEvaluator.h @@ -31,7 +31,7 @@ namespace llvm { class AAResults; -class AAEvaluator : public PassBase { +class AAEvaluator : public PassInfoMixin { int64_t FunctionCount; int64_t NoAliasCount, MayAliasCount, PartialAliasCount, MustAliasCount; int64_t NoModRefCount, ModCount, RefCount, ModRefCount; diff --git a/include/llvm/Analysis/AssumptionCache.h b/include/llvm/Analysis/AssumptionCache.h index 9c2737c5181..f76a73780a4 100644 --- a/include/llvm/Analysis/AssumptionCache.h +++ b/include/llvm/Analysis/AssumptionCache.h @@ -93,8 +93,8 @@ public: /// /// This analysis is intended for use with the new pass manager and will vend /// assumption caches for a given function. -class AssumptionAnalysis : public AnalysisBase { - friend AnalysisBase; +class AssumptionAnalysis : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: @@ -110,7 +110,7 @@ public: }; /// \brief Printer pass for the \c AssumptionAnalysis results. -class AssumptionPrinterPass : public PassBase { +class AssumptionPrinterPass : public PassInfoMixin { raw_ostream &OS; public: diff --git a/include/llvm/Analysis/BasicAliasAnalysis.h b/include/llvm/Analysis/BasicAliasAnalysis.h index bd71eae388c..43752c7d725 100644 --- a/include/llvm/Analysis/BasicAliasAnalysis.h +++ b/include/llvm/Analysis/BasicAliasAnalysis.h @@ -180,8 +180,8 @@ private: }; /// Analysis pass providing a never-invalidated alias analysis result. -class BasicAA : public AnalysisBase { - friend AnalysisBase; +class BasicAA : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: diff --git a/include/llvm/Analysis/CFLAliasAnalysis.h b/include/llvm/Analysis/CFLAliasAnalysis.h index 1e7c3b72540..08848700239 100644 --- a/include/llvm/Analysis/CFLAliasAnalysis.h +++ b/include/llvm/Analysis/CFLAliasAnalysis.h @@ -109,8 +109,8 @@ private: /// /// FIXME: We really should refactor CFL to use the analysis more heavily, and /// in particular to leverage invalidation to trigger re-computation of sets. -class CFLAA : public AnalysisBase { - friend AnalysisBase; +class CFLAA : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: diff --git a/include/llvm/Analysis/CGSCCPassManager.h b/include/llvm/Analysis/CGSCCPassManager.h index 4da08741a8a..d69ee3f4f19 100644 --- a/include/llvm/Analysis/CGSCCPassManager.h +++ b/include/llvm/Analysis/CGSCCPassManager.h @@ -65,7 +65,7 @@ typedef OuterAnalysisManagerProxy /// within this run safely. template class ModuleToPostOrderCGSCCPassAdaptor - : public PassBase> { + : public PassInfoMixin> { public: explicit ModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT Pass) : Pass(std::move(Pass)) {} @@ -159,7 +159,7 @@ typedef OuterAnalysisManagerProxy /// within this run safely. template class CGSCCToFunctionPassAdaptor - : public PassBase> { + : public PassInfoMixin> { public: explicit CGSCCToFunctionPassAdaptor(FunctionPassT Pass) : Pass(std::move(Pass)) {} diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index 45474f003cd..d4f9d25ed3e 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -295,8 +295,8 @@ private: /// This class implements the concept of an analysis pass used by the \c /// ModuleAnalysisManager to run an analysis over a module and cache the /// resulting data. -class CallGraphAnalysis : public AnalysisBase { - friend AnalysisBase; +class CallGraphAnalysis : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: @@ -310,7 +310,7 @@ public: }; /// \brief Printer pass for the \c CallGraphAnalysis results. -class CallGraphPrinterPass : public PassBase { +class CallGraphPrinterPass : public PassInfoMixin { raw_ostream &OS; public: diff --git a/include/llvm/Analysis/DominanceFrontier.h b/include/llvm/Analysis/DominanceFrontier.h index 197d3652d77..65940e92a1c 100644 --- a/include/llvm/Analysis/DominanceFrontier.h +++ b/include/llvm/Analysis/DominanceFrontier.h @@ -169,8 +169,8 @@ extern template class ForwardDominanceFrontierBase; /// \brief Analysis pass which computes a \c DominanceFrontier. class DominanceFrontierAnalysis - : public AnalysisBase { - friend AnalysisBase; + : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: @@ -183,7 +183,7 @@ public: /// \brief Printer pass for the \c DominanceFrontier. class DominanceFrontierPrinterPass - : public PassBase { + : public PassInfoMixin { raw_ostream &OS; public: diff --git a/include/llvm/Analysis/GlobalsModRef.h b/include/llvm/Analysis/GlobalsModRef.h index c8eea06b973..555b25d9afa 100644 --- a/include/llvm/Analysis/GlobalsModRef.h +++ b/include/llvm/Analysis/GlobalsModRef.h @@ -118,8 +118,8 @@ private: }; /// Analysis pass providing a never-invalidated alias analysis result. -class GlobalsAA : public AnalysisBase { - friend AnalysisBase; +class GlobalsAA : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: diff --git a/include/llvm/Analysis/LazyCallGraph.h b/include/llvm/Analysis/LazyCallGraph.h index 89f8cf2062c..d9047323a81 100644 --- a/include/llvm/Analysis/LazyCallGraph.h +++ b/include/llvm/Analysis/LazyCallGraph.h @@ -895,8 +895,8 @@ template <> struct GraphTraits { }; /// An analysis pass which computes the call graph for a module. -class LazyCallGraphAnalysis : public AnalysisBase { - friend AnalysisBase; +class LazyCallGraphAnalysis : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: @@ -913,7 +913,8 @@ public: /// A pass which prints the call graph to a \c raw_ostream. /// /// This is primarily useful for testing the analysis. -class LazyCallGraphPrinterPass : public PassBase { +class LazyCallGraphPrinterPass + : public PassInfoMixin { raw_ostream &OS; public: diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 2ea8d283f3a..de0e3a5b972 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -787,8 +787,8 @@ template <> struct GraphTraits { }; /// \brief Analysis pass that exposes the \c LoopInfo for a function. -class LoopAnalysis : public AnalysisBase { - friend AnalysisBase; +class LoopAnalysis : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: @@ -798,7 +798,7 @@ public: }; /// \brief Printer pass for the \c LoopAnalysis results. -class LoopPrinterPass : public PassBase { +class LoopPrinterPass : public PassInfoMixin { raw_ostream &OS; public: @@ -833,7 +833,7 @@ public: }; /// \brief Pass for printing a loop's contents as LLVM's text IR assembly. -class PrintLoopPass : public PassBase { +class PrintLoopPass : public PassInfoMixin { raw_ostream &OS; std::string Banner; diff --git a/include/llvm/Analysis/LoopPassManager.h b/include/llvm/Analysis/LoopPassManager.h index c3a6c4e3545..1b723c35df6 100644 --- a/include/llvm/Analysis/LoopPassManager.h +++ b/include/llvm/Analysis/LoopPassManager.h @@ -57,7 +57,7 @@ typedef OuterAnalysisManagerProxy /// LoopAnalysisManager to be used within this run safely. template class FunctionToLoopPassAdaptor - : public PassBase> { + : public PassInfoMixin> { public: explicit FunctionToLoopPassAdaptor(LoopPassT Pass) : Pass(std::move(Pass)) {} diff --git a/include/llvm/Analysis/MemoryDependenceAnalysis.h b/include/llvm/Analysis/MemoryDependenceAnalysis.h index b33765081d4..7c8bd2f5cdc 100644 --- a/include/llvm/Analysis/MemoryDependenceAnalysis.h +++ b/include/llvm/Analysis/MemoryDependenceAnalysis.h @@ -471,8 +471,9 @@ private: /// /// This is essentially a no-op because the results are computed entirely /// lazily. -class MemoryDependenceAnalysis : public AnalysisBase { - friend AnalysisBase; +class MemoryDependenceAnalysis + : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: diff --git a/include/llvm/Analysis/ObjCARCAliasAnalysis.h b/include/llvm/Analysis/ObjCARCAliasAnalysis.h index 0370b638de9..06a2ce77b6f 100644 --- a/include/llvm/Analysis/ObjCARCAliasAnalysis.h +++ b/include/llvm/Analysis/ObjCARCAliasAnalysis.h @@ -61,8 +61,8 @@ public: }; /// Analysis pass providing a never-invalidated alias analysis result. -class ObjCARCAA : public AnalysisBase { - friend AnalysisBase; +class ObjCARCAA : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: diff --git a/include/llvm/Analysis/PostDominators.h b/include/llvm/Analysis/PostDominators.h index 22d1b236de1..dd6e9d36436 100644 --- a/include/llvm/Analysis/PostDominators.h +++ b/include/llvm/Analysis/PostDominators.h @@ -38,8 +38,8 @@ struct PostDominatorTree : public DominatorTreeBase { /// \brief Analysis pass which computes a \c PostDominatorTree. class PostDominatorTreeAnalysis - : public AnalysisBase { - friend AnalysisBase; + : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: @@ -53,7 +53,7 @@ public: /// \brief Printer pass for the \c PostDominatorTree. class PostDominatorTreePrinterPass - : public PassBase { + : public PassInfoMixin { raw_ostream &OS; public: diff --git a/include/llvm/Analysis/RegionInfo.h b/include/llvm/Analysis/RegionInfo.h index 3b3a75cf446..c3cbc9e2fb3 100644 --- a/include/llvm/Analysis/RegionInfo.h +++ b/include/llvm/Analysis/RegionInfo.h @@ -923,8 +923,8 @@ public: }; /// \brief Analysis pass that exposes the \c RegionInfo for a function. -class RegionInfoAnalysis : public AnalysisBase { - friend AnalysisBase; +class RegionInfoAnalysis : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: @@ -934,7 +934,7 @@ public: }; /// \brief Printer pass for the \c RegionInfo. -class RegionInfoPrinterPass : public PassBase { +class RegionInfoPrinterPass : public PassInfoMixin { raw_ostream &OS; public: @@ -943,7 +943,7 @@ public: }; /// \brief Verifier pass for the \c RegionInfo. -struct RegionInfoVerifierPass : PassBase { +struct RegionInfoVerifierPass : PassInfoMixin { PreservedAnalyses run(Function &F, AnalysisManager *AM); }; diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index 7d68c425645..040b16d0dd8 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -1430,8 +1430,9 @@ namespace llvm { }; /// \brief Analysis pass that exposes the \c ScalarEvolution for a function. - class ScalarEvolutionAnalysis : public AnalysisBase { - friend AnalysisBase; + class ScalarEvolutionAnalysis + : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: @@ -1442,7 +1443,7 @@ namespace llvm { /// \brief Printer pass for the \c ScalarEvolutionAnalysis results. class ScalarEvolutionPrinterPass - : public PassBase { + : public PassInfoMixin { raw_ostream &OS; public: diff --git a/include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h b/include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h index 96ce5c61363..89e4a0035ca 100644 --- a/include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h +++ b/include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h @@ -38,8 +38,8 @@ private: }; /// Analysis pass providing a never-invalidated alias analysis result. -class SCEVAA : public AnalysisBase { - friend AnalysisBase; +class SCEVAA : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: diff --git a/include/llvm/Analysis/ScopedNoAliasAA.h b/include/llvm/Analysis/ScopedNoAliasAA.h index 08cb94b03ee..a5cba3f54b1 100644 --- a/include/llvm/Analysis/ScopedNoAliasAA.h +++ b/include/llvm/Analysis/ScopedNoAliasAA.h @@ -47,8 +47,8 @@ private: }; /// Analysis pass providing a never-invalidated alias analysis result. -class ScopedNoAliasAA : public AnalysisBase { - friend AnalysisBase; +class ScopedNoAliasAA : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h index d7d0878f541..bc4ac000e24 100644 --- a/include/llvm/Analysis/TargetLibraryInfo.h +++ b/include/llvm/Analysis/TargetLibraryInfo.h @@ -262,7 +262,7 @@ public: /// /// Note that this pass's result cannot be invalidated, it is immutable for the /// life of the module. -class TargetLibraryAnalysis : public AnalysisBase { +class TargetLibraryAnalysis : public AnalysisInfoMixin { public: typedef TargetLibraryInfo Result; @@ -292,7 +292,7 @@ public: TargetLibraryInfo run(Function &F); private: - friend AnalysisBase; + friend AnalysisInfoMixin; static char PassID; Optional PresetInfoImpl; diff --git a/include/llvm/Analysis/TargetTransformInfo.h b/include/llvm/Analysis/TargetTransformInfo.h index 78ea97a1b83..d8b5d116ba4 100644 --- a/include/llvm/Analysis/TargetTransformInfo.h +++ b/include/llvm/Analysis/TargetTransformInfo.h @@ -889,7 +889,7 @@ TargetTransformInfo::TargetTransformInfo(T Impl) /// is done in a subtarget specific way and LLVM supports compiling different /// functions targeting different subtargets in order to support runtime /// dispatch according to the observed subtarget. -class TargetIRAnalysis : public AnalysisBase { +class TargetIRAnalysis : public AnalysisInfoMixin { public: typedef TargetTransformInfo Result; @@ -922,7 +922,7 @@ public: Result run(const Function &F); private: - friend AnalysisBase; + friend AnalysisInfoMixin; static char PassID; /// \brief The callback used to produce a result. diff --git a/include/llvm/Analysis/TypeBasedAliasAnalysis.h b/include/llvm/Analysis/TypeBasedAliasAnalysis.h index 2480d948959..9b497504b22 100644 --- a/include/llvm/Analysis/TypeBasedAliasAnalysis.h +++ b/include/llvm/Analysis/TypeBasedAliasAnalysis.h @@ -48,8 +48,8 @@ private: }; /// Analysis pass providing a never-invalidated alias analysis result. -class TypeBasedAA : public AnalysisBase { - friend AnalysisBase; +class TypeBasedAA : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: diff --git a/include/llvm/IR/Dominators.h b/include/llvm/IR/Dominators.h index 1cb9202ae37..8efff1c0c46 100644 --- a/include/llvm/IR/Dominators.h +++ b/include/llvm/IR/Dominators.h @@ -182,8 +182,8 @@ template <> struct GraphTraits }; /// \brief Analysis pass which computes a \c DominatorTree. -class DominatorTreeAnalysis : public AnalysisBase { - friend AnalysisBase; +class DominatorTreeAnalysis : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: @@ -195,7 +195,8 @@ public: }; /// \brief Printer pass for the \c DominatorTree. -class DominatorTreePrinterPass : public PassBase { +class DominatorTreePrinterPass + : public PassInfoMixin { raw_ostream &OS; public: @@ -204,7 +205,7 @@ public: }; /// \brief Verifier pass for the \c DominatorTree. -struct DominatorTreeVerifierPass : PassBase { +struct DominatorTreeVerifierPass : PassInfoMixin { PreservedAnalyses run(Function &F, AnalysisManager *AM); }; diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index 02dfb65c9b8..6ed6a366867 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -167,10 +167,11 @@ private: // Forward declare the analysis manager template. template class AnalysisManager; -/// A CRTP mix-in base class to help define types that are valid passes. +/// A CRTP mix-in to automatically provide informational APIs needed for +/// passes. /// /// This provides some boiler plate for types that are passes. -template struct PassBase { +template struct PassInfoMixin { /// Returns the name of the derived pass type. static StringRef name() { StringRef Name = getTypeName(); @@ -180,10 +181,14 @@ template struct PassBase { } }; -/// A CRTP mix-in base class to help define types that are valid analyses. +/// A CRTP mix-in to automatically provide informational APIs needed for +/// analysis passes. /// -/// This provides some boiler plate for types that are analysis passes. -template struct AnalysisBase : PassBase { +/// This provides some boiler plate for types that are analysis passes. It +/// automatically mixes in \c PassInfoMixin and adds informational APIs +/// specifically used for analyses. +template +struct AnalysisInfoMixin : PassInfoMixin { /// Returns an opaque, unique ID for this pass type. /// /// Note that this requires the derived type provide a static member whose @@ -212,7 +217,7 @@ template struct AnalysisBase : PassBase { /// manager's invalidation routine with the PreservedAnalyses of each pass it /// runs. template -class PassManager : public PassBase> { +class PassManager : public PassInfoMixin> { public: /// \brief Construct a pass manager. /// @@ -663,7 +668,7 @@ typedef AnalysisManager FunctionAnalysisManager; /// provides. template class InnerAnalysisManagerProxy - : public AnalysisBase< + : public AnalysisInfoMixin< InnerAnalysisManagerProxy> { public: class Result { @@ -746,7 +751,8 @@ public: Result run(IRUnitT &IR) { return Result(*AM); } private: - friend AnalysisBase>; + friend AnalysisInfoMixin< + InnerAnalysisManagerProxy>; static char PassID; AnalysisManagerT *AM; @@ -775,7 +781,7 @@ typedef InnerAnalysisManagerProxy /// returned PreservedAnalysis set. template class OuterAnalysisManagerProxy - : public AnalysisBase< + : public AnalysisInfoMixin< OuterAnalysisManagerProxy> { public: /// \brief Result proxy object for \c OuterAnalysisManagerProxy. @@ -818,7 +824,8 @@ public: Result run(IRUnitT &) { return Result(*AM); } private: - friend AnalysisBase>; + friend AnalysisInfoMixin< + OuterAnalysisManagerProxy>; static char PassID; const AnalysisManagerT *AM; @@ -857,7 +864,7 @@ typedef OuterAnalysisManagerProxy /// violate this principle. template class ModuleToFunctionPassAdaptor - : public PassBase> { + : public PassInfoMixin> { public: explicit ModuleToFunctionPassAdaptor(FunctionPassT Pass) : Pass(std::move(Pass)) {} @@ -929,7 +936,7 @@ createModuleToFunctionPassAdaptor(FunctionPassT Pass) { /// This is a no-op pass which simply forces a specific analysis pass's result /// to be available when it is run. template -struct RequireAnalysisPass : PassBase> { +struct RequireAnalysisPass : PassInfoMixin> { /// \brief Run this pass over some unit of IR. /// /// This pass can be run over any unit of IR and use any analysis manager @@ -951,7 +958,8 @@ struct RequireAnalysisPass : PassBase> { /// This is a no-op pass which simply forces a specific analysis result to be /// invalidated when it is run. template -struct InvalidateAnalysisPass : PassBase> { +struct InvalidateAnalysisPass + : PassInfoMixin> { /// \brief Run this pass over some unit of IR. /// /// This pass can be run over any unit of IR and use any analysis manager @@ -973,7 +981,7 @@ struct InvalidateAnalysisPass : PassBase> { /// /// As a consequence fo not preserving any analyses, this pass will force all /// analysis passes to be re-run to produce fresh results if any are needed. -struct InvalidateAllAnalysesPass : PassBase { +struct InvalidateAllAnalysesPass : PassInfoMixin { /// \brief Run this pass over some unit of IR. template PreservedAnalyses run(IRUnitT &Arg) { return PreservedAnalyses::none(); diff --git a/include/llvm/IR/Verifier.h b/include/llvm/IR/Verifier.h index a0c75de116d..4b00b57532f 100644 --- a/include/llvm/IR/Verifier.h +++ b/include/llvm/IR/Verifier.h @@ -60,7 +60,7 @@ bool verifyModule(const Module &M, raw_ostream *OS = nullptr); /// nothing to do with \c VerifierPass. FunctionPass *createVerifierPass(bool FatalErrors = true); -class VerifierPass : public PassBase { +class VerifierPass : public PassInfoMixin { bool FatalErrors; public: diff --git a/include/llvm/Transforms/IPO/ForceFunctionAttrs.h b/include/llvm/Transforms/IPO/ForceFunctionAttrs.h index cf15f463186..5a6e9b36ef5 100644 --- a/include/llvm/Transforms/IPO/ForceFunctionAttrs.h +++ b/include/llvm/Transforms/IPO/ForceFunctionAttrs.h @@ -21,7 +21,7 @@ namespace llvm { /// Pass which forces specific function attributes into the IR, primarily as /// a debugging tool. -struct ForceFunctionAttrsPass : PassBase { +struct ForceFunctionAttrsPass : PassInfoMixin { PreservedAnalyses run(Module &M); }; diff --git a/include/llvm/Transforms/IPO/FunctionAttrs.h b/include/llvm/Transforms/IPO/FunctionAttrs.h index d4a1c3d56c7..aab7d8ba9f3 100644 --- a/include/llvm/Transforms/IPO/FunctionAttrs.h +++ b/include/llvm/Transforms/IPO/FunctionAttrs.h @@ -29,7 +29,7 @@ namespace llvm { /// access memory, or only read memory, and give them the readnone/readonly /// attribute. It also discovers function arguments that are not captured by /// the function and marks them with the nocapture attribute. -struct PostOrderFunctionAttrsPass : PassBase { +struct PostOrderFunctionAttrsPass : PassInfoMixin { PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager *AM); }; diff --git a/include/llvm/Transforms/IPO/InferFunctionAttrs.h b/include/llvm/Transforms/IPO/InferFunctionAttrs.h index ef69de8d512..a26205d5403 100644 --- a/include/llvm/Transforms/IPO/InferFunctionAttrs.h +++ b/include/llvm/Transforms/IPO/InferFunctionAttrs.h @@ -23,7 +23,7 @@ namespace llvm { /// A pass which infers function attributes from the names and signatures of /// function declarations in a module. -struct InferFunctionAttrsPass : PassBase { +struct InferFunctionAttrsPass : PassInfoMixin { PreservedAnalyses run(Module &M, AnalysisManager *AM); }; diff --git a/include/llvm/Transforms/IPO/StripDeadPrototypes.h b/include/llvm/Transforms/IPO/StripDeadPrototypes.h index 12cf00a8f08..3dad8aa0805 100644 --- a/include/llvm/Transforms/IPO/StripDeadPrototypes.h +++ b/include/llvm/Transforms/IPO/StripDeadPrototypes.h @@ -23,7 +23,7 @@ namespace llvm { /// Pass to remove unused function declarations. -struct StripDeadPrototypesPass : PassBase { +struct StripDeadPrototypesPass : PassInfoMixin { PreservedAnalyses run(Module &M); }; diff --git a/include/llvm/Transforms/InstCombine/InstCombine.h b/include/llvm/Transforms/InstCombine/InstCombine.h index 7f0d9365741..b03017fd8b6 100644 --- a/include/llvm/Transforms/InstCombine/InstCombine.h +++ b/include/llvm/Transforms/InstCombine/InstCombine.h @@ -24,7 +24,7 @@ namespace llvm { -class InstCombinePass : public PassBase { +class InstCombinePass : public PassInfoMixin { InstCombineWorklist Worklist; bool ExpensiveCombines; diff --git a/include/llvm/Transforms/Scalar/ADCE.h b/include/llvm/Transforms/Scalar/ADCE.h index a28e93dfdf9..0cd14bde97f 100644 --- a/include/llvm/Transforms/Scalar/ADCE.h +++ b/include/llvm/Transforms/Scalar/ADCE.h @@ -28,7 +28,7 @@ namespace llvm { /// instructions are dead until proven otherwise. This allows it to eliminate /// dead computations that other DCE passes do not catch, particularly involving /// loop computations. -struct ADCEPass : PassBase { +struct ADCEPass : PassInfoMixin { PreservedAnalyses run(Function &F); }; } diff --git a/include/llvm/Transforms/Scalar/EarlyCSE.h b/include/llvm/Transforms/Scalar/EarlyCSE.h index 24b02c86aaf..8d1dc321b35 100644 --- a/include/llvm/Transforms/Scalar/EarlyCSE.h +++ b/include/llvm/Transforms/Scalar/EarlyCSE.h @@ -26,7 +26,7 @@ namespace llvm { /// canonicalize things as it goes. It is intended to be fast and catch obvious /// cases so that instcombine and other passes are more effective. It is /// expected that a later pass of GVN will catch the interesting/hard cases. -struct EarlyCSEPass : PassBase { +struct EarlyCSEPass : PassInfoMixin { /// \brief Run the pass over the function. PreservedAnalyses run(Function &F, AnalysisManager *AM); }; diff --git a/include/llvm/Transforms/Scalar/GVN.h b/include/llvm/Transforms/Scalar/GVN.h index c6b86bfb7cd..342b3df1eb9 100644 --- a/include/llvm/Transforms/Scalar/GVN.h +++ b/include/llvm/Transforms/Scalar/GVN.h @@ -42,7 +42,7 @@ class GVNLegacyPass; /// /// FIXME: We should have a good summary of the GVN algorithm implemented by /// this particular pass here. -class GVN : public PassBase { +class GVN : public PassInfoMixin { public: /// \brief Run the pass over the function. diff --git a/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h b/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h index c78ae310d3e..d03e76f5152 100644 --- a/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h +++ b/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h @@ -21,7 +21,7 @@ namespace llvm { -struct LowerExpectIntrinsicPass : PassBase { +struct LowerExpectIntrinsicPass : PassInfoMixin { /// \brief Run the pass over the function. /// /// This will lower all of th expect intrinsic calls in this function into diff --git a/include/llvm/Transforms/Scalar/SROA.h b/include/llvm/Transforms/Scalar/SROA.h index c6fe735a291..9581cb7b5bf 100644 --- a/include/llvm/Transforms/Scalar/SROA.h +++ b/include/llvm/Transforms/Scalar/SROA.h @@ -51,7 +51,7 @@ class SROALegacyPass; /// onto insert and extract operations on a vector value, and convert them to /// this form. By doing so, it will enable promotion of vector aggregates to /// SSA vector values. -class SROA : public PassBase { +class SROA : public PassInfoMixin { LLVMContext *C; DominatorTree *DT; AssumptionCache *AC; diff --git a/include/llvm/Transforms/Scalar/SimplifyCFG.h b/include/llvm/Transforms/Scalar/SimplifyCFG.h index 6a102c5b7d8..514a86b95bd 100644 --- a/include/llvm/Transforms/Scalar/SimplifyCFG.h +++ b/include/llvm/Transforms/Scalar/SimplifyCFG.h @@ -25,7 +25,7 @@ namespace llvm { /// This pass iteratively simplifies the entire CFG of a function, removing /// unnecessary control flows and bringing it into the canonical form expected /// by the rest of the mid-level optimizer. -class SimplifyCFGPass : public PassBase { +class SimplifyCFGPass : public PassInfoMixin { int BonusInstThreshold; public: diff --git a/lib/Passes/PassBuilder.cpp b/lib/Passes/PassBuilder.cpp index e436966d320..ad6ce725c12 100644 --- a/lib/Passes/PassBuilder.cpp +++ b/lib/Passes/PassBuilder.cpp @@ -70,8 +70,8 @@ struct NoOpModulePass { }; /// \brief No-op module analysis. -class NoOpModuleAnalysis : public AnalysisBase { - friend AnalysisBase; +class NoOpModuleAnalysis : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: @@ -89,8 +89,8 @@ struct NoOpCGSCCPass { }; /// \brief No-op CGSCC analysis. -class NoOpCGSCCAnalysis : public AnalysisBase { - friend AnalysisBase; +class NoOpCGSCCAnalysis : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: @@ -106,8 +106,8 @@ struct NoOpFunctionPass { }; /// \brief No-op function analysis. -class NoOpFunctionAnalysis : public AnalysisBase { - friend AnalysisBase; +class NoOpFunctionAnalysis : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: @@ -123,8 +123,8 @@ struct NoOpLoopPass { }; /// \brief No-op loop analysis. -class NoOpLoopAnalysis : public AnalysisBase { - friend AnalysisBase; +class NoOpLoopAnalysis : public AnalysisInfoMixin { + friend AnalysisInfoMixin; static char PassID; public: diff --git a/unittests/IR/PassManagerTest.cpp b/unittests/IR/PassManagerTest.cpp index c00748cadb9..68218cc6d59 100644 --- a/unittests/IR/PassManagerTest.cpp +++ b/unittests/IR/PassManagerTest.cpp @@ -19,7 +19,7 @@ using namespace llvm; namespace { -class TestFunctionAnalysis : public AnalysisBase { +class TestFunctionAnalysis : public AnalysisInfoMixin { public: struct Result { Result(int Count) : InstructionCount(Count) {} @@ -40,7 +40,7 @@ public: } private: - friend AnalysisBase; + friend AnalysisInfoMixin; static char PassID; int &Runs; @@ -48,7 +48,7 @@ private: char TestFunctionAnalysis::PassID; -class TestModuleAnalysis : public AnalysisBase { +class TestModuleAnalysis : public AnalysisInfoMixin { public: struct Result { Result(int Count) : FunctionCount(Count) {} @@ -66,7 +66,7 @@ public: } private: - friend AnalysisBase; + friend AnalysisInfoMixin; static char PassID; int &Runs; @@ -74,7 +74,7 @@ private: char TestModuleAnalysis::PassID; -struct TestModulePass : PassBase { +struct TestModulePass : PassInfoMixin { TestModulePass(int &RunCount) : RunCount(RunCount) {} PreservedAnalyses run(Module &M) { @@ -85,11 +85,12 @@ struct TestModulePass : PassBase { int &RunCount; }; -struct TestPreservingModulePass : PassBase { +struct TestPreservingModulePass : PassInfoMixin { PreservedAnalyses run(Module &M) { return PreservedAnalyses::all(); } }; -struct TestMinPreservingModulePass : PassBase { +struct TestMinPreservingModulePass + : PassInfoMixin { PreservedAnalyses run(Module &M, ModuleAnalysisManager *AM) { PreservedAnalyses PA; @@ -101,7 +102,7 @@ struct TestMinPreservingModulePass : PassBase { } }; -struct TestFunctionPass : PassBase { +struct TestFunctionPass : PassInfoMixin { TestFunctionPass(int &RunCount, int &AnalyzedInstrCount, int &AnalyzedFunctionCount, bool OnlyUseCachedResults = false) @@ -140,7 +141,8 @@ struct TestFunctionPass : PassBase { // A test function pass that invalidates all function analyses for a function // with a specific name. -struct TestInvalidationFunctionPass : PassBase { +struct TestInvalidationFunctionPass + : PassInfoMixin { TestInvalidationFunctionPass(StringRef FunctionName) : Name(FunctionName) {} PreservedAnalyses run(Function &F) {