Index: include/llvm/Analysis/AliasAnalysis.h =================================================================== --- include/llvm/Analysis/AliasAnalysis.h +++ include/llvm/Analysis/AliasAnalysis.h @@ -878,7 +878,7 @@ ResultGetters.push_back(&getModuleAAResultImpl); } - Result run(Function &F, AnalysisManager &AM) { + Result run(Function &F, AnalysisManager &AM) { Result R(AM.getResult(F)); for (auto &Getter : ResultGetters) (*Getter)(F, AM, R); @@ -889,23 +889,20 @@ friend AnalysisInfoMixin; static char PassID; - SmallVector &AM, - AAResults &AAResults), - 4> ResultGetters; + SmallVector + ResultGetters; template - static void getFunctionAAResultImpl(Function &F, - AnalysisManager &AM, + static void getFunctionAAResultImpl(Function &F, AnalysisManager &AM, AAResults &AAResults) { AAResults.addAAResult(AM.template getResult(F)); } template - static void getModuleAAResultImpl(Function &F, AnalysisManager &AM, + static void getModuleAAResultImpl(Function &F, AnalysisManager &AM, AAResults &AAResults) { - auto &MAM = - AM.getResult(F).getManager(); - if (auto *R = MAM.template getCachedResult(*F.getParent())) + if (auto *R = AM.template getCachedResult(*F.getParent())) AAResults.addAAResult(*R); } }; Index: include/llvm/Analysis/AliasAnalysisEvaluator.h =================================================================== --- include/llvm/Analysis/AliasAnalysisEvaluator.h +++ include/llvm/Analysis/AliasAnalysisEvaluator.h @@ -53,7 +53,7 @@ ~AAEvaluator(); /// \brief Run the pass over the function. - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); private: // Allow the legacy pass to run this using an internal API. Index: include/llvm/Analysis/AssumptionCache.h =================================================================== --- include/llvm/Analysis/AssumptionCache.h +++ include/llvm/Analysis/AssumptionCache.h @@ -106,7 +106,7 @@ AssumptionAnalysis &operator=(const AssumptionAnalysis &RHS) { return *this; } AssumptionAnalysis &operator=(AssumptionAnalysis &&RHS) { return *this; } - AssumptionCache run(Function &F, FunctionAnalysisManager &) { + AssumptionCache run(Function &F, AnalysisManager &) { return AssumptionCache(F); } }; @@ -117,7 +117,7 @@ public: explicit AssumptionPrinterPass(raw_ostream &OS) : OS(OS) {} - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; /// \brief An immutable pass that tracks lazily created \c AssumptionCache Index: include/llvm/Analysis/BasicAliasAnalysis.h =================================================================== --- include/llvm/Analysis/BasicAliasAnalysis.h +++ include/llvm/Analysis/BasicAliasAnalysis.h @@ -198,7 +198,7 @@ public: typedef BasicAAResult Result; - BasicAAResult run(Function &F, AnalysisManager &AM); + BasicAAResult run(Function &F, AnalysisManager &AM); }; /// Legacy wrapper pass to provide the BasicAAResult object. Index: include/llvm/Analysis/BlockFrequencyInfo.h =================================================================== --- include/llvm/Analysis/BlockFrequencyInfo.h +++ include/llvm/Analysis/BlockFrequencyInfo.h @@ -97,7 +97,7 @@ typedef BlockFrequencyInfo Result; /// \brief Run the analysis pass over a function and produce BFI. - Result run(Function &F, AnalysisManager &AM); + Result run(Function &F, AnalysisManager &AM); }; /// \brief Printer pass for the \c BlockFrequencyInfo results. @@ -107,7 +107,7 @@ public: explicit BlockFrequencyPrinterPass(raw_ostream &OS) : OS(OS) {} - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; /// \brief Legacy analysis pass which computes \c BlockFrequencyInfo. Index: include/llvm/Analysis/BranchProbabilityInfo.h =================================================================== --- include/llvm/Analysis/BranchProbabilityInfo.h +++ include/llvm/Analysis/BranchProbabilityInfo.h @@ -185,7 +185,7 @@ typedef BranchProbabilityInfo Result; /// \brief Run the analysis pass over a function and produce BPI. - BranchProbabilityInfo run(Function &F, AnalysisManager &AM); + BranchProbabilityInfo run(Function &F, AnalysisManager &AM); }; /// \brief Printer pass for the \c BranchProbabilityAnalysis results. @@ -195,7 +195,7 @@ public: explicit BranchProbabilityPrinterPass(raw_ostream &OS) : OS(OS) {} - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; /// \brief Legacy analysis pass which computes \c BranchProbabilityInfo. Index: include/llvm/Analysis/CFLAndersAliasAnalysis.h =================================================================== --- include/llvm/Analysis/CFLAndersAliasAnalysis.h +++ include/llvm/Analysis/CFLAndersAliasAnalysis.h @@ -108,7 +108,7 @@ public: typedef CFLAndersAAResult Result; - CFLAndersAAResult run(Function &F, AnalysisManager &AM); + CFLAndersAAResult run(Function &F, AnalysisManager &AM); }; /// Legacy wrapper pass to provide the CFLAndersAAResult object. Index: include/llvm/Analysis/CFLSteensAliasAnalysis.h =================================================================== --- include/llvm/Analysis/CFLSteensAliasAnalysis.h +++ include/llvm/Analysis/CFLSteensAliasAnalysis.h @@ -127,7 +127,7 @@ public: typedef CFLSteensAAResult Result; - CFLSteensAAResult run(Function &F, AnalysisManager &AM); + CFLSteensAAResult run(Function &F, AnalysisManager &AM); }; /// Legacy wrapper pass to provide the CFLSteensAAResult object. Index: include/llvm/Analysis/CGSCCPassManager.h =================================================================== --- include/llvm/Analysis/CGSCCPassManager.h +++ include/llvm/Analysis/CGSCCPassManager.h @@ -34,35 +34,11 @@ /// typedef serves as a convenient way to refer to this construct. typedef PassManager CGSCCPassManager; -extern template class AnalysisManager; -/// \brief The CGSCC analysis manager. -/// -/// See the documentation for the AnalysisManager template for detail -/// documentation. This typedef serves as a convenient way to refer to this -/// construct in the adaptors and proxies used to integrate this into the larger -/// pass manager infrastructure. -typedef AnalysisManager CGSCCAnalysisManager; - -extern template class InnerAnalysisManagerProxy; -/// A proxy from a \c CGSCCAnalysisManager to a \c Module. -typedef InnerAnalysisManagerProxy - CGSCCAnalysisManagerModuleProxy; - -extern template class OuterAnalysisManagerProxy; -/// A proxy from a \c ModuleAnalysisManager to an \c SCC. -typedef OuterAnalysisManagerProxy - ModuleAnalysisManagerCGSCCProxy; - /// \brief The core module pass which does a post-order walk of the SCCs and /// runs a CGSCC pass over each one. /// /// Designed to allow composition of a CGSCCPass(Manager) and -/// a ModulePassManager. Note that this pass must be run with a module analysis -/// manager as it uses the LazyCallGraph analysis. It will also run the -/// \c CGSCCAnalysisManagerModuleProxy analysis prior to running the CGSCC -/// pass over the module to enable a \c FunctionAnalysisManager to be used -/// within this run safely. +/// a ModulePassManager. template class ModuleToPostOrderCGSCCPassAdaptor : public PassInfoMixin> { @@ -89,11 +65,7 @@ } /// \brief Runs the CGSCC pass across every SCC in the module. - PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM) { - // Setup the CGSCC analysis manager from its proxy. - CGSCCAnalysisManager &CGAM = - AM.getResult(M).getManager(); - + PreservedAnalyses run(Module &M, AnalysisManager &AM) { // Get the call graph for this module. LazyCallGraph &CG = AM.getResult(M); @@ -103,7 +75,7 @@ dbgs() << "Running an SCC pass across the RefSCC: " << RC << "\n"; for (LazyCallGraph::SCC &C : RC) { - PreservedAnalyses PassPA = Pass.run(C, CGAM); + PreservedAnalyses PassPA = Pass.run(C, AM); // We know that the CGSCC pass couldn't have invalidated any other // SCC's analyses (that's the contract of a CGSCC pass), so @@ -113,7 +85,7 @@ // FIXME: This isn't quite correct. We need to handle the case where the // pass updated the CG, particularly some child of the current SCC, and // invalidate its analyses. - PassPA = CGAM.invalidate(C, std::move(PassPA)); + PassPA = AM.invalidate(C, std::move(PassPA)); // Then intersect the preserved set so that invalidation of module // analyses will eventually occur when the module pass completes. @@ -121,11 +93,6 @@ } } - // By definition we preserve the proxy. This precludes *any* invalidation - // of CGSCC analyses by the proxy, but that's OK because we've taken - // care to invalidate analyses in the CGSCC analysis manager - // incrementally above. - PA.preserve(); return PA; } @@ -142,25 +109,10 @@ return ModuleToPostOrderCGSCCPassAdaptor(std::move(Pass), DebugLogging); } -extern template class InnerAnalysisManagerProxy; -/// A proxy from a \c FunctionAnalysisManager to an \c SCC. -typedef InnerAnalysisManagerProxy - FunctionAnalysisManagerCGSCCProxy; - -extern template class OuterAnalysisManagerProxy; -/// A proxy from a \c CGSCCAnalysisManager to a \c Function. -typedef OuterAnalysisManagerProxy - CGSCCAnalysisManagerFunctionProxy; - /// \brief Adaptor that maps from a SCC to its functions. /// /// Designed to allow composition of a FunctionPass(Manager) and -/// a CGSCCPassManager. Note that if this pass is constructed with a pointer -/// to a \c CGSCCAnalysisManager it will run the -/// \c FunctionAnalysisManagerCGSCCProxy analysis prior to running the function -/// pass over the SCC to enable a \c FunctionAnalysisManager to be used -/// within this run safely. +/// a CGSCCPassManager. template class CGSCCToFunctionPassAdaptor : public PassInfoMixin> { @@ -185,37 +137,28 @@ } /// \brief Runs the function pass across every function in the module. - PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM) { - // Setup the function analysis manager from its proxy. - FunctionAnalysisManager &FAM = - AM.getResult(C).getManager(); - + PreservedAnalyses run(LazyCallGraph::SCC &C, AnalysisManager &AM) { if (DebugLogging) dbgs() << "Running function passes across an SCC: " << C << "\n"; PreservedAnalyses PA = PreservedAnalyses::all(); for (LazyCallGraph::Node &N : C) { - PreservedAnalyses PassPA = Pass.run(N.getFunction(), FAM); + PreservedAnalyses PassPA = Pass.run(N.getFunction(), AM); // We know that the function pass couldn't have invalidated any other // function's analyses (that's the contract of a function pass), so // directly handle the function analysis manager's invalidation here. // Also, update the preserved analyses to reflect that once invalidated // these can again be preserved. - PassPA = FAM.invalidate(N.getFunction(), std::move(PassPA)); + PassPA = AM.invalidate(N.getFunction(), std::move(PassPA)); // Then intersect the preserved set so that invalidation of module // analyses will eventually occur when the module pass completes. PA.intersect(std::move(PassPA)); } - // By definition we preserve the proxy. This precludes *any* invalidation - // of function analyses by the proxy, but that's OK because we've taken - // care to invalidate analyses in the function analysis manager - // incrementally above. // FIXME: We need to update the call graph here to account for any deleted // edges! - PA.preserve(); return PA; } @@ -224,6 +167,15 @@ bool DebugLogging; }; +static inline IRUnitKind getIRUnitKindID(LazyCallGraph::SCC *) { + return IRK_CGSCC; +} +static inline Module *getStaticParentIRUnit(LazyCallGraph::SCC &C) { + assert(C.size() != 0 && "Empty SCC?"); + return C.begin()->getFunction().getParent(); +} +extern template struct ParentIRUnitTrackingAnalysis; + /// \brief A function to deduce a function pass type and wrap it in the /// templated adaptor. template Index: include/llvm/Analysis/CallGraph.h =================================================================== --- include/llvm/Analysis/CallGraph.h +++ include/llvm/Analysis/CallGraph.h @@ -291,10 +291,6 @@ }; /// \brief An analysis pass to compute the \c CallGraph for a \c Module. -/// -/// 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 AnalysisInfoMixin { friend AnalysisInfoMixin; static char PassID; @@ -306,7 +302,7 @@ /// \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, ModuleAnalysisManager &) { return CallGraph(M); } + CallGraph run(Module &M, AnalysisManager &) { return CallGraph(M); } }; /// \brief Printer pass for the \c CallGraphAnalysis results. @@ -315,7 +311,7 @@ public: explicit CallGraphPrinterPass(raw_ostream &OS) : OS(OS) {} - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); }; /// \brief The \c ModulePass which wraps up a \c CallGraph and the logic to Index: include/llvm/Analysis/DemandedBits.h =================================================================== --- include/llvm/Analysis/DemandedBits.h +++ include/llvm/Analysis/DemandedBits.h @@ -97,7 +97,7 @@ /// \brief Run the analysis pass over a function and produce demanded bits /// information. - DemandedBits run(Function &F, AnalysisManager &AM); + DemandedBits run(Function &F, AnalysisManager &AM); }; /// \brief Printer pass for DemandedBits @@ -106,7 +106,7 @@ public: explicit DemandedBitsPrinterPass(raw_ostream &OS) : OS(OS) {} - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; /// Create a demanded bits analysis pass. Index: include/llvm/Analysis/DependenceAnalysis.h =================================================================== --- include/llvm/Analysis/DependenceAnalysis.h +++ include/llvm/Analysis/DependenceAnalysis.h @@ -928,7 +928,7 @@ class DependenceAnalysis : public AnalysisInfoMixin { public: typedef DependenceInfo Result; - Result run(Function &F, FunctionAnalysisManager &FAM); + Result run(Function &F, AnalysisManager &AM); private: static char PassID; Index: include/llvm/Analysis/DominanceFrontier.h =================================================================== --- include/llvm/Analysis/DominanceFrontier.h +++ include/llvm/Analysis/DominanceFrontier.h @@ -178,7 +178,7 @@ typedef DominanceFrontier Result; /// \brief Run the analysis pass over a function and produce a dominator tree. - DominanceFrontier run(Function &F, AnalysisManager &AM); + DominanceFrontier run(Function &F, AnalysisManager &AM); }; /// \brief Printer pass for the \c DominanceFrontier. @@ -188,7 +188,7 @@ public: explicit DominanceFrontierPrinterPass(raw_ostream &OS); - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } // End llvm namespace Index: include/llvm/Analysis/GlobalsModRef.h =================================================================== --- include/llvm/Analysis/GlobalsModRef.h +++ include/llvm/Analysis/GlobalsModRef.h @@ -125,7 +125,7 @@ public: typedef GlobalsAAResult Result; - GlobalsAAResult run(Module &M, AnalysisManager &AM); + GlobalsAAResult run(Module &M, AnalysisManager &AM); }; /// Legacy wrapper pass to provide the GlobalsAAResult object. Index: include/llvm/Analysis/IVUsers.h =================================================================== --- include/llvm/Analysis/IVUsers.h +++ include/llvm/Analysis/IVUsers.h @@ -208,7 +208,7 @@ public: typedef IVUsers Result; - IVUsers run(Loop &L, AnalysisManager &AM); + IVUsers run(Loop &L, AnalysisManager &AM); }; /// Printer pass for the \c IVUsers for a loop. @@ -217,7 +217,7 @@ public: explicit IVUsersPrinterPass(raw_ostream &OS) : OS(OS) {} - PreservedAnalyses run(Loop &L, AnalysisManager &AM); + PreservedAnalyses run(Loop &L, AnalysisManager &AM); }; } Index: include/llvm/Analysis/LazyCallGraph.h =================================================================== --- include/llvm/Analysis/LazyCallGraph.h +++ include/llvm/Analysis/LazyCallGraph.h @@ -982,7 +982,7 @@ /// /// 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, ModuleAnalysisManager &) { + LazyCallGraph run(Module &M, AnalysisManager &) { return LazyCallGraph(M); } }; @@ -997,7 +997,7 @@ public: explicit LazyCallGraphPrinterPass(raw_ostream &OS); - PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); }; /// A pass which prints the call graph as a DOT file to a \c raw_ostream. @@ -1010,7 +1010,7 @@ public: explicit LazyCallGraphDOTPrinterPass(raw_ostream &OS); - PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); }; } Index: include/llvm/Analysis/LazyValueInfo.h =================================================================== --- include/llvm/Analysis/LazyValueInfo.h +++ include/llvm/Analysis/LazyValueInfo.h @@ -106,7 +106,7 @@ class LazyValueAnalysis : public AnalysisInfoMixin { public: typedef LazyValueInfo Result; - Result run(Function &F, FunctionAnalysisManager &FAM); + Result run(Function &F, AnalysisManager &AM); private: static char PassID; Index: include/llvm/Analysis/LoopAccessAnalysis.h =================================================================== --- include/llvm/Analysis/LoopAccessAnalysis.h +++ include/llvm/Analysis/LoopAccessAnalysis.h @@ -775,7 +775,7 @@ public: typedef LoopAccessInfo Result; - Result run(Loop &, AnalysisManager &); + Result run(Loop &, AnalysisManager &); static StringRef name() { return "LoopAccessAnalysis"; } }; @@ -786,7 +786,7 @@ public: explicit LoopAccessInfoPrinterPass(raw_ostream &OS) : OS(OS) {} - PreservedAnalyses run(Loop &L, AnalysisManager &AM); + PreservedAnalyses run(Loop &L, AnalysisManager &AM); }; inline Instruction *MemoryDepChecker::Dependence::getSource( Index: include/llvm/Analysis/LoopInfo.h =================================================================== --- include/llvm/Analysis/LoopInfo.h +++ include/llvm/Analysis/LoopInfo.h @@ -794,7 +794,7 @@ public: typedef LoopInfo Result; - LoopInfo run(Function &F, AnalysisManager &AM); + LoopInfo run(Function &F, AnalysisManager &AM); }; /// \brief Printer pass for the \c LoopAnalysis results. @@ -803,12 +803,12 @@ public: explicit LoopPrinterPass(raw_ostream &OS) : OS(OS) {} - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; /// \brief Verifier pass for the \c LoopAnalysis results. struct LoopVerifierPass : public PassInfoMixin { - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; /// \brief The legacy pass manager's analysis pass to compute loop information. @@ -846,7 +846,7 @@ PrintLoopPass(); PrintLoopPass(raw_ostream &OS, const std::string &Banner = ""); - PreservedAnalyses run(Loop &L, AnalysisManager &); + PreservedAnalyses run(Loop &L, AnalysisManager &); }; } // End llvm namespace Index: include/llvm/Analysis/LoopPassManager.h =================================================================== --- include/llvm/Analysis/LoopPassManager.h +++ include/llvm/Analysis/LoopPassManager.h @@ -29,35 +29,13 @@ /// typedef serves as a convenient way to refer to this construct. typedef PassManager LoopPassManager; -extern template class AnalysisManager; -/// \brief The loop analysis manager. -/// -/// See the documentation for the AnalysisManager template for detail -/// documentation. This typedef serves as a convenient way to refer to this -/// construct in the adaptors and proxies used to integrate this into the larger -/// pass manager infrastructure. -typedef AnalysisManager LoopAnalysisManager; - -extern template class InnerAnalysisManagerProxy; -/// A proxy from a \c LoopAnalysisManager to a \c Function. -typedef InnerAnalysisManagerProxy - LoopAnalysisManagerFunctionProxy; - -extern template class OuterAnalysisManagerProxy; -/// A proxy from a \c FunctionAnalysisManager to a \c Loop. -typedef OuterAnalysisManagerProxy - FunctionAnalysisManagerLoopProxy; - /// Returns the minimum set of Analyses that all loop passes must preserve. PreservedAnalyses getLoopPassPreservedAnalyses(); /// \brief Adaptor that maps from a function to its loops. /// /// Designed to allow composition of a LoopPass(Manager) and a -/// FunctionPassManager. Note that if this pass is constructed with a \c -/// FunctionAnalysisManager it will run the \c LoopAnalysisManagerFunctionProxy -/// analysis prior to running the loop passes over the function to enable a \c -/// LoopAnalysisManager to be used within this run safely. +/// FunctionPassManager. template class FunctionToLoopPassAdaptor : public PassInfoMixin> { @@ -81,10 +59,7 @@ } /// \brief Runs the loop passes across every loop in the function. - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) { - // Setup the loop analysis manager from its proxy. - LoopAnalysisManager &LAM = - AM.getResult(F).getManager(); + PreservedAnalyses run(Function &F, AnalysisManager &AM) { // Get the loop structure for this function LoopInfo &LI = AM.getResult(F); @@ -103,7 +78,7 @@ // Now pop each element off of the stack to visit the loops in reverse // post-order. for (auto *L : reverse(Loops)) { - PreservedAnalyses PassPA = Pass.run(*L, LAM); + PreservedAnalyses PassPA = Pass.run(*L, AM); assert(PassPA.preserved(getLoopPassPreservedAnalyses()) && "Loop passes must preserve all relevant analyses"); @@ -112,17 +87,12 @@ // loop analysis manager's invalidation here. Also, update the // preserved analyses to reflect that once invalidated these can again // be preserved. - PassPA = LAM.invalidate(*L, std::move(PassPA)); + PassPA = AM.invalidate(*L, std::move(PassPA)); // Then intersect the preserved set so that invalidation of module // analyses will eventually occur when the module pass completes. PA.intersect(std::move(PassPA)); } - - // By definition we preserve the proxy. This precludes *any* invalidation of - // loop analyses by the proxy, but that's OK because we've taken care to - // invalidate analyses in the loop analysis manager incrementally above. - PA.preserve(); return PA; } @@ -130,6 +100,12 @@ LoopPassT Pass; }; +static inline IRUnitKind getIRUnitKindID(Loop *) { return IRK_Loop; } +static inline Function *getStaticParentIRUnit(Loop &L) { + return L.getHeader()->getParent(); +} +extern template struct ParentIRUnitTrackingAnalysis; + /// \brief A function to deduce a loop pass type and wrap it in the templated /// adaptor. template Index: include/llvm/Analysis/MemoryDependenceAnalysis.h =================================================================== --- include/llvm/Analysis/MemoryDependenceAnalysis.h +++ include/llvm/Analysis/MemoryDependenceAnalysis.h @@ -479,7 +479,7 @@ public: typedef MemoryDependenceResults Result; - MemoryDependenceResults run(Function &F, AnalysisManager &AM); + MemoryDependenceResults run(Function &F, AnalysisManager &AM); }; /// A wrapper analysis pass for the legacy pass manager that exposes a \c Index: include/llvm/Analysis/ObjCARCAliasAnalysis.h =================================================================== --- include/llvm/Analysis/ObjCARCAliasAnalysis.h +++ include/llvm/Analysis/ObjCARCAliasAnalysis.h @@ -68,7 +68,7 @@ public: typedef ObjCARCAAResult Result; - ObjCARCAAResult run(Function &F, AnalysisManager &AM); + ObjCARCAAResult run(Function &F, AnalysisManager &AM); }; /// Legacy wrapper pass to provide the ObjCARCAAResult object. Index: include/llvm/Analysis/OptimizationDiagnosticInfo.h =================================================================== --- include/llvm/Analysis/OptimizationDiagnosticInfo.h +++ include/llvm/Analysis/OptimizationDiagnosticInfo.h @@ -183,7 +183,7 @@ typedef OptimizationRemarkEmitter Result; /// \brief Run the analysis pass over a function and produce BFI. - Result run(Function &F, AnalysisManager &AM); + Result run(Function &F, AnalysisManager &AM); }; } #endif // LLVM_IR_OPTIMIZATIONDIAGNOSTICINFO_H Index: include/llvm/Analysis/PostDominators.h =================================================================== --- include/llvm/Analysis/PostDominators.h +++ include/llvm/Analysis/PostDominators.h @@ -48,7 +48,7 @@ /// \brief Run the analysis pass over a function and produce a post dominator /// tree. - PostDominatorTree run(Function &F, FunctionAnalysisManager &); + PostDominatorTree run(Function &F, AnalysisManager &); }; /// \brief Printer pass for the \c PostDominatorTree. @@ -58,7 +58,7 @@ public: explicit PostDominatorTreePrinterPass(raw_ostream &OS); - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; struct PostDominatorTreeWrapperPass : public FunctionPass { Index: include/llvm/Analysis/ProfileSummaryInfo.h =================================================================== --- include/llvm/Analysis/ProfileSummaryInfo.h +++ include/llvm/Analysis/ProfileSummaryInfo.h @@ -91,7 +91,7 @@ return *this; } - Result run(Module &M, ModuleAnalysisManager &); + Result run(Module &M, AnalysisManager &); private: friend AnalysisInfoMixin; @@ -105,7 +105,7 @@ public: explicit ProfileSummaryPrinterPass(raw_ostream &OS) : OS(OS) {} - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); }; } // end namespace llvm Index: include/llvm/Analysis/RegionInfo.h =================================================================== --- include/llvm/Analysis/RegionInfo.h +++ include/llvm/Analysis/RegionInfo.h @@ -937,7 +937,7 @@ public: typedef RegionInfo Result; - RegionInfo run(Function &F, AnalysisManager &AM); + RegionInfo run(Function &F, AnalysisManager &AM); }; /// \brief Printer pass for the \c RegionInfo. @@ -946,12 +946,12 @@ public: explicit RegionInfoPrinterPass(raw_ostream &OS); - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; /// \brief Verifier pass for the \c RegionInfo. struct RegionInfoVerifierPass : PassInfoMixin { - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; template <> Index: include/llvm/Analysis/ScalarEvolution.h =================================================================== --- include/llvm/Analysis/ScalarEvolution.h +++ include/llvm/Analysis/ScalarEvolution.h @@ -1681,7 +1681,7 @@ public: typedef ScalarEvolution Result; - ScalarEvolution run(Function &F, AnalysisManager &AM); + ScalarEvolution run(Function &F, AnalysisManager &AM); }; /// Printer pass for the \c ScalarEvolutionAnalysis results. @@ -1691,7 +1691,7 @@ public: explicit ScalarEvolutionPrinterPass(raw_ostream &OS) : OS(OS) {} - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; class ScalarEvolutionWrapperPass : public FunctionPass { Index: include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h =================================================================== --- include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h +++ include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h @@ -45,7 +45,7 @@ public: typedef SCEVAAResult Result; - SCEVAAResult run(Function &F, AnalysisManager &AM); + SCEVAAResult run(Function &F, AnalysisManager &AM); }; /// Legacy wrapper pass to provide the SCEVAAResult object. Index: include/llvm/Analysis/ScopedNoAliasAA.h =================================================================== --- include/llvm/Analysis/ScopedNoAliasAA.h +++ include/llvm/Analysis/ScopedNoAliasAA.h @@ -54,7 +54,7 @@ public: typedef ScopedNoAliasAAResult Result; - ScopedNoAliasAAResult run(Function &F, AnalysisManager &AM); + ScopedNoAliasAAResult run(Function &F, AnalysisManager &AM); }; /// Legacy wrapper pass to provide the ScopedNoAliasAAResult object. Index: include/llvm/Analysis/TargetLibraryInfo.h =================================================================== --- include/llvm/Analysis/TargetLibraryInfo.h +++ include/llvm/Analysis/TargetLibraryInfo.h @@ -306,8 +306,8 @@ return *this; } - TargetLibraryInfo run(Module &M, ModuleAnalysisManager &); - TargetLibraryInfo run(Function &F, FunctionAnalysisManager &); + TargetLibraryInfo run(Module &M, AnalysisManager &); + TargetLibraryInfo run(Function &F, AnalysisManager &); private: friend AnalysisInfoMixin; Index: include/llvm/Analysis/TargetTransformInfo.h =================================================================== --- include/llvm/Analysis/TargetTransformInfo.h +++ include/llvm/Analysis/TargetTransformInfo.h @@ -1028,7 +1028,7 @@ return *this; } - Result run(const Function &F, AnalysisManager &); + Result run(const Function &F, AnalysisManager &); private: friend AnalysisInfoMixin; Index: include/llvm/Analysis/TypeBasedAliasAnalysis.h =================================================================== --- include/llvm/Analysis/TypeBasedAliasAnalysis.h +++ include/llvm/Analysis/TypeBasedAliasAnalysis.h @@ -55,7 +55,7 @@ public: typedef TypeBasedAAResult Result; - TypeBasedAAResult run(Function &F, AnalysisManager &AM); + TypeBasedAAResult run(Function &F, AnalysisManager &AM); }; /// Legacy wrapper pass to provide the TypeBasedAAResult object. Index: include/llvm/Bitcode/BitcodeWriterPass.h =================================================================== --- include/llvm/Bitcode/BitcodeWriterPass.h +++ include/llvm/Bitcode/BitcodeWriterPass.h @@ -67,7 +67,7 @@ /// \brief Run the bitcode writer pass, and output the module to the selected /// output stream. - PreservedAnalyses run(Module &M, ModuleAnalysisManager &); + PreservedAnalyses run(Module &M, AnalysisManager &); static StringRef name() { return "BitcodeWriterPass"; } }; Index: include/llvm/CodeGen/PreISelIntrinsicLowering.h =================================================================== --- include/llvm/CodeGen/PreISelIntrinsicLowering.h +++ include/llvm/CodeGen/PreISelIntrinsicLowering.h @@ -19,7 +19,7 @@ struct PreISelIntrinsicLoweringPass : PassInfoMixin { - PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); }; } Index: include/llvm/CodeGen/UnreachableBlockElim.h =================================================================== --- include/llvm/CodeGen/UnreachableBlockElim.h +++ include/llvm/CodeGen/UnreachableBlockElim.h @@ -30,7 +30,7 @@ class UnreachableBlockElimPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } // end namespace llvm Index: include/llvm/IR/Dominators.h =================================================================== --- include/llvm/IR/Dominators.h +++ include/llvm/IR/Dominators.h @@ -208,7 +208,7 @@ typedef DominatorTree Result; /// \brief Run the analysis pass over a function and produce a dominator tree. - DominatorTree run(Function &F, AnalysisManager &); + DominatorTree run(Function &F, AnalysisManager &); }; /// \brief Printer pass for the \c DominatorTree. @@ -218,12 +218,12 @@ public: explicit DominatorTreePrinterPass(raw_ostream &OS); - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; /// \brief Verifier pass for the \c DominatorTree. struct DominatorTreeVerifierPass : PassInfoMixin { - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; /// \brief Legacy analysis pass which computes a \c DominatorTree. Index: include/llvm/IR/IRPrintingPasses.h =================================================================== --- include/llvm/IR/IRPrintingPasses.h +++ include/llvm/IR/IRPrintingPasses.h @@ -30,7 +30,7 @@ class ModulePass; class PreservedAnalyses; class raw_ostream; -template class AnalysisManager; +class AnalysisManager; /// \brief Create and return a pass that writes the module to the specified /// \c raw_ostream. @@ -68,7 +68,7 @@ PrintModulePass(raw_ostream &OS, const std::string &Banner = "", bool ShouldPreserveUseListOrder = false); - PreservedAnalyses run(Module &M, AnalysisManager &); + PreservedAnalyses run(Module &M, AnalysisManager &); static StringRef name() { return "PrintModulePass"; } }; @@ -85,7 +85,7 @@ PrintFunctionPass(); PrintFunctionPass(raw_ostream &OS, const std::string &Banner = ""); - PreservedAnalyses run(Function &F, AnalysisManager &); + PreservedAnalyses run(Function &F, AnalysisManager &); static StringRef name() { return "PrintFunctionPass"; } }; Index: include/llvm/IR/PassManager.h =================================================================== --- include/llvm/IR/PassManager.h +++ include/llvm/IR/PassManager.h @@ -170,8 +170,31 @@ SmallPtrSet PreservedPassIDs; }; -// Forward declare the analysis manager template. -template class AnalysisManager; +// The key used for holding analyses registered in the analysis manager. +struct AnalysisKey { + void *AnalysisID; + IRUnitKind IRUnitKindID; +}; + +static inline IRUnitKind getIRUnitKindID(Function *) { return IRK_Function; } +static inline IRUnitKind getIRUnitKindID(Module *) { return IRK_Module; } +static inline Module *getStaticParentIRUnit(Function &F) { return F.getParent(); } +static inline Module *getStaticParentIRUnit(Module &M) { return nullptr; } + +// Provide DenseMapInfo for AnalysisKey +template <> struct DenseMapInfo { + static inline AnalysisKey getEmptyKey() { return {nullptr, IRK_Module}; } + static inline AnalysisKey getTombstoneKey() { + return {nullptr, IRK_Function}; + } + static unsigned getHashValue(const AnalysisKey &Val) { + return hash_combine(Val.AnalysisID, Val.IRUnitKindID); + } + static bool isEqual(const AnalysisKey &LHS, const AnalysisKey &RHS) { + return LHS.AnalysisID == RHS.AnalysisID && + LHS.IRUnitKindID == RHS.IRUnitKindID; + } +}; /// A CRTP mix-in to automatically provide informational APIs needed for /// passes. @@ -211,17 +234,467 @@ static void *ID() { return (void *)&DerivedT::PassID; } }; +class AnalysisManager; + +// This is used internally by the analysis manager to track dependencies on +// parent IRUnit's. +template +struct ParentIRUnitTrackingAnalysis + : public AnalysisInfoMixin> { + typedef int Result; // Dummy. + Result run(IRUnitT &, AnalysisManager &) { return 0; } + static char PassID; +}; +extern template struct ParentIRUnitTrackingAnalysis; +extern template struct ParentIRUnitTrackingAnalysis; + +namespace detail { + +/// \brief A CRTP base used to implement analysis managers. +/// +/// This class template serves as the boiler plate of an analysis manager. Any +/// analysis manager can be implemented on top of this base class. Any +/// implementation will be required to provide specific hooks: +/// +/// - getResultImpl +/// - getCachedResultImpl +/// - invalidateImpl +/// +/// The details of the call pattern are within. +/// +/// Note that there is also a generic analysis manager template which implements +/// the above required functions along with common datastructures used for +/// managing analyses. This base class is factored so that if you need to +/// customize the handling of a specific IR unit, you can do so without +/// replicating *all* of the boilerplate. +template +class AnalysisManagerBase { + DerivedT *derived_this() { return static_cast(this); } + const DerivedT *derived_this() const { + return static_cast(this); + } + + AnalysisManagerBase(const AnalysisManagerBase &) = delete; + AnalysisManagerBase &operator=(const AnalysisManagerBase &) = delete; + +protected: + typedef detail::AnalysisResultConcept ResultConceptT; + typedef detail::AnalysisPassConcept PassConceptT; + + // FIXME: Provide template aliases for the models when we're using C++11 in + // a mode supporting them. + + // We have to explicitly define all the special member functions because MSVC + // refuses to generate them. + AnalysisManagerBase() {} + AnalysisManagerBase(AnalysisManagerBase &&Arg) + : AnalysisPasses(std::move(Arg.AnalysisPasses)) {} + AnalysisManagerBase &operator=(AnalysisManagerBase &&RHS) { + AnalysisPasses = std::move(RHS.AnalysisPasses); + return *this; + } + +public: + /// \brief Get the result of an analysis pass for this module. + /// + /// If there is not a valid cached result in the manager already, this will + /// re-run the analysis to produce a valid result. + template + typename PassT::Result &getResult(IRUnitT &IR) { + AnalysisKey AK = {PassT::ID(), getIRUnitKindID(&IR)}; + assert(AnalysisPasses.count(AK) && + "This analysis pass was not registered prior to being queried"); + + ResultConceptT &ResultConcept = derived_this()->getResultImpl(AK, IR); + typedef detail::AnalysisResultModel + ResultModelT; + return static_cast(ResultConcept).Result; + } + + /// \brief Get the cached result of an analysis pass for this module. + /// + /// This method never runs the analysis. + /// + /// \returns null if there is no cached result. + template + typename PassT::Result *getCachedResult(IRUnitT &IR) const { + AnalysisKey AK = {PassT::ID(), getIRUnitKindID(&IR)}; + assert(AnalysisPasses.count(AK) && + "This analysis pass was not registered prior to being queried"); + + ResultConceptT *ResultConcept = derived_this()->getCachedResultImpl(AK, IR); + if (!ResultConcept) + return nullptr; + + typedef detail::AnalysisResultModel + ResultModelT; + return &static_cast(ResultConcept)->Result; + } + + /// \brief Register an analysis pass with the manager. + /// + /// The argument is a callable whose result is a pass. This allows passing in + /// a lambda to construct the pass. + /// + /// The pass type registered is the result type of calling the argument. If + /// that pass has already been registered, then the argument will not be + /// called and this function will return false. Otherwise, the pass type + /// becomes registered, with the instance provided by calling the argument + /// once, and this function returns true. + /// + /// While this returns whether or not the pass type was already registered, + /// there in't an independent way to query that as that would be prone to + /// risky use when *querying* the analysis manager. Instead, the only + /// supported use case is avoiding duplicate registry of an analysis. This + /// interface also lends itself to minimizing the number of times we have to + /// do lookups for analyses or construct complex passes only to throw them + /// away. + template + bool registerPass(PassBuilderT PassBuilder) { + typedef decltype(PassBuilder()) PassT; + typedef detail::AnalysisPassModel PassModelT; + + AnalysisKey AK = {PassT::ID(), getIRUnitKindID((IRUnitT *)nullptr)}; + auto &PassPtr = AnalysisPasses[AK]; + if (PassPtr) + // Already registered this pass type! + return false; + + // Construct a new model around the instance returned by the builder. + PassPtr.reset(new PassModelT(PassBuilder())); + return true; + } + + /// \brief Invalidate a specific analysis pass for an IR module. + /// + /// Note that the analysis result can disregard invalidation. + template void invalidate(IRUnitT &IR) { + AnalysisKey AK = {PassT::ID(), getIRUnitKindID(&IR)}; + assert(AnalysisPasses.count(AK) && + "This analysis pass was not registered prior to being invalidated"); + derived_this()->invalidateImpl(AK, IR); + } + + /// \brief Invalidate analyses cached for an IR unit. + /// + /// Walk through all of the analyses pertaining to this unit of IR and + /// invalidate them unless they are preserved by the PreservedAnalyses set. + /// We accept the PreservedAnalyses set by value and update it with each + /// analyis pass which has been successfully invalidated and thus can be + /// preserved going forward. The updated set is returned. + template + PreservedAnalyses invalidate(IRUnitT &IR, PreservedAnalyses PA) { + return derived_this()->invalidateImpl(IR, std::move(PA)); + } + +protected: + /// \brief Lookup a registered analysis pass. + PassConceptT &lookupPass(AnalysisKey AK) { + typename AnalysisPassMapT::iterator PI = AnalysisPasses.find(AK); + assert(PI != AnalysisPasses.end() && + "Analysis passes must be registered prior to being queried!"); + return *PI->second; + } + + /// \brief Lookup a registered analysis pass. + const PassConceptT &lookupPass(AnalysisKey AK) const { + typename AnalysisPassMapT::const_iterator PI = AnalysisPasses.find(AK); + assert(PI != AnalysisPasses.end() && + "Analysis passes must be registered prior to being queried!"); + return *PI->second; + } + +private: + /// \brief Map type from module analysis pass ID to pass concept pointer. + typedef DenseMap> AnalysisPassMapT; + + /// \brief Collection of module analysis passes, indexed by ID. + AnalysisPassMapT AnalysisPasses; +}; + +} // End namespace detail + +struct PerIRUnitAnalysisResultListElement; +struct DependentTrackingNode { + std::list::iterator Dependent; + + // This is a backpointer to allow deletion by somebody with just an + // iterator. + std::list &OwnerList; +}; +struct PerIRUnitAnalysisResultListElement { + PerIRUnitAnalysisResultListElement( + AnalysisKey AK_, + std::unique_ptr AnalysisResult_, + TypeErasedIRUnitID ID_) + : AK(AK_), Result(std::move(AnalysisResult_)), ID(ID_) {} + AnalysisKey AK; + std::unique_ptr Result; + std::list Dependents; + std::vector::iterator> + DependentTrackingNodesThatPointAtMe; + + // This is needed so that we can invalidate this analysis result with + // just an iterator to this struct. + TypeErasedIRUnitID ID; +}; + +/// \brief A generic analysis pass manager with lazy running and caching of +/// results. +/// +/// This analysis manager can be used for any IR unit where the address of the +/// IR unit sufficies as its identity. It manages the cache for a unit of IR via +/// the address of each unit of IR cached. +class AnalysisManager : public detail::AnalysisManagerBase { + friend class detail::AnalysisManagerBase; + typedef detail::AnalysisManagerBase BaseT; + typedef typename BaseT::ResultConceptT ResultConceptT; + typedef typename BaseT::PassConceptT PassConceptT; + +public: + // Most public APIs are inherited from the CRTP base class. + + /// \brief Construct an empty analysis manager. + /// + /// A flag can be passed to indicate that the manager should perform debug + /// logging. + AnalysisManager(bool DebugLogging = false) : DebugLogging(DebugLogging) {} + + // We have to explicitly define all the special member functions because MSVC + // refuses to generate them. + AnalysisManager(AnalysisManager &&Arg) + : BaseT(std::move(static_cast(Arg))), + AnalysisResults(std::move(Arg.AnalysisResults)), + DebugLogging(std::move(Arg.DebugLogging)) {} + AnalysisManager &operator=(AnalysisManager &&RHS) { + BaseT::operator=(std::move(static_cast(RHS))); + AnalysisResults = std::move(RHS.AnalysisResults); + DebugLogging = std::move(RHS.DebugLogging); + return *this; + } + + /// \brief Returns true if the analysis manager has an empty results cache. + bool empty() const { + assert(AnalysisResults.empty() == AnalysisResultLists.empty() && + "The storage and index of analysis results disagree on how many " + "there are!"); + return AnalysisResults.empty(); + } + + /// \brief Clear the analysis result cache. + /// + /// This routine allows cleaning up when the set of IR units itself has + /// potentially changed, and thus we can't even look up a a result and + /// invalidate it directly. Notably, this does *not* call invalidate functions + /// as there is nothing to be done for them. + void clear() { + AnalysisResults.clear(); + AnalysisResultLists.clear(); + } + +private: + AnalysisManager(const AnalysisManager &) = delete; + AnalysisManager &operator=(const AnalysisManager &) = delete; + + /// \brief List of function analysis pass IDs and associated concept pointers. + /// + /// Requires iterators to be valid across appending new entries and arbitrary + /// erases. Provides both the pass ID and concept pointer such that it is + /// half of a bijection and provides storage for the actual result concept. + /// Also does dependency tracking. + typedef std::list AnalysisResultListT; + + + /// \brief Get an analysis result, running the pass if necessary. + template + ResultConceptT &getResultImpl(AnalysisKey AK, IRUnitT &IR) { + typename AnalysisResultMapT::iterator RI; + bool Inserted; + std::tie(RI, Inserted) = AnalysisResults.insert( + std::make_pair(std::make_pair(AK, static_cast(&IR)), + typename AnalysisResultListT::iterator())); + + AnalysisResultListT::iterator ThisResult = RI->second; + + // If we don't have a cached result for this function, look up the pass and + // run it to produce a result, which we then add to the cache. + if (Inserted) { + auto &P = this->lookupPass(AK); + if (DebugLogging) + dbgs() << "Running analysis: " << P.name() << "\n"; + std::unique_ptr &ResultListPtr = + AnalysisResultLists[static_cast(&IR)]; + if (!ResultListPtr) + ResultListPtr = make_unique(); + AnalysisResultListT &ResultList = *ResultListPtr; + ResultList.emplace_back( + AK, std::unique_ptr(nullptr), + static_cast(&IR)); + PerIRUnitAnalysisResultListElement &E = ResultList.back(); + ThisResult = std::prev(ResultList.end()); + RI->second = ThisResult; + InFlightAnalysesStack.push_back(ThisResult); + // Set up the parent IR unit tracking analysis. + // The dependency link will invalidate this result when invalidating + // analysis result for the parent IRUnit. + if (auto *P = getStaticParentIRUnit(IR)) { + typedef + typename std::remove_reference::type ParentIRUnitT; + this->getResult>(*P); + } + // Run the analysis and get the result. + E.Result = P.run(static_cast(&IR), *this); + InFlightAnalysesStack.pop_back(); + } + + // Add dependency tracking links. + if (!InFlightAnalysesStack.empty()) { + auto I = InFlightAnalysesStack.back(); + ThisResult->Dependents.push_back({I, ThisResult->Dependents}); + I->DependentTrackingNodesThatPointAtMe.push_back( + std::prev(ThisResult->Dependents.end())); + } + + return *ThisResult->Result; + } + + /// \brief Get a cached analysis result or return null. + template + ResultConceptT *getCachedResultImpl(AnalysisKey AK, IRUnitT &IR) const { + typename AnalysisResultMapT::const_iterator RI = AnalysisResults.find( + std::make_pair(AK, static_cast(&IR))); + bool Cached = RI != AnalysisResults.end(); + if (!Cached) + return nullptr; + AnalysisResultListT::iterator ThisResult = RI->second; + // Add dependency tracking links. + if (!InFlightAnalysesStack.empty()) { + auto I = InFlightAnalysesStack.back(); + ThisResult->Dependents.push_back({I, ThisResult->Dependents}); + I->DependentTrackingNodesThatPointAtMe.push_back( + std::prev(ThisResult->Dependents.end())); + } + return ThisResult->Result.get(); + } + + /// \brief Invalidate a function pass result. + template void invalidateImpl(AnalysisKey AK, IRUnitT &IR) { + invalidateImplImpl(AK, static_cast(&IR)); + } + + /// \brief Invalidate a function pass result. + /// This includes walking its dependencies and invalidating them. + /// + /// Returns an iterator to the next element in the list (after all + /// dependencies have been invalidated, which may have removed elements + /// from the list). + typename AnalysisResultListT::iterator + invalidateImplImpl(AnalysisKey AK, TypeErasedIRUnitID ID) { + auto MapKey = std::make_pair(AK, ID); + typename AnalysisResultMapT::iterator RI = AnalysisResults.find(MapKey); + if (RI == AnalysisResults.end()) + return typename AnalysisResultListT::iterator(); + + if (DebugLogging) + dbgs() << "Invalidating analysis: " << this->lookupPass(AK).name() + << "\n"; + auto I = RI->second; + auto &L = *AnalysisResultLists[ID]; + auto &D = I->Dependents; + // Invalidate all dependents. + while (!D.empty()) { + auto &Element = *D.front().Dependent; + // This recursive call will delete (at least) this element of `D`. + invalidateImplImpl(Element.AK, Element.ID); + } + // Remove any dependent tracking nodes that are tracking a dependency + // on this analysis result. + // This analysis result is about to be erased and those pointers can't + // be allowed to dangle. + for (auto DepNodeIt : I->DependentTrackingNodesThatPointAtMe) + DepNodeIt->OwnerList.erase(DepNodeIt); + + auto Ret = L.erase(I); // This returns the iterator to the next element. + AnalysisResults.erase(MapKey); // RI may have been invalidated, so use the key. + return Ret; + } + + /// \brief Invalidate the results for a function.. + template + PreservedAnalyses invalidateImpl(IRUnitT &IR, PreservedAnalyses PA) { + // Short circuit for a common case of all analyses being preserved. + if (PA.areAllPreserved()) + return PA; + + if (DebugLogging) + dbgs() << "Invalidating all non-preserved analyses for: " << IR.getName() + << "\n"; + + // Clear all the invalidated results associated specifically with this + // function. + SmallVector InvalidatedAnalysisKeys; + std::unique_ptr &ResultsListPtr = + AnalysisResultLists[static_cast(&IR)]; + if (!ResultsListPtr) + ResultsListPtr = make_unique(); + AnalysisResultListT &ResultsList = *ResultsListPtr; + for (typename AnalysisResultListT::iterator I = ResultsList.begin(), + E = ResultsList.end(); + I != E;) { + AnalysisKey AK = I->AK; + + // Pass the invalidation down to the pass itself to see if it thinks it is + // necessary. The analysis pass can return false if no action on the part + // of the analysis manager is required for this invalidation event. + if (I->Result->invalidate(static_cast(&IR), PA)) + I = invalidateImplImpl(AK, static_cast(&IR)); + else + ++I; + + // After handling each pass, we mark it as preserved. Once we've + // invalidated any stale results, the rest of the system is allowed to + // start preserving this analysis again. + PA.preserve(AK.AnalysisID); + } + if (ResultsList.empty()) + AnalysisResultLists.erase(static_cast(&IR)); + + return PA; + } + + /// \brief Map type from function pointer to our custom list type. + typedef DenseMap> + AnalysisResultListMapT; + + /// \brief Map from function to a list of function analysis results. + /// + /// Provides linear time removal of all analysis results for a function and + /// the ultimate storage for a particular cached analysis result. + AnalysisResultListMapT AnalysisResultLists; + + /// \brief Map type from a pair of analysis ID and function pointer to an + /// iterator into a particular result list. + typedef DenseMap, + typename AnalysisResultListT::iterator> + AnalysisResultMapT; + + /// \brief Map from an analysis ID and function to a particular cached + /// analysis result. + AnalysisResultMapT AnalysisResults; + + /// \brief A stack of analyses currently being computed. + SmallVector InFlightAnalysesStack; + + /// \brief A flag indicating whether debug logging is enabled. + bool DebugLogging; +}; + /// \brief Manages a sequence of passes over units of IR. /// /// A pass manager contains a sequence of passes to run over units of IR. It is /// itself a valid pass over that unit of IR, and when over some given IR will /// run each pass in sequence. This is the primary and most basic building /// block of a pass pipeline. -/// -/// If it is run with an \c AnalysisManager argument, it will propagate -/// that analysis manager to each pass it runs, as well as calling the analysis -/// manager's invalidation routine with the PreservedAnalyses of each pass it -/// runs. template class PassManager : public PassInfoMixin> { public: @@ -241,7 +714,7 @@ } /// \brief Run all of the passes in this manager over the IR. - PreservedAnalyses run(IRUnitT &IR, AnalysisManager &AM) { + PreservedAnalyses run(IRUnitT &IR, AnalysisManager &AM) { PreservedAnalyses PA = PreservedAnalyses::all(); if (DebugLogging) @@ -302,554 +775,11 @@ /// \brief Convenience typedef for a pass manager over functions. typedef PassManager FunctionPassManager; -namespace detail { - -/// \brief A CRTP base used to implement analysis managers. -/// -/// This class template serves as the boiler plate of an analysis manager. Any -/// analysis manager can be implemented on top of this base class. Any -/// implementation will be required to provide specific hooks: -/// -/// - getResultImpl -/// - getCachedResultImpl -/// - invalidateImpl -/// -/// The details of the call pattern are within. -/// -/// Note that there is also a generic analysis manager template which implements -/// the above required functions along with common datastructures used for -/// managing analyses. This base class is factored so that if you need to -/// customize the handling of a specific IR unit, you can do so without -/// replicating *all* of the boilerplate. -template class AnalysisManagerBase { - DerivedT *derived_this() { return static_cast(this); } - const DerivedT *derived_this() const { - return static_cast(this); - } - - AnalysisManagerBase(const AnalysisManagerBase &) = delete; - AnalysisManagerBase &operator=(const AnalysisManagerBase &) = delete; - -protected: - typedef detail::AnalysisResultConcept ResultConceptT; - typedef detail::AnalysisPassConcept PassConceptT; - - // FIXME: Provide template aliases for the models when we're using C++11 in - // a mode supporting them. - - // We have to explicitly define all the special member functions because MSVC - // refuses to generate them. - AnalysisManagerBase() {} - AnalysisManagerBase(AnalysisManagerBase &&Arg) - : AnalysisPasses(std::move(Arg.AnalysisPasses)) {} - AnalysisManagerBase &operator=(AnalysisManagerBase &&RHS) { - AnalysisPasses = std::move(RHS.AnalysisPasses); - return *this; - } - -public: - /// \brief Get the result of an analysis pass for this module. - /// - /// If there is not a valid cached result in the manager already, this will - /// re-run the analysis to produce a valid result. - template typename PassT::Result &getResult(IRUnitT &IR) { - assert(AnalysisPasses.count(PassT::ID()) && - "This analysis pass was not registered prior to being queried"); - - ResultConceptT &ResultConcept = - derived_this()->getResultImpl(PassT::ID(), IR); - typedef detail::AnalysisResultModel - ResultModelT; - return static_cast(ResultConcept).Result; - } - - /// \brief Get the cached result of an analysis pass for this module. - /// - /// This method never runs the analysis. - /// - /// \returns null if there is no cached result. - template - typename PassT::Result *getCachedResult(IRUnitT &IR) const { - assert(AnalysisPasses.count(PassT::ID()) && - "This analysis pass was not registered prior to being queried"); - - ResultConceptT *ResultConcept = - derived_this()->getCachedResultImpl(PassT::ID(), IR); - if (!ResultConcept) - return nullptr; - - typedef detail::AnalysisResultModel - ResultModelT; - return &static_cast(ResultConcept)->Result; - } - - /// \brief Register an analysis pass with the manager. - /// - /// The argument is a callable whose result is a pass. This allows passing in - /// a lambda to construct the pass. - /// - /// The pass type registered is the result type of calling the argument. If - /// that pass has already been registered, then the argument will not be - /// called and this function will return false. Otherwise, the pass type - /// becomes registered, with the instance provided by calling the argument - /// once, and this function returns true. - /// - /// While this returns whether or not the pass type was already registered, - /// there in't an independent way to query that as that would be prone to - /// risky use when *querying* the analysis manager. Instead, the only - /// supported use case is avoiding duplicate registry of an analysis. This - /// interface also lends itself to minimizing the number of times we have to - /// do lookups for analyses or construct complex passes only to throw them - /// away. - template bool registerPass(PassBuilderT PassBuilder) { - typedef decltype(PassBuilder()) PassT; - typedef detail::AnalysisPassModel PassModelT; - - auto &PassPtr = AnalysisPasses[PassT::ID()]; - if (PassPtr) - // Already registered this pass type! - return false; - - // Construct a new model around the instance returned by the builder. - PassPtr.reset(new PassModelT(PassBuilder())); - return true; - } - - /// \brief Invalidate a specific analysis pass for an IR module. - /// - /// Note that the analysis result can disregard invalidation. - template void invalidate(IRUnitT &IR) { - assert(AnalysisPasses.count(PassT::ID()) && - "This analysis pass was not registered prior to being invalidated"); - derived_this()->invalidateImpl(PassT::ID(), IR); - } - - /// \brief Invalidate analyses cached for an IR unit. - /// - /// Walk through all of the analyses pertaining to this unit of IR and - /// invalidate them unless they are preserved by the PreservedAnalyses set. - /// We accept the PreservedAnalyses set by value and update it with each - /// analyis pass which has been successfully invalidated and thus can be - /// preserved going forward. The updated set is returned. - PreservedAnalyses invalidate(IRUnitT &IR, PreservedAnalyses PA) { - return derived_this()->invalidateImpl(IR, std::move(PA)); - } - -protected: - /// \brief Lookup a registered analysis pass. - PassConceptT &lookupPass(void *PassID) { - typename AnalysisPassMapT::iterator PI = AnalysisPasses.find(PassID); - assert(PI != AnalysisPasses.end() && - "Analysis passes must be registered prior to being queried!"); - return *PI->second; - } - - /// \brief Lookup a registered analysis pass. - const PassConceptT &lookupPass(void *PassID) const { - typename AnalysisPassMapT::const_iterator PI = AnalysisPasses.find(PassID); - assert(PI != AnalysisPasses.end() && - "Analysis passes must be registered prior to being queried!"); - return *PI->second; - } - -private: - /// \brief Map type from module analysis pass ID to pass concept pointer. - typedef DenseMap> AnalysisPassMapT; - - /// \brief Collection of module analysis passes, indexed by ID. - AnalysisPassMapT AnalysisPasses; -}; - -} // End namespace detail - -/// \brief A generic analysis pass manager with lazy running and caching of -/// results. -/// -/// This analysis manager can be used for any IR unit where the address of the -/// IR unit sufficies as its identity. It manages the cache for a unit of IR via -/// the address of each unit of IR cached. -template -class AnalysisManager - : public detail::AnalysisManagerBase, IRUnitT> { - friend class detail::AnalysisManagerBase, IRUnitT>; - typedef detail::AnalysisManagerBase, IRUnitT> BaseT; - typedef typename BaseT::ResultConceptT ResultConceptT; - typedef typename BaseT::PassConceptT PassConceptT; - -public: - // Most public APIs are inherited from the CRTP base class. - - /// \brief Construct an empty analysis manager. - /// - /// A flag can be passed to indicate that the manager should perform debug - /// logging. - AnalysisManager(bool DebugLogging = false) : DebugLogging(DebugLogging) {} - - // We have to explicitly define all the special member functions because MSVC - // refuses to generate them. - AnalysisManager(AnalysisManager &&Arg) - : BaseT(std::move(static_cast(Arg))), - AnalysisResults(std::move(Arg.AnalysisResults)), - DebugLogging(std::move(Arg.DebugLogging)) {} - AnalysisManager &operator=(AnalysisManager &&RHS) { - BaseT::operator=(std::move(static_cast(RHS))); - AnalysisResults = std::move(RHS.AnalysisResults); - DebugLogging = std::move(RHS.DebugLogging); - return *this; - } - - /// \brief Returns true if the analysis manager has an empty results cache. - bool empty() const { - assert(AnalysisResults.empty() == AnalysisResultLists.empty() && - "The storage and index of analysis results disagree on how many " - "there are!"); - return AnalysisResults.empty(); - } - - /// \brief Clear the analysis result cache. - /// - /// This routine allows cleaning up when the set of IR units itself has - /// potentially changed, and thus we can't even look up a a result and - /// invalidate it directly. Notably, this does *not* call invalidate functions - /// as there is nothing to be done for them. - void clear() { - AnalysisResults.clear(); - AnalysisResultLists.clear(); - } - -private: - AnalysisManager(const AnalysisManager &) = delete; - AnalysisManager &operator=(const AnalysisManager &) = delete; - - /// \brief Get an analysis result, running the pass if necessary. - ResultConceptT &getResultImpl(void *PassID, IRUnitT &IR) { - typename AnalysisResultMapT::iterator RI; - bool Inserted; - std::tie(RI, Inserted) = AnalysisResults.insert(std::make_pair( - std::make_pair(PassID, &IR), typename AnalysisResultListT::iterator())); - - // If we don't have a cached result for this function, look up the pass and - // run it to produce a result, which we then add to the cache. - if (Inserted) { - auto &P = this->lookupPass(PassID); - if (DebugLogging) - dbgs() << "Running analysis: " << P.name() << "\n"; - AnalysisResultListT &ResultList = AnalysisResultLists[&IR]; - ResultList.emplace_back(PassID, P.run(IR, *this)); - - // P.run may have inserted elements into AnalysisResults and invalidated - // RI. - RI = AnalysisResults.find(std::make_pair(PassID, &IR)); - assert(RI != AnalysisResults.end() && "we just inserted it!"); - - RI->second = std::prev(ResultList.end()); - } - - return *RI->second->second; - } - - /// \brief Get a cached analysis result or return null. - ResultConceptT *getCachedResultImpl(void *PassID, IRUnitT &IR) const { - typename AnalysisResultMapT::const_iterator RI = - AnalysisResults.find(std::make_pair(PassID, &IR)); - return RI == AnalysisResults.end() ? nullptr : &*RI->second->second; - } - - /// \brief Invalidate a function pass result. - void invalidateImpl(void *PassID, IRUnitT &IR) { - typename AnalysisResultMapT::iterator RI = - AnalysisResults.find(std::make_pair(PassID, &IR)); - if (RI == AnalysisResults.end()) - return; - - if (DebugLogging) - dbgs() << "Invalidating analysis: " << this->lookupPass(PassID).name() - << "\n"; - AnalysisResultLists[&IR].erase(RI->second); - AnalysisResults.erase(RI); - } - - /// \brief Invalidate the results for a function.. - PreservedAnalyses invalidateImpl(IRUnitT &IR, PreservedAnalyses PA) { - // Short circuit for a common case of all analyses being preserved. - if (PA.areAllPreserved()) - return PA; - - if (DebugLogging) - dbgs() << "Invalidating all non-preserved analyses for: " << IR.getName() - << "\n"; - - // Clear all the invalidated results associated specifically with this - // function. - SmallVector InvalidatedPassIDs; - AnalysisResultListT &ResultsList = AnalysisResultLists[&IR]; - for (typename AnalysisResultListT::iterator I = ResultsList.begin(), - E = ResultsList.end(); - I != E;) { - void *PassID = I->first; - - // Pass the invalidation down to the pass itself to see if it thinks it is - // necessary. The analysis pass can return false if no action on the part - // of the analysis manager is required for this invalidation event. - if (I->second->invalidate(IR, PA)) { - if (DebugLogging) - dbgs() << "Invalidating analysis: " << this->lookupPass(PassID).name() - << "\n"; - - InvalidatedPassIDs.push_back(I->first); - I = ResultsList.erase(I); - } else { - ++I; - } - - // After handling each pass, we mark it as preserved. Once we've - // invalidated any stale results, the rest of the system is allowed to - // start preserving this analysis again. - PA.preserve(PassID); - } - while (!InvalidatedPassIDs.empty()) - AnalysisResults.erase( - std::make_pair(InvalidatedPassIDs.pop_back_val(), &IR)); - if (ResultsList.empty()) - AnalysisResultLists.erase(&IR); - - return PA; - } - - /// \brief List of function analysis pass IDs and associated concept pointers. - /// - /// Requires iterators to be valid across appending new entries and arbitrary - /// erases. Provides both the pass ID and concept pointer such that it is - /// half of a bijection and provides storage for the actual result concept. - typedef std::list>>> - AnalysisResultListT; - - /// \brief Map type from function pointer to our custom list type. - typedef DenseMap AnalysisResultListMapT; - - /// \brief Map from function to a list of function analysis results. - /// - /// Provides linear time removal of all analysis results for a function and - /// the ultimate storage for a particular cached analysis result. - AnalysisResultListMapT AnalysisResultLists; - - /// \brief Map type from a pair of analysis ID and function pointer to an - /// iterator into a particular result list. - typedef DenseMap, - typename AnalysisResultListT::iterator> - AnalysisResultMapT; - - /// \brief Map from an analysis ID and function to a particular cached - /// analysis result. - AnalysisResultMapT AnalysisResults; - - /// \brief A flag indicating whether debug logging is enabled. - bool DebugLogging; -}; - -extern template class AnalysisManager; -/// \brief Convenience typedef for the Module analysis manager. -typedef AnalysisManager ModuleAnalysisManager; - -extern template class AnalysisManager; -/// \brief Convenience typedef for the Function analysis manager. -typedef AnalysisManager FunctionAnalysisManager; - -/// \brief A module analysis which acts as a proxy for a function analysis -/// manager. -/// -/// This primarily proxies invalidation information from the module analysis -/// manager and module pass manager to a function analysis manager. You should -/// never use a function analysis manager from within (transitively) a module -/// pass manager unless your parent module pass has received a proxy result -/// object for it. -/// -/// Note that the proxy's result is a move-only object and represents ownership -/// of the validity of the analyses in the \c FunctionAnalysisManager it -/// provides. -template -class InnerAnalysisManagerProxy - : public AnalysisInfoMixin< - InnerAnalysisManagerProxy> { -public: - class Result { - public: - explicit Result(AnalysisManagerT &AM) : AM(&AM) {} - Result(Result &&Arg) : AM(std::move(Arg.AM)) { - // We have to null out the analysis manager in the moved-from state - // because we are taking ownership of the responsibilty to clear the - // analysis state. - Arg.AM = nullptr; - } - Result &operator=(Result &&RHS) { - AM = RHS.AM; - // We have to null out the analysis manager in the moved-from state - // because we are taking ownership of the responsibilty to clear the - // analysis state. - RHS.AM = nullptr; - return *this; - } - ~Result() { - // AM is cleared in a moved from state where there is nothing to do. - if (!AM) - return; - - // Clear out the analysis manager if we're being destroyed -- it means we - // didn't even see an invalidate call when we got invalidated. - AM->clear(); - } - - /// \brief Accessor for the analysis manager. - AnalysisManagerT &getManager() { return *AM; } - - /// \brief Handler for invalidation of the module. - /// - /// If this analysis itself is preserved, then we assume that the set of \c - /// Function objects in the \c Module hasn't changed and thus we don't need - /// to invalidate *all* cached data associated with a \c Function* in the \c - /// FunctionAnalysisManager. - /// - /// Regardless of whether this analysis is marked as preserved, all of the - /// analyses in the \c FunctionAnalysisManager are potentially invalidated - /// based on the set of preserved analyses. - bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA) { - // If this proxy isn't marked as preserved, then we can't even invalidate - // individual function analyses, there may be an invalid set of Function - // objects in the cache making it impossible to incrementally preserve - // them. Just clear the entire manager. - if (!PA.preserved(InnerAnalysisManagerProxy::ID())) - AM->clear(); - - // Return false to indicate that this result is still a valid proxy. - return false; - } - - private: - AnalysisManagerT *AM; - }; - - explicit InnerAnalysisManagerProxy(AnalysisManagerT &AM) : AM(&AM) {} - // We have to explicitly define all the special member functions because MSVC - // refuses to generate them. - InnerAnalysisManagerProxy(const InnerAnalysisManagerProxy &Arg) - : AM(Arg.AM) {} - InnerAnalysisManagerProxy(InnerAnalysisManagerProxy &&Arg) - : AM(std::move(Arg.AM)) {} - InnerAnalysisManagerProxy &operator=(InnerAnalysisManagerProxy RHS) { - std::swap(AM, RHS.AM); - return *this; - } - - /// \brief Run the analysis pass and create our proxy result object. - /// - /// This doesn't do any interesting work, it is primarily used to insert our - /// proxy result object into the module analysis cache so that we can proxy - /// invalidation to the function analysis manager. - /// - /// 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, AnalysisManager &) { return Result(*AM); } - -private: - friend AnalysisInfoMixin< - InnerAnalysisManagerProxy>; - static char PassID; - - AnalysisManagerT *AM; -}; - -template -char InnerAnalysisManagerProxy::PassID; - -extern template class InnerAnalysisManagerProxy; -/// Provide the \c FunctionAnalysisManager to \c Module proxy. -typedef InnerAnalysisManagerProxy - FunctionAnalysisManagerModuleProxy; - -/// \brief A function analysis which acts as a proxy for a module analysis -/// manager. -/// -/// This primarily provides an accessor to a parent module analysis manager to -/// function passes. Only the const interface of the module analysis manager is -/// provided to indicate that once inside of a function analysis pass you -/// cannot request a module analysis to actually run. Instead, the user must -/// rely on the \c getCachedResult API. -/// -/// This proxy *doesn't* manage the invalidation in any way. That is handled by -/// the recursive return path of each layer of the pass manager and the -/// returned PreservedAnalysis set. -template -class OuterAnalysisManagerProxy - : public AnalysisInfoMixin< - OuterAnalysisManagerProxy> { -public: - /// \brief Result proxy object for \c OuterAnalysisManagerProxy. - class Result { - public: - explicit Result(const AnalysisManagerT &AM) : AM(&AM) {} - // We have to explicitly define all the special member functions because - // MSVC refuses to generate them. - Result(const Result &Arg) : AM(Arg.AM) {} - Result(Result &&Arg) : AM(std::move(Arg.AM)) {} - Result &operator=(Result RHS) { - std::swap(AM, RHS.AM); - return *this; - } - - const AnalysisManagerT &getManager() const { return *AM; } - - /// \brief Handle invalidation by ignoring it, this pass is immutable. - bool invalidate(IRUnitT &) { return false; } - - private: - const AnalysisManagerT *AM; - }; - - OuterAnalysisManagerProxy(const AnalysisManagerT &AM) : AM(&AM) {} - // We have to explicitly define all the special member functions because MSVC - // refuses to generate them. - OuterAnalysisManagerProxy(const OuterAnalysisManagerProxy &Arg) - : AM(Arg.AM) {} - OuterAnalysisManagerProxy(OuterAnalysisManagerProxy &&Arg) - : AM(std::move(Arg.AM)) {} - OuterAnalysisManagerProxy &operator=(OuterAnalysisManagerProxy RHS) { - std::swap(AM, RHS.AM); - return *this; - } - - /// \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 &, AnalysisManager &) { return Result(*AM); } - -private: - friend AnalysisInfoMixin< - OuterAnalysisManagerProxy>; - static char PassID; - - const AnalysisManagerT *AM; -}; - -template -char OuterAnalysisManagerProxy::PassID; - -extern template class OuterAnalysisManagerProxy; -/// Provide the \c ModuleAnalysisManager to \c Fucntion proxy. -typedef OuterAnalysisManagerProxy - ModuleAnalysisManagerFunctionProxy; /// \brief Trivial adaptor that maps from a module to its functions. /// /// Designed to allow composition of a FunctionPass(Manager) and -/// a ModulePassManager. Note that if this pass is constructed with a pointer -/// to a \c ModuleAnalysisManager it will run the -/// \c FunctionAnalysisManagerModuleProxy analysis prior to running the function -/// pass over the module to enable a \c FunctionAnalysisManager to be used -/// within this run safely. +/// a ModulePassManager. /// /// Function passes run within this adaptor can rely on having exclusive access /// to the function they are run over. They should not read or modify any other @@ -887,35 +817,27 @@ } /// \brief Runs the function pass across every function in the module. - PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM) { - // Setup the function analysis manager from its proxy. - FunctionAnalysisManager &FAM = - AM.getResult(M).getManager(); - + PreservedAnalyses run(Module &M, AnalysisManager &AM) { PreservedAnalyses PA = PreservedAnalyses::all(); for (Function &F : M) { if (F.isDeclaration()) continue; - PreservedAnalyses PassPA = Pass.run(F, FAM); + PreservedAnalyses PassPA = Pass.run(F, AM); // We know that the function pass couldn't have invalidated any other // function's analyses (that's the contract of a function pass), so // directly handle the function analysis manager's invalidation here and // update our preserved set to reflect that these have already been // handled. - PassPA = FAM.invalidate(F, std::move(PassPA)); + PassPA = AM.invalidate(F, std::move(PassPA)); // Then intersect the preserved set so that invalidation of module // analyses will eventually occur when the module pass completes. PA.intersect(std::move(PassPA)); } - // By definition we preserve the proxy. This precludes *any* invalidation - // of function analyses by the proxy, but that's OK because we've taken - // care to invalidate analyses in the function analysis manager - // incrementally above. - PA.preserve(); + PA.preserve>(); return PA; } @@ -944,7 +866,7 @@ /// created, these methods can be instantiated to satisfy whatever the /// context requires. template - PreservedAnalyses run(IRUnitT &Arg, AnalysisManager &AM) { + PreservedAnalyses run(IRUnitT &Arg, AnalysisManager &AM) { (void)AM.template getResult(Arg); return PreservedAnalyses::all(); @@ -966,7 +888,7 @@ /// created, these methods can be instantiated to satisfy whatever the /// context requires. template - PreservedAnalyses run(IRUnitT &Arg, AnalysisManager &AM) { + PreservedAnalyses run(IRUnitT &Arg, AnalysisManager &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. AM.template invalidate(Arg); @@ -982,7 +904,7 @@ struct InvalidateAllAnalysesPass : PassInfoMixin { /// \brief Run this pass over some unit of IR. template - PreservedAnalyses run(IRUnitT &, AnalysisManager &) { + PreservedAnalyses run(IRUnitT &, AnalysisManager &) { return PreservedAnalyses::none(); } }; @@ -1010,8 +932,7 @@ } template - PreservedAnalyses run(IRUnitT &Arg, AnalysisManager &AM, - Ts... Args) { + PreservedAnalyses run(IRUnitT &Arg, AnalysisManager &AM, Ts... Args) { auto PA = PreservedAnalyses::all(); for (int i = 0; i < Count; ++i) PA.intersect(P.run(Arg, AM, Args...)); Index: include/llvm/IR/PassManagerInternal.h =================================================================== --- include/llvm/IR/PassManagerInternal.h +++ include/llvm/IR/PassManagerInternal.h @@ -23,7 +23,12 @@ namespace llvm { -template class AnalysisManager; +/// More semantically meaningful name for opaque handle type. +typedef void *TypeErasedIRUnitID; + +enum IRUnitKind { IRK_Loop, IRK_Function, IRK_CGSCC, IRK_Module }; + +class AnalysisManager; class PreservedAnalyses; /// \brief Implementation details of the pass manager interfaces. @@ -36,7 +41,7 @@ virtual ~PassConcept() {} /// \brief The polymorphic API which runs the pass over a given IR entity. - virtual PreservedAnalyses run(IRUnitT &IR, AnalysisManager &AM) = 0; + virtual PreservedAnalyses run(IRUnitT &IR, AnalysisManager &AM) = 0; /// \brief Polymorphic method to access the name of a pass. virtual StringRef name() = 0; @@ -45,7 +50,7 @@ /// \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& and an \c AnalysisManager&. It requires the pass to +/// an \c IRUnitT& and an \c AnalysisManager&. It requires the pass to /// be a copyable object. template @@ -64,7 +69,7 @@ return *this; } - PreservedAnalysesT run(IRUnitT &IR, AnalysisManager &AM) override { + PreservedAnalysesT run(IRUnitT &IR, AnalysisManager &AM) override { return Pass.run(IR, AM); } StringRef name() override { return PassT::name(); } @@ -75,7 +80,7 @@ /// /// This concept is parameterized over the IR unit that this result pertains /// to. -template struct AnalysisResultConcept { +struct AnalysisResultConcept { virtual ~AnalysisResultConcept() {} /// \brief Method to try and mark a result as invalid. @@ -88,7 +93,8 @@ /// took care to update or preserve the analysis result in some way. /// /// \returns true if the result is indeed invalid (the default). - virtual bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA) = 0; + virtual bool invalidate(TypeErasedIRUnitID IR, + const PreservedAnalyses &PA) = 0; }; /// \brief SFINAE metafunction for computing whether \c ResultT provides an @@ -126,7 +132,7 @@ template struct AnalysisResultModel - : AnalysisResultConcept { + : AnalysisResultConcept { explicit AnalysisResultModel(ResultT Result) : Result(std::move(Result)) {} // We have to explicitly define all the special member functions because MSVC // refuses to generate them. @@ -147,7 +153,8 @@ // FIXME: We should actually use two different concepts for analysis results // rather than two different models, and avoid the indirect function call for // ones that use the trivial behavior. - bool invalidate(IRUnitT &, const PreservedAnalysesT &PA) override { + bool invalidate(TypeErasedIRUnitID IR, + const PreservedAnalysesT &PA) override { return !PA.preserved(PassT::ID()); } @@ -159,7 +166,7 @@ template struct AnalysisResultModel - : AnalysisResultConcept { + : AnalysisResultConcept { explicit AnalysisResultModel(ResultT Result) : Result(std::move(Result)) {} // We have to explicitly define all the special member functions because MSVC // refuses to generate them. @@ -176,8 +183,9 @@ } /// \brief The model delegates to the \c ResultT method. - bool invalidate(IRUnitT &IR, const PreservedAnalysesT &PA) override { - return Result.invalidate(IR, PA); + bool invalidate(TypeErasedIRUnitID IR, + const PreservedAnalysesT &PA) override { + return Result.invalidate(*(IRUnitT *)IR, PA); } ResultT Result; @@ -187,14 +195,14 @@ /// /// This concept is parameterized over the IR unit that it can run over and /// produce an analysis result. -template struct AnalysisPassConcept { +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, AnalysisManager &AM) = 0; + virtual std::unique_ptr + run(TypeErasedIRUnitID IR, AnalysisManager &AM) = 0; /// \brief Polymorphic method to access the name of a pass. virtual StringRef name() = 0; @@ -203,10 +211,10 @@ /// \brief Wrapper to model the analysis pass concept. /// /// Can wrap any type which implements a suitable \c run method. The method -/// must accept an \c IRUnitT& and an \c AnalysisManager& as arguments +/// 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. @@ -228,9 +236,9 @@ /// \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 &AM) override { - return make_unique(Pass.run(IR, AM)); + std::unique_ptr run(TypeErasedIRUnitID IR, + AnalysisManager &AM) override { + return make_unique(Pass.run(*(IRUnitT *)IR, AM)); } /// \brief The model delegates to a static \c PassT::name method. Index: include/llvm/IR/Verifier.h =================================================================== --- include/llvm/IR/Verifier.h +++ include/llvm/IR/Verifier.h @@ -65,8 +65,8 @@ bool IRBroken, DebugInfoBroken; }; static void *ID() { return (void *)&PassID; } - Result run(Module &M, ModuleAnalysisManager &); - Result run(Function &F, FunctionAnalysisManager &); + Result run(Module &M, AnalysisManager &); + Result run(Function &F, AnalysisManager &); }; /// Check a module for errors, but report debug info errors separately. @@ -90,8 +90,8 @@ public: explicit VerifierPass(bool FatalErrors = true) : FatalErrors(FatalErrors) {} - PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; Index: include/llvm/Passes/PassBuilder.h =================================================================== --- include/llvm/Passes/PassBuilder.h +++ include/llvm/Passes/PassBuilder.h @@ -125,45 +125,36 @@ explicit PassBuilder(TargetMachine *TM = nullptr) : TM(TM) {} - /// \brief Cross register the analysis managers through their proxies. - /// - /// This is an interface that can be used to cross register each - // AnalysisManager with all the others analysis managers. - void crossRegisterProxies(LoopAnalysisManager &LAM, - FunctionAnalysisManager &FAM, - CGSCCAnalysisManager &CGAM, - ModuleAnalysisManager &MAM); - /// \brief Registers all available module analysis passes. /// - /// This is an interface that can be used to populate a \c - /// ModuleAnalysisManager with all registered module analyses. Callers can + /// This is an interface that can be used to populate an \c + /// AnalysisManager with all registered module analyses. Callers can /// still manually register any additional analyses. Callers can also /// pre-register analyses and this will not override those. - void registerModuleAnalyses(ModuleAnalysisManager &MAM); + void registerModuleAnalyses(AnalysisManager &AM); /// \brief Registers all available CGSCC analysis passes. /// - /// This is an interface that can be used to populate a \c CGSCCAnalysisManager + /// This is an interface that can be used to populate an \c AnalysisManager /// with all registered CGSCC analyses. Callers can still manually register any /// additional analyses. Callers can also pre-register analyses and this will /// not override those. - void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM); + void registerCGSCCAnalyses(AnalysisManager &AM); /// \brief Registers all available function analysis passes. /// - /// This is an interface that can be used to populate a \c - /// FunctionAnalysisManager with all registered function analyses. Callers can + /// This is an interface that can be used to populate an \c + /// AnalysisManager with all registered function analyses. Callers can /// still manually register any additional analyses. Callers can also /// pre-register analyses and this will not override those. - void registerFunctionAnalyses(FunctionAnalysisManager &FAM); + void registerFunctionAnalyses(AnalysisManager &AM); /// \brief Registers all available loop analysis passes. /// - /// This is an interface that can be used to populate a \c LoopAnalysisManager + /// This is an interface that can be used to populate an \c AnalysisManager /// with all registered loop analyses. Callers can still manually register any /// additional analyses. - void registerLoopAnalyses(LoopAnalysisManager &LAM); + void registerLoopAnalyses(AnalysisManager &AM); /// \brief Add a per-module default optimization pipeline to a pass manager. /// Index: include/llvm/Transforms/GCOVProfiler.h =================================================================== --- include/llvm/Transforms/GCOVProfiler.h +++ include/llvm/Transforms/GCOVProfiler.h @@ -21,7 +21,7 @@ class GCOVProfilerPass : public PassInfoMixin { public: GCOVProfilerPass(const GCOVOptions &Options = GCOVOptions::getDefault()) : GCOVOpts(Options) { } - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); private: GCOVOptions GCOVOpts; Index: include/llvm/Transforms/IPO/ConstantMerge.h =================================================================== --- include/llvm/Transforms/IPO/ConstantMerge.h +++ include/llvm/Transforms/IPO/ConstantMerge.h @@ -28,7 +28,7 @@ /// A pass that merges duplicate global constants into a single constant. class ConstantMergePass : public PassInfoMixin { public: - PreservedAnalyses run(Module &M, ModuleAnalysisManager &); + PreservedAnalyses run(Module &M, AnalysisManager &); }; } Index: include/llvm/Transforms/IPO/CrossDSOCFI.h =================================================================== --- include/llvm/Transforms/IPO/CrossDSOCFI.h +++ include/llvm/Transforms/IPO/CrossDSOCFI.h @@ -21,7 +21,7 @@ namespace llvm { class CrossDSOCFIPass : public PassInfoMixin { public: - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); }; } #endif // LLVM_TRANSFORMS_IPO_CROSSDSOCFI_H Index: include/llvm/Transforms/IPO/DeadArgumentElimination.h =================================================================== --- include/llvm/Transforms/IPO/DeadArgumentElimination.h +++ include/llvm/Transforms/IPO/DeadArgumentElimination.h @@ -110,7 +110,7 @@ public: DeadArgumentEliminationPass(bool ShouldHackArguments_ = false) : ShouldHackArguments(ShouldHackArguments_) {} - PreservedAnalyses run(Module &M, ModuleAnalysisManager &); + PreservedAnalyses run(Module &M, AnalysisManager &); private: Liveness MarkIfNotLive(RetOrArg Use, UseVector &MaybeLiveUses); Index: include/llvm/Transforms/IPO/ElimAvailExtern.h =================================================================== --- include/llvm/Transforms/IPO/ElimAvailExtern.h +++ include/llvm/Transforms/IPO/ElimAvailExtern.h @@ -24,7 +24,7 @@ class EliminateAvailableExternallyPass : public PassInfoMixin { public: - PreservedAnalyses run(Module &M, ModuleAnalysisManager &); + PreservedAnalyses run(Module &M, AnalysisManager &); }; } Index: include/llvm/Transforms/IPO/ForceFunctionAttrs.h =================================================================== --- include/llvm/Transforms/IPO/ForceFunctionAttrs.h +++ include/llvm/Transforms/IPO/ForceFunctionAttrs.h @@ -22,7 +22,7 @@ /// Pass which forces specific function attributes into the IR, primarily as /// a debugging tool. struct ForceFunctionAttrsPass : PassInfoMixin { - PreservedAnalyses run(Module &M, ModuleAnalysisManager &); + PreservedAnalyses run(Module &M, AnalysisManager &); }; /// Create a legacy pass manager instance of a pass to force function attrs. Index: include/llvm/Transforms/IPO/FunctionAttrs.h =================================================================== --- include/llvm/Transforms/IPO/FunctionAttrs.h +++ include/llvm/Transforms/IPO/FunctionAttrs.h @@ -30,7 +30,7 @@ /// attribute. It also discovers function arguments that are not captured by /// the function and marks them with the nocapture attribute. struct PostOrderFunctionAttrsPass : PassInfoMixin { - PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM); + PreservedAnalyses run(LazyCallGraph::SCC &C, AnalysisManager &AM); }; /// Create a legacy pass manager instance of a pass to compute function attrs @@ -50,7 +50,7 @@ class ReversePostOrderFunctionAttrsPass : public PassInfoMixin { public: - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); }; } Index: include/llvm/Transforms/IPO/FunctionImport.h =================================================================== --- include/llvm/Transforms/IPO/FunctionImport.h +++ include/llvm/Transforms/IPO/FunctionImport.h @@ -69,7 +69,7 @@ public: FunctionImportPass(const ModuleSummaryIndex *Index = nullptr) : Index(Index) {} - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); private: const ModuleSummaryIndex *Index; Index: include/llvm/Transforms/IPO/GlobalDCE.h =================================================================== --- include/llvm/Transforms/IPO/GlobalDCE.h +++ include/llvm/Transforms/IPO/GlobalDCE.h @@ -27,7 +27,7 @@ /// Pass to remove unused function declarations. class GlobalDCEPass : public PassInfoMixin { public: - PreservedAnalyses run(Module &M, ModuleAnalysisManager &); + PreservedAnalyses run(Module &M, AnalysisManager &); private: SmallPtrSet AliveGlobals; Index: include/llvm/Transforms/IPO/GlobalOpt.h =================================================================== --- include/llvm/Transforms/IPO/GlobalOpt.h +++ include/llvm/Transforms/IPO/GlobalOpt.h @@ -24,7 +24,7 @@ /// Optimize globals that never have their address taken. class GlobalOptPass : public PassInfoMixin { public: - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); }; } Index: include/llvm/Transforms/IPO/InferFunctionAttrs.h =================================================================== --- include/llvm/Transforms/IPO/InferFunctionAttrs.h +++ include/llvm/Transforms/IPO/InferFunctionAttrs.h @@ -24,7 +24,7 @@ /// A pass which infers function attributes from the names and signatures of /// function declarations in a module. struct InferFunctionAttrsPass : PassInfoMixin { - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); }; /// Create a legacy pass manager instance of a pass to infer function Index: include/llvm/Transforms/IPO/Internalize.h =================================================================== --- include/llvm/Transforms/IPO/Internalize.h +++ include/llvm/Transforms/IPO/Internalize.h @@ -63,7 +63,7 @@ /// internalizing a function (by removing any edge from the "external node") bool internalizeModule(Module &TheModule, CallGraph *CG = nullptr); - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); }; /// Helper function to internalize functions and variables in a Module. Index: include/llvm/Transforms/IPO/LowerTypeTests.h =================================================================== --- include/llvm/Transforms/IPO/LowerTypeTests.h +++ include/llvm/Transforms/IPO/LowerTypeTests.h @@ -205,7 +205,7 @@ class LowerTypeTestsPass : public PassInfoMixin { public: - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); }; } // end namespace llvm Index: include/llvm/Transforms/IPO/PartialInlining.h =================================================================== --- include/llvm/Transforms/IPO/PartialInlining.h +++ include/llvm/Transforms/IPO/PartialInlining.h @@ -23,7 +23,7 @@ /// Pass to remove unused function declarations. class PartialInlinerPass : public PassInfoMixin { public: - PreservedAnalyses run(Module &M, ModuleAnalysisManager &); + PreservedAnalyses run(Module &M, AnalysisManager &); }; } #endif // LLVM_TRANSFORMS_IPO_PARTIALINLINING_H Index: include/llvm/Transforms/IPO/SCCP.h =================================================================== --- include/llvm/Transforms/IPO/SCCP.h +++ include/llvm/Transforms/IPO/SCCP.h @@ -28,7 +28,7 @@ /// Pass to perform interprocedural constant propagation. class IPSCCPPass : public PassInfoMixin { public: - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); }; } #endif // LLVM_TRANSFORMS_IPO_SCCP_H Index: include/llvm/Transforms/IPO/StripDeadPrototypes.h =================================================================== --- include/llvm/Transforms/IPO/StripDeadPrototypes.h +++ include/llvm/Transforms/IPO/StripDeadPrototypes.h @@ -24,7 +24,7 @@ /// Pass to remove unused function declarations. struct StripDeadPrototypesPass : PassInfoMixin { - PreservedAnalyses run(Module &M, ModuleAnalysisManager &); + PreservedAnalyses run(Module &M, AnalysisManager &); }; } Index: include/llvm/Transforms/IPO/WholeProgramDevirt.h =================================================================== --- include/llvm/Transforms/IPO/WholeProgramDevirt.h +++ include/llvm/Transforms/IPO/WholeProgramDevirt.h @@ -215,7 +215,7 @@ } // end namespace wholeprogramdevirt struct WholeProgramDevirtPass : public PassInfoMixin { - PreservedAnalyses run(Module &M, ModuleAnalysisManager &); + PreservedAnalyses run(Module &M, AnalysisManager &); }; } // end namespace llvm Index: include/llvm/Transforms/InstCombine/InstCombine.h =================================================================== --- include/llvm/Transforms/InstCombine/InstCombine.h +++ include/llvm/Transforms/InstCombine/InstCombine.h @@ -43,7 +43,7 @@ return *this; } - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; /// \brief The legacy pass manager's instcombine pass. Index: include/llvm/Transforms/InstrProfiling.h =================================================================== --- include/llvm/Transforms/InstrProfiling.h +++ include/llvm/Transforms/InstrProfiling.h @@ -29,7 +29,7 @@ InstrProfiling() {} InstrProfiling(const InstrProfOptions &Options) : Options(Options) {} - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); bool run(Module &M); private: Index: include/llvm/Transforms/PGOInstrumentation.h =================================================================== --- include/llvm/Transforms/PGOInstrumentation.h +++ include/llvm/Transforms/PGOInstrumentation.h @@ -22,13 +22,13 @@ /// The instrumentation (profile-instr-gen) pass for IR based PGO. class PGOInstrumentationGen : public PassInfoMixin { public: - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); }; /// The profile annotation (profile-instr-use) pass for IR based PGO. class PGOInstrumentationUse : public PassInfoMixin { public: - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); PGOInstrumentationUse(std::string Filename = ""); private: @@ -39,7 +39,7 @@ class PGOIndirectCallPromotion : public PassInfoMixin { public: PGOIndirectCallPromotion(bool IsInLTO = false) : InLTO(IsInLTO) {} - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); private: bool InLTO; }; Index: include/llvm/Transforms/SampleProfile.h =================================================================== --- include/llvm/Transforms/SampleProfile.h +++ include/llvm/Transforms/SampleProfile.h @@ -20,7 +20,7 @@ /// The sample profiler data loader pass. class SampleProfileLoaderPass : public PassInfoMixin { public: - PreservedAnalyses run(Module &M, AnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); }; } // End llvm namespace Index: include/llvm/Transforms/Scalar/ADCE.h =================================================================== --- include/llvm/Transforms/Scalar/ADCE.h +++ include/llvm/Transforms/Scalar/ADCE.h @@ -29,7 +29,7 @@ /// dead computations that other DCE passes do not catch, particularly involving /// loop computations. struct ADCEPass : PassInfoMixin { - PreservedAnalyses run(Function &F, FunctionAnalysisManager &); + PreservedAnalyses run(Function &F, AnalysisManager &); }; } Index: include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h =================================================================== --- include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h +++ include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h @@ -27,7 +27,7 @@ struct AlignmentFromAssumptionsPass : public PassInfoMixin { - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); // Glue for old PM. bool runImpl(Function &F, AssumptionCache &AC, ScalarEvolution *SE_, Index: include/llvm/Transforms/Scalar/BDCE.h =================================================================== --- include/llvm/Transforms/Scalar/BDCE.h +++ include/llvm/Transforms/Scalar/BDCE.h @@ -24,7 +24,7 @@ // The Bit-Tracking Dead Code Elimination pass. struct BDCEPass : PassInfoMixin { - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/ConstantHoisting.h =================================================================== --- include/llvm/Transforms/Scalar/ConstantHoisting.h +++ include/llvm/Transforms/Scalar/ConstantHoisting.h @@ -94,7 +94,7 @@ class ConstantHoistingPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); // Glue for old PM. bool runImpl(Function &F, TargetTransformInfo &TTI, DominatorTree &DT, Index: include/llvm/Transforms/Scalar/CorrelatedValuePropagation.h =================================================================== --- include/llvm/Transforms/Scalar/CorrelatedValuePropagation.h +++ include/llvm/Transforms/Scalar/CorrelatedValuePropagation.h @@ -17,7 +17,7 @@ struct CorrelatedValuePropagationPass : PassInfoMixin { - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/DCE.h =================================================================== --- include/llvm/Transforms/Scalar/DCE.h +++ include/llvm/Transforms/Scalar/DCE.h @@ -22,7 +22,7 @@ /// Basic Dead Code Elimination pass. class DCEPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/DeadStoreElimination.h =================================================================== --- include/llvm/Transforms/Scalar/DeadStoreElimination.h +++ include/llvm/Transforms/Scalar/DeadStoreElimination.h @@ -27,7 +27,7 @@ /// only the redundant stores that are local to a single Basic Block. class DSEPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, AnalysisManager &FAM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/EarlyCSE.h =================================================================== --- include/llvm/Transforms/Scalar/EarlyCSE.h +++ include/llvm/Transforms/Scalar/EarlyCSE.h @@ -28,7 +28,7 @@ /// expected that a later pass of GVN will catch the interesting/hard cases. struct EarlyCSEPass : PassInfoMixin { /// \brief Run the pass over the function. - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/Float2Int.h =================================================================== --- include/llvm/Transforms/Scalar/Float2Int.h +++ include/llvm/Transforms/Scalar/Float2Int.h @@ -24,7 +24,7 @@ namespace llvm { class Float2IntPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); // Glue for old PM. bool runImpl(Function &F); Index: include/llvm/Transforms/Scalar/GVN.h =================================================================== --- include/llvm/Transforms/Scalar/GVN.h +++ include/llvm/Transforms/Scalar/GVN.h @@ -45,7 +45,7 @@ public: /// \brief Run the pass over the function. - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); /// This removes the specified instruction from /// our various maps and marks it for deletion. @@ -232,7 +232,7 @@ /// from sibling branches. struct GVNHoistPass : PassInfoMixin { /// \brief Run the pass over the function. - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/GuardWidening.h =================================================================== --- include/llvm/Transforms/Scalar/GuardWidening.h +++ include/llvm/Transforms/Scalar/GuardWidening.h @@ -24,7 +24,7 @@ class Function; struct GuardWideningPass : public PassInfoMixin { - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/IndVarSimplify.h =================================================================== --- include/llvm/Transforms/Scalar/IndVarSimplify.h +++ include/llvm/Transforms/Scalar/IndVarSimplify.h @@ -22,7 +22,7 @@ class IndVarSimplifyPass : public PassInfoMixin { public: - PreservedAnalyses run(Loop &L, AnalysisManager &AM); + PreservedAnalyses run(Loop &L, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/JumpThreading.h =================================================================== --- include/llvm/Transforms/Scalar/JumpThreading.h +++ include/llvm/Transforms/Scalar/JumpThreading.h @@ -98,7 +98,7 @@ bool HasProfileData_, std::unique_ptr BFI_, std::unique_ptr BPI_); - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); void releaseMemory() { BFI.reset(); Index: include/llvm/Transforms/Scalar/LICM.h =================================================================== --- include/llvm/Transforms/Scalar/LICM.h +++ include/llvm/Transforms/Scalar/LICM.h @@ -41,7 +41,7 @@ /// Performs Loop Invariant Code Motion Pass. class LICMPass : public PassInfoMixin { public: - PreservedAnalyses run(Loop &L, AnalysisManager &AM); + PreservedAnalyses run(Loop &L, AnalysisManager &AM); }; } // end namespace llvm Index: include/llvm/Transforms/Scalar/LoopDeletion.h =================================================================== --- include/llvm/Transforms/Scalar/LoopDeletion.h +++ include/llvm/Transforms/Scalar/LoopDeletion.h @@ -23,7 +23,7 @@ class LoopDeletionPass : public PassInfoMixin { public: LoopDeletionPass() {} - PreservedAnalyses run(Loop &L, AnalysisManager &AM); + PreservedAnalyses run(Loop &L, AnalysisManager &AM); bool runImpl(Loop *L, DominatorTree &DT, ScalarEvolution &SE, LoopInfo &loopInfo); Index: include/llvm/Transforms/Scalar/LoopDistribute.h =================================================================== --- include/llvm/Transforms/Scalar/LoopDistribute.h +++ include/llvm/Transforms/Scalar/LoopDistribute.h @@ -23,7 +23,7 @@ class LoopDistributePass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } // end namespace llvm Index: include/llvm/Transforms/Scalar/LoopIdiomRecognize.h =================================================================== --- include/llvm/Transforms/Scalar/LoopIdiomRecognize.h +++ include/llvm/Transforms/Scalar/LoopIdiomRecognize.h @@ -24,7 +24,7 @@ /// Performs Loop Idiom Recognize Pass. class LoopIdiomRecognizePass : public PassInfoMixin { public: - PreservedAnalyses run(Loop &L, AnalysisManager &AM); + PreservedAnalyses run(Loop &L, AnalysisManager &AM); }; } // end namespace llvm Index: include/llvm/Transforms/Scalar/LoopInstSimplify.h =================================================================== --- include/llvm/Transforms/Scalar/LoopInstSimplify.h +++ include/llvm/Transforms/Scalar/LoopInstSimplify.h @@ -22,7 +22,7 @@ /// Performs Loop Inst Simplify Pass. class LoopInstSimplifyPass : public PassInfoMixin { public: - PreservedAnalyses run(Loop &L, AnalysisManager &AM); + PreservedAnalyses run(Loop &L, AnalysisManager &AM); }; } // end namespace llvm Index: include/llvm/Transforms/Scalar/LoopRotation.h =================================================================== --- include/llvm/Transforms/Scalar/LoopRotation.h +++ include/llvm/Transforms/Scalar/LoopRotation.h @@ -23,7 +23,7 @@ class LoopRotatePass : public PassInfoMixin { public: LoopRotatePass(); - PreservedAnalyses run(Loop &L, AnalysisManager &AM); + PreservedAnalyses run(Loop &L, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/LoopSimplifyCFG.h =================================================================== --- include/llvm/Transforms/Scalar/LoopSimplifyCFG.h +++ include/llvm/Transforms/Scalar/LoopSimplifyCFG.h @@ -25,7 +25,7 @@ /// Performs basic CFG simplifications to assist other loop passes. class LoopSimplifyCFGPass : public PassInfoMixin { public: - PreservedAnalyses run(Loop &L, AnalysisManager &AM); + PreservedAnalyses run(Loop &L, AnalysisManager &AM); }; } // end namespace llvm Index: include/llvm/Transforms/Scalar/LoopStrengthReduce.h =================================================================== --- include/llvm/Transforms/Scalar/LoopStrengthReduce.h +++ include/llvm/Transforms/Scalar/LoopStrengthReduce.h @@ -30,7 +30,7 @@ /// Performs Loop Strength Reduce Pass. class LoopStrengthReducePass : public PassInfoMixin { public: - PreservedAnalyses run(Loop &L, AnalysisManager &AM); + PreservedAnalyses run(Loop &L, AnalysisManager &AM); }; } // end namespace llvm Index: include/llvm/Transforms/Scalar/LoopUnrollPass.h =================================================================== --- include/llvm/Transforms/Scalar/LoopUnrollPass.h +++ include/llvm/Transforms/Scalar/LoopUnrollPass.h @@ -21,7 +21,7 @@ Optional ProvidedAllowPartial; Optional ProvidedRuntime; - PreservedAnalyses run(Loop &L, AnalysisManager &AM); + PreservedAnalyses run(Loop &L, AnalysisManager &AM); }; } // end namespace llvm Index: include/llvm/Transforms/Scalar/LowerAtomic.h =================================================================== --- include/llvm/Transforms/Scalar/LowerAtomic.h +++ include/llvm/Transforms/Scalar/LowerAtomic.h @@ -22,7 +22,7 @@ /// A pass that lowers atomic intrinsic into non-atomic intrinsics. class LowerAtomicPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &); + PreservedAnalyses run(Function &F, AnalysisManager &); }; } Index: include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h =================================================================== --- include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h +++ include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h @@ -29,7 +29,7 @@ /// 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, FunctionAnalysisManager &); + PreservedAnalyses run(Function &F, AnalysisManager &); }; } Index: include/llvm/Transforms/Scalar/LowerGuardIntrinsic.h =================================================================== --- include/llvm/Transforms/Scalar/LowerGuardIntrinsic.h +++ include/llvm/Transforms/Scalar/LowerGuardIntrinsic.h @@ -20,7 +20,7 @@ namespace llvm { struct LowerGuardIntrinsicPass : PassInfoMixin { - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/MemCpyOptimizer.h =================================================================== --- include/llvm/Transforms/Scalar/MemCpyOptimizer.h +++ include/llvm/Transforms/Scalar/MemCpyOptimizer.h @@ -38,7 +38,7 @@ public: MemCpyOptPass() {} - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); // Glue for the old PM. bool runImpl(Function &F, MemoryDependenceResults *MD_, TargetLibraryInfo *TLI_, Index: include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h =================================================================== --- include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h +++ include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h @@ -31,7 +31,7 @@ class MergedLoadStoreMotionPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/NaryReassociate.h =================================================================== --- include/llvm/Transforms/Scalar/NaryReassociate.h +++ include/llvm/Transforms/Scalar/NaryReassociate.h @@ -92,7 +92,7 @@ namespace llvm { class NaryReassociatePass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); // Glue for old PM. bool runImpl(Function &F, AssumptionCache *AC_, DominatorTree *DT_, Index: include/llvm/Transforms/Scalar/PartiallyInlineLibCalls.h =================================================================== --- include/llvm/Transforms/Scalar/PartiallyInlineLibCalls.h +++ include/llvm/Transforms/Scalar/PartiallyInlineLibCalls.h @@ -23,7 +23,7 @@ class PartiallyInlineLibCallsPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/Reassociate.h =================================================================== --- include/llvm/Transforms/Scalar/Reassociate.h +++ include/llvm/Transforms/Scalar/Reassociate.h @@ -62,7 +62,7 @@ bool MadeChange; public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &); + PreservedAnalyses run(Function &F, AnalysisManager &); private: void BuildRankMap(Function &F, ReversePostOrderTraversal &RPOT); Index: include/llvm/Transforms/Scalar/SCCP.h =================================================================== --- include/llvm/Transforms/Scalar/SCCP.h +++ include/llvm/Transforms/Scalar/SCCP.h @@ -29,7 +29,7 @@ /// This pass performs function-level constant propagation and merging. class SCCPPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/SROA.h =================================================================== --- include/llvm/Transforms/Scalar/SROA.h +++ include/llvm/Transforms/Scalar/SROA.h @@ -102,7 +102,7 @@ SROA() : C(nullptr), DT(nullptr), AC(nullptr) {} /// \brief Run the pass over the function. - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); private: friend class sroa::AllocaSliceRewriter; Index: include/llvm/Transforms/Scalar/SimplifyCFG.h =================================================================== --- include/llvm/Transforms/Scalar/SimplifyCFG.h +++ include/llvm/Transforms/Scalar/SimplifyCFG.h @@ -36,7 +36,7 @@ SimplifyCFGPass(int BonusInstThreshold); /// \brief Run the pass over the function. - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/Sink.h =================================================================== --- include/llvm/Transforms/Scalar/Sink.h +++ include/llvm/Transforms/Scalar/Sink.h @@ -23,7 +23,7 @@ /// Move instructions into successor blocks when possible. class SinkingPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Scalar/SpeculativeExecution.h =================================================================== --- include/llvm/Transforms/Scalar/SpeculativeExecution.h +++ include/llvm/Transforms/Scalar/SpeculativeExecution.h @@ -72,7 +72,7 @@ public: SpeculativeExecutionPass(bool OnlyIfDivergentTarget = false); - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); // Glue for old PM bool runImpl(Function &F, TargetTransformInfo *TTI); Index: include/llvm/Transforms/Scalar/TailRecursionElimination.h =================================================================== --- include/llvm/Transforms/Scalar/TailRecursionElimination.h +++ include/llvm/Transforms/Scalar/TailRecursionElimination.h @@ -59,7 +59,7 @@ namespace llvm { struct TailCallElimPass : PassInfoMixin { - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } Index: include/llvm/Transforms/Utils/AddDiscriminators.h =================================================================== --- include/llvm/Transforms/Utils/AddDiscriminators.h +++ include/llvm/Transforms/Utils/AddDiscriminators.h @@ -22,7 +22,7 @@ class AddDiscriminatorsPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } // end namespace llvm Index: include/llvm/Transforms/Utils/BreakCriticalEdges.h =================================================================== --- include/llvm/Transforms/Utils/BreakCriticalEdges.h +++ include/llvm/Transforms/Utils/BreakCriticalEdges.h @@ -23,7 +23,7 @@ namespace llvm { struct BreakCriticalEdgesPass : public PassInfoMixin { - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } // namespace llvm #endif // LLVM_TRANSFORMS_UTILS_BREAKCRITICALEDGES_H Index: include/llvm/Transforms/Utils/LCSSA.h =================================================================== --- include/llvm/Transforms/Utils/LCSSA.h +++ include/llvm/Transforms/Utils/LCSSA.h @@ -37,7 +37,7 @@ /// Converts loops into loop-closed SSA form. class LCSSAPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } // end namespace llvm Index: include/llvm/Transforms/Utils/LoopSimplify.h =================================================================== --- include/llvm/Transforms/Utils/LoopSimplify.h +++ include/llvm/Transforms/Utils/LoopSimplify.h @@ -49,7 +49,7 @@ /// This pass is responsible for loop canonicalization. class LoopSimplifyPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; /// \brief Simplify each loop in a loop nest recursively. Index: include/llvm/Transforms/Utils/Mem2Reg.h =================================================================== --- include/llvm/Transforms/Utils/Mem2Reg.h +++ include/llvm/Transforms/Utils/Mem2Reg.h @@ -21,8 +21,8 @@ namespace llvm { class PromotePass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } -#endif // LLVM_TRANSFORMS_UTILS_MEM2REG_H \ No newline at end of file +#endif // LLVM_TRANSFORMS_UTILS_MEM2REG_H Index: include/llvm/Transforms/Utils/MemorySSA.h =================================================================== --- include/llvm/Transforms/Utils/MemorySSA.h +++ include/llvm/Transforms/Utils/MemorySSA.h @@ -678,7 +678,7 @@ public: typedef MemorySSA Result; - MemorySSA run(Function &F, AnalysisManager &AM); + MemorySSA run(Function &F, AnalysisManager &AM); }; /// \brief Printer pass for \c MemorySSA. @@ -687,12 +687,12 @@ public: explicit MemorySSAPrinterPass(raw_ostream &OS) : OS(OS) {} - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; /// \brief Verifier pass for \c MemorySSA. struct MemorySSAVerifierPass : PassInfoMixin { - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; /// \brief Legacy analysis pass which computes \c MemorySSA. Index: include/llvm/Transforms/Utils/SimplifyInstructions.h =================================================================== --- include/llvm/Transforms/Utils/SimplifyInstructions.h +++ include/llvm/Transforms/Utils/SimplifyInstructions.h @@ -24,7 +24,7 @@ /// This pass removes redundant instructions. class InstSimplifierPass : public PassInfoMixin { public: - PreservedAnalyses run(Function &F, AnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); }; } // end namespace llvm Index: include/llvm/Transforms/Utils/SymbolRewriter.h =================================================================== --- include/llvm/Transforms/Utils/SymbolRewriter.h +++ include/llvm/Transforms/Utils/SymbolRewriter.h @@ -123,7 +123,7 @@ RewriteSymbolPass(RewriteSymbolPass &&Other) : Descriptors(std::move(Other.Descriptors)) {} - PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); + PreservedAnalyses run(Module &M, AnalysisManager &AM); // Glue for old PM bool runImpl(Module &M); Index: include/llvm/Transforms/Vectorize/LoopVectorize.h =================================================================== --- include/llvm/Transforms/Vectorize/LoopVectorize.h +++ include/llvm/Transforms/Vectorize/LoopVectorize.h @@ -89,7 +89,7 @@ BlockFrequency ColdEntryFreq; - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); // Shim for old PM. bool runImpl(Function &F, ScalarEvolution &SE_, LoopInfo &LI_, Index: include/llvm/Transforms/Vectorize/SLPVectorizer.h =================================================================== --- include/llvm/Transforms/Vectorize/SLPVectorizer.h +++ include/llvm/Transforms/Vectorize/SLPVectorizer.h @@ -54,7 +54,7 @@ const DataLayout *DL = nullptr; public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + PreservedAnalyses run(Function &F, AnalysisManager &AM); // Glue for old PM. bool runImpl(Function &F, ScalarEvolution *SE_, TargetTransformInfo *TTI_, Index: lib/Analysis/AliasAnalysisEvaluator.cpp =================================================================== --- lib/Analysis/AliasAnalysisEvaluator.cpp +++ lib/Analysis/AliasAnalysisEvaluator.cpp @@ -88,7 +88,7 @@ && !isa(V); } -PreservedAnalyses AAEvaluator::run(Function &F, AnalysisManager &AM) { +PreservedAnalyses AAEvaluator::run(Function &F, AnalysisManager &AM) { runInternal(F, AM.getResult(F)); return PreservedAnalyses::all(); } Index: lib/Analysis/AssumptionCache.cpp =================================================================== --- lib/Analysis/AssumptionCache.cpp +++ lib/Analysis/AssumptionCache.cpp @@ -76,8 +76,7 @@ char AssumptionAnalysis::PassID; -PreservedAnalyses AssumptionPrinterPass::run(Function &F, - AnalysisManager &AM) { +PreservedAnalyses AssumptionPrinterPass::run(Function &F, AnalysisManager &AM) { AssumptionCache &AC = AM.getResult(F); OS << "Cached assumptions for function: " << F.getName() << "\n"; Index: lib/Analysis/BasicAliasAnalysis.cpp =================================================================== --- lib/Analysis/BasicAliasAnalysis.cpp +++ lib/Analysis/BasicAliasAnalysis.cpp @@ -1669,7 +1669,7 @@ char BasicAA::PassID; -BasicAAResult BasicAA::run(Function &F, AnalysisManager &AM) { +BasicAAResult BasicAA::run(Function &F, AnalysisManager &AM) { return BasicAAResult(F.getParent()->getDataLayout(), AM.getResult(F), AM.getResult(F), Index: lib/Analysis/BlockFrequencyInfo.cpp =================================================================== --- lib/Analysis/BlockFrequencyInfo.cpp +++ lib/Analysis/BlockFrequencyInfo.cpp @@ -257,15 +257,15 @@ char BlockFrequencyAnalysis::PassID; BlockFrequencyInfo BlockFrequencyAnalysis::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { BlockFrequencyInfo BFI; BFI.calculate(F, AM.getResult(F), AM.getResult(F)); return BFI; } -PreservedAnalyses -BlockFrequencyPrinterPass::run(Function &F, AnalysisManager &AM) { +PreservedAnalyses BlockFrequencyPrinterPass::run(Function &F, + AnalysisManager &AM) { OS << "Printing analysis results of BFI for function " << "'" << F.getName() << "':" << "\n"; Index: lib/Analysis/BranchProbabilityInfo.cpp =================================================================== --- lib/Analysis/BranchProbabilityInfo.cpp +++ lib/Analysis/BranchProbabilityInfo.cpp @@ -703,14 +703,14 @@ char BranchProbabilityAnalysis::PassID; BranchProbabilityInfo -BranchProbabilityAnalysis::run(Function &F, AnalysisManager &AM) { +BranchProbabilityAnalysis::run(Function &F, AnalysisManager &AM) { BranchProbabilityInfo BPI; BPI.calculate(F, AM.getResult(F)); return BPI; } PreservedAnalyses -BranchProbabilityPrinterPass::run(Function &F, AnalysisManager &AM) { +BranchProbabilityPrinterPass::run(Function &F, AnalysisManager &AM) { OS << "Printing analysis results of BPI for function " << "'" << F.getName() << "':" << "\n"; Index: lib/Analysis/CFLAndersAliasAnalysis.cpp =================================================================== --- lib/Analysis/CFLAndersAliasAnalysis.cpp +++ lib/Analysis/CFLAndersAliasAnalysis.cpp @@ -869,7 +869,7 @@ char CFLAndersAA::PassID; -CFLAndersAAResult CFLAndersAA::run(Function &F, AnalysisManager &AM) { +CFLAndersAAResult CFLAndersAA::run(Function &F, AnalysisManager &AM) { return CFLAndersAAResult(AM.getResult(F)); } Index: lib/Analysis/CFLSteensAliasAnalysis.cpp =================================================================== --- lib/Analysis/CFLSteensAliasAnalysis.cpp +++ lib/Analysis/CFLSteensAliasAnalysis.cpp @@ -343,7 +343,7 @@ char CFLSteensAA::PassID; -CFLSteensAAResult CFLSteensAA::run(Function &F, AnalysisManager &AM) { +CFLSteensAAResult CFLSteensAA::run(Function &F, AnalysisManager &AM) { return CFLSteensAAResult(AM.getResult(F)); } Index: lib/Analysis/CGSCCPassManager.cpp =================================================================== --- lib/Analysis/CGSCCPassManager.cpp +++ lib/Analysis/CGSCCPassManager.cpp @@ -11,14 +11,9 @@ using namespace llvm; -// Explicit instantiations for the core proxy templates. +// Explicit instantiations for the pass manager. namespace llvm { template class PassManager; -template class AnalysisManager; -template class InnerAnalysisManagerProxy; -template class OuterAnalysisManagerProxy; -template class InnerAnalysisManagerProxy; -template class OuterAnalysisManagerProxy; +template struct ParentIRUnitTrackingAnalysis; +template <> char ParentIRUnitTrackingAnalysis::PassID = 0; } Index: lib/Analysis/CallGraph.cpp =================================================================== --- lib/Analysis/CallGraph.cpp +++ lib/Analysis/CallGraph.cpp @@ -260,8 +260,7 @@ // Provide an explicit template instantiation for the static ID. char CallGraphAnalysis::PassID; -PreservedAnalyses CallGraphPrinterPass::run(Module &M, - AnalysisManager &AM) { +PreservedAnalyses CallGraphPrinterPass::run(Module &M, AnalysisManager &AM) { AM.getResult(M).print(OS); return PreservedAnalyses::all(); } Index: lib/Analysis/DemandedBits.cpp =================================================================== --- lib/Analysis/DemandedBits.cpp +++ lib/Analysis/DemandedBits.cpp @@ -388,15 +388,14 @@ char DemandedBitsAnalysis::PassID; -DemandedBits DemandedBitsAnalysis::run(Function &F, - AnalysisManager &AM) { +DemandedBits DemandedBitsAnalysis::run(Function &F, AnalysisManager &AM) { auto &AC = AM.getResult(F); auto &DT = AM.getResult(F); return DemandedBits(F, AC, DT); } PreservedAnalyses DemandedBitsPrinterPass::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { AM.getResult(F).print(OS); return PreservedAnalyses::all(); } Index: lib/Analysis/DependenceAnalysis.cpp =================================================================== --- lib/Analysis/DependenceAnalysis.cpp +++ lib/Analysis/DependenceAnalysis.cpp @@ -114,11 +114,11 @@ //===----------------------------------------------------------------------===// // basics -DependenceAnalysis::Result -DependenceAnalysis::run(Function &F, FunctionAnalysisManager &FAM) { - auto &AA = FAM.getResult(F); - auto &SE = FAM.getResult(F); - auto &LI = FAM.getResult(F); +DependenceAnalysis::Result DependenceAnalysis::run(Function &F, + AnalysisManager &AM) { + auto &AA = AM.getResult(F); + auto &SE = AM.getResult(F); + auto &LI = AM.getResult(F); return DependenceInfo(&F, &AA, &SE, &LI); } Index: lib/Analysis/DominanceFrontier.cpp =================================================================== --- lib/Analysis/DominanceFrontier.cpp +++ lib/Analysis/DominanceFrontier.cpp @@ -59,7 +59,7 @@ char DominanceFrontierAnalysis::PassID; DominanceFrontier DominanceFrontierAnalysis::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { DominanceFrontier DF; DF.analyze(AM.getResult(F)); return DF; @@ -69,7 +69,7 @@ : OS(OS) {} PreservedAnalyses -DominanceFrontierPrinterPass::run(Function &F, FunctionAnalysisManager &AM) { +DominanceFrontierPrinterPass::run(Function &F, AnalysisManager &AM) { OS << "DominanceFrontier for function: " << F.getName() << "\n"; AM.getResult(F).print(OS); Index: lib/Analysis/GlobalsModRef.cpp =================================================================== --- lib/Analysis/GlobalsModRef.cpp +++ lib/Analysis/GlobalsModRef.cpp @@ -939,7 +939,7 @@ char GlobalsAA::PassID; -GlobalsAAResult GlobalsAA::run(Module &M, AnalysisManager &AM) { +GlobalsAAResult GlobalsAA::run(Module &M, AnalysisManager &AM) { return GlobalsAAResult::analyzeModule(M, AM.getResult(M), AM.getResult(M)); Index: lib/Analysis/IVUsers.cpp =================================================================== --- lib/Analysis/IVUsers.cpp +++ lib/Analysis/IVUsers.cpp @@ -36,18 +36,16 @@ char IVUsersAnalysis::PassID; -IVUsers IVUsersAnalysis::run(Loop &L, AnalysisManager &AM) { - const auto &FAM = - AM.getResult(L).getManager(); +IVUsers IVUsersAnalysis::run(Loop &L, AnalysisManager &AM) { Function *F = L.getHeader()->getParent(); - return IVUsers(&L, FAM.getCachedResult(*F), - FAM.getCachedResult(*F), - FAM.getCachedResult(*F), - FAM.getCachedResult(*F)); + return IVUsers(&L, AM.getCachedResult(*F), + AM.getCachedResult(*F), + AM.getCachedResult(*F), + AM.getCachedResult(*F)); } -PreservedAnalyses IVUsersPrinterPass::run(Loop &L, AnalysisManager &AM) { +PreservedAnalyses IVUsersPrinterPass::run(Loop &L, AnalysisManager &AM) { AM.getResult(L).print(OS); return PreservedAnalyses::all(); } Index: lib/Analysis/LazyCallGraph.cpp =================================================================== --- lib/Analysis/LazyCallGraph.cpp +++ lib/Analysis/LazyCallGraph.cpp @@ -1543,7 +1543,7 @@ } PreservedAnalyses LazyCallGraphPrinterPass::run(Module &M, - ModuleAnalysisManager &AM) { + AnalysisManager &AM) { LazyCallGraph &G = AM.getResult(M); OS << "Printing the call graph for module: " << M.getModuleIdentifier() @@ -1576,7 +1576,7 @@ } PreservedAnalyses LazyCallGraphDOTPrinterPass::run(Module &M, - ModuleAnalysisManager &AM) { + AnalysisManager &AM) { LazyCallGraph &G = AM.getResult(M); OS << "digraph \"" << DOT::EscapeString(M.getModuleIdentifier()) << "\" {\n"; Index: lib/Analysis/LazyValueInfo.cpp =================================================================== --- lib/Analysis/LazyValueInfo.cpp +++ lib/Analysis/LazyValueInfo.cpp @@ -1485,10 +1485,10 @@ void LazyValueInfoWrapperPass::releaseMemory() { Info.releaseMemory(); } -LazyValueInfo LazyValueAnalysis::run(Function &F, FunctionAnalysisManager &FAM) { - auto &AC = FAM.getResult(F); - auto &TLI = FAM.getResult(F); - auto *DT = FAM.getCachedResult(F); +LazyValueInfo LazyValueAnalysis::run(Function &F, AnalysisManager &AM) { + auto &AC = AM.getResult(F); + auto &TLI = AM.getResult(F); + auto *DT = AM.getCachedResult(F); return LazyValueInfo(&AC, &TLI, DT); } Index: lib/Analysis/LoopAccessAnalysis.cpp =================================================================== --- lib/Analysis/LoopAccessAnalysis.cpp +++ lib/Analysis/LoopAccessAnalysis.cpp @@ -2030,15 +2030,13 @@ char LoopAccessAnalysis::PassID; -LoopAccessInfo LoopAccessAnalysis::run(Loop &L, AnalysisManager &AM) { - const AnalysisManager &FAM = - AM.getResult(L).getManager(); +LoopAccessInfo LoopAccessAnalysis::run(Loop &L, AnalysisManager &AM) { Function &F = *L.getHeader()->getParent(); - auto *SE = FAM.getCachedResult(F); - auto *TLI = FAM.getCachedResult(F); - auto *AA = FAM.getCachedResult(F); - auto *DT = FAM.getCachedResult(F); - auto *LI = FAM.getCachedResult(F); + auto *SE = AM.getCachedResult(F); + auto *TLI = AM.getCachedResult(F); + auto *AA = AM.getCachedResult(F); + auto *DT = AM.getCachedResult(F); + auto *LI = AM.getCachedResult(F); if (!SE) report_fatal_error( "ScalarEvolution must have been cached at a higher level"); @@ -2051,8 +2049,7 @@ return LoopAccessInfo(&L, SE, TLI, AA, DT, LI); } -PreservedAnalyses LoopAccessInfoPrinterPass::run(Loop &L, - AnalysisManager &AM) { +PreservedAnalyses LoopAccessInfoPrinterPass::run(Loop &L, AnalysisManager &AM) { Function &F = *L.getHeader()->getParent(); auto &LAI = AM.getResult(L); OS << "Loop access info in function '" << F.getName() << "':\n"; Index: lib/Analysis/LoopInfo.cpp =================================================================== --- lib/Analysis/LoopInfo.cpp +++ lib/Analysis/LoopInfo.cpp @@ -651,7 +651,7 @@ char LoopAnalysis::PassID; -LoopInfo LoopAnalysis::run(Function &F, AnalysisManager &AM) { +LoopInfo LoopAnalysis::run(Function &F, AnalysisManager &AM) { // FIXME: Currently we create a LoopInfo from scratch for every function. // This may prove to be too wasteful due to deallocating and re-allocating // memory each time for the underlying map and vector datastructures. At some @@ -664,7 +664,7 @@ } PreservedAnalyses LoopPrinterPass::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { AM.getResult(F).print(OS); return PreservedAnalyses::all(); } @@ -673,7 +673,7 @@ PrintLoopPass::PrintLoopPass(raw_ostream &OS, const std::string &Banner) : OS(OS), Banner(Banner) {} -PreservedAnalyses PrintLoopPass::run(Loop &L, AnalysisManager &) { +PreservedAnalyses PrintLoopPass::run(Loop &L, AnalysisManager &) { OS << Banner; for (auto *Block : L.blocks()) if (Block) @@ -720,7 +720,7 @@ } PreservedAnalyses LoopVerifierPass::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { LoopInfo &LI = AM.getResult(F); LI.verify(); return PreservedAnalyses::all(); Index: lib/Analysis/LoopPass.cpp =================================================================== --- lib/Analysis/LoopPass.cpp +++ lib/Analysis/LoopPass.cpp @@ -48,8 +48,8 @@ [](BasicBlock *BB) { return BB; }); if (BBI != L->blocks().end() && isFunctionInPrintList((*BBI)->getParent()->getName())) { - AnalysisManager DummyLAM; - P.run(*L, DummyLAM); + AnalysisManager DummyAM; + P.run(*L, DummyAM); } return false; } Index: lib/Analysis/LoopPassManager.cpp =================================================================== --- lib/Analysis/LoopPassManager.cpp +++ lib/Analysis/LoopPassManager.cpp @@ -20,9 +20,8 @@ // Explicit instantiations for core typedef'ed templates. namespace llvm { template class PassManager; -template class AnalysisManager; -template class InnerAnalysisManagerProxy; -template class OuterAnalysisManagerProxy; +template struct ParentIRUnitTrackingAnalysis; +template <> char ParentIRUnitTrackingAnalysis::PassID = 0; } PreservedAnalyses llvm::getLoopPassPreservedAnalyses() { Index: lib/Analysis/MemoryDependenceAnalysis.cpp =================================================================== --- lib/Analysis/MemoryDependenceAnalysis.cpp +++ lib/Analysis/MemoryDependenceAnalysis.cpp @@ -1661,8 +1661,8 @@ char MemoryDependenceAnalysis::PassID; -MemoryDependenceResults -MemoryDependenceAnalysis::run(Function &F, AnalysisManager &AM) { +MemoryDependenceResults MemoryDependenceAnalysis::run(Function &F, + AnalysisManager &AM) { auto &AA = AM.getResult(F); auto &AC = AM.getResult(F); auto &TLI = AM.getResult(F); Index: lib/Analysis/ObjCARCAliasAnalysis.cpp =================================================================== --- lib/Analysis/ObjCARCAliasAnalysis.cpp +++ lib/Analysis/ObjCARCAliasAnalysis.cpp @@ -131,7 +131,7 @@ return AAResultBase::getModRefInfo(CS, Loc); } -ObjCARCAAResult ObjCARCAA::run(Function &F, AnalysisManager &AM) { +ObjCARCAAResult ObjCARCAA::run(Function &F, AnalysisManager &AM) { return ObjCARCAAResult(F.getParent()->getDataLayout()); } Index: lib/Analysis/OptimizationDiagnosticInfo.cpp =================================================================== --- lib/Analysis/OptimizationDiagnosticInfo.cpp +++ lib/Analysis/OptimizationDiagnosticInfo.cpp @@ -119,7 +119,7 @@ OptimizationRemarkEmitter OptimizationRemarkEmitterAnalysis::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { BlockFrequencyInfo *BFI; if (F.getContext().getDiagnosticHotnessRequested()) Index: lib/Analysis/PostDominators.cpp =================================================================== --- lib/Analysis/PostDominators.cpp +++ lib/Analysis/PostDominators.cpp @@ -47,7 +47,7 @@ char PostDominatorTreeAnalysis::PassID; PostDominatorTree PostDominatorTreeAnalysis::run(Function &F, - FunctionAnalysisManager &) { + AnalysisManager &) { PostDominatorTree PDT; PDT.recalculate(F); return PDT; @@ -56,8 +56,8 @@ PostDominatorTreePrinterPass::PostDominatorTreePrinterPass(raw_ostream &OS) : OS(OS) {} -PreservedAnalyses -PostDominatorTreePrinterPass::run(Function &F, FunctionAnalysisManager &AM) { +PreservedAnalyses PostDominatorTreePrinterPass::run(Function &F, + AnalysisManager &AM) { OS << "PostDominatorTree for function: " << F.getName() << "\n"; AM.getResult(F).print(OS); Index: lib/Analysis/ProfileSummaryInfo.cpp =================================================================== --- lib/Analysis/ProfileSummaryInfo.cpp +++ lib/Analysis/ProfileSummaryInfo.cpp @@ -140,15 +140,14 @@ } char ProfileSummaryAnalysis::PassID; -ProfileSummaryInfo ProfileSummaryAnalysis::run(Module &M, - ModuleAnalysisManager &) { +ProfileSummaryInfo ProfileSummaryAnalysis::run(Module &M, AnalysisManager &) { return ProfileSummaryInfo(M); } // FIXME: This only tests isHotFunction and isColdFunction and not the // isHotCount and isColdCount calls. PreservedAnalyses ProfileSummaryPrinterPass::run(Module &M, - AnalysisManager &AM) { + AnalysisManager &AM) { ProfileSummaryInfo &PSI = AM.getResult(M); OS << "Functions in " << M.getName() << " with hot/cold annotations: \n"; Index: lib/Analysis/RegionInfo.cpp =================================================================== --- lib/Analysis/RegionInfo.cpp +++ lib/Analysis/RegionInfo.cpp @@ -184,7 +184,7 @@ char RegionInfoAnalysis::PassID; -RegionInfo RegionInfoAnalysis::run(Function &F, AnalysisManager &AM) { +RegionInfo RegionInfoAnalysis::run(Function &F, AnalysisManager &AM) { RegionInfo RI; auto *DT = &AM.getResult(F); auto *PDT = &AM.getResult(F); @@ -197,8 +197,7 @@ RegionInfoPrinterPass::RegionInfoPrinterPass(raw_ostream &OS) : OS(OS) {} -PreservedAnalyses RegionInfoPrinterPass::run(Function &F, - FunctionAnalysisManager &AM) { +PreservedAnalyses RegionInfoPrinterPass::run(Function &F, AnalysisManager &AM) { OS << "Region Tree for function: " << F.getName() << "\n"; AM.getResult(F).print(OS); @@ -206,7 +205,7 @@ } PreservedAnalyses RegionInfoVerifierPass::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { AM.getResult(F).verifyAnalysis(); return PreservedAnalyses::all(); Index: lib/Analysis/ScalarEvolution.cpp =================================================================== --- lib/Analysis/ScalarEvolution.cpp +++ lib/Analysis/ScalarEvolution.cpp @@ -9998,8 +9998,7 @@ char ScalarEvolutionAnalysis::PassID; -ScalarEvolution ScalarEvolutionAnalysis::run(Function &F, - AnalysisManager &AM) { +ScalarEvolution ScalarEvolutionAnalysis::run(Function &F, AnalysisManager &AM) { return ScalarEvolution(F, AM.getResult(F), AM.getResult(F), AM.getResult(F), @@ -10007,7 +10006,7 @@ } PreservedAnalyses -ScalarEvolutionPrinterPass::run(Function &F, AnalysisManager &AM) { +ScalarEvolutionPrinterPass::run(Function &F, AnalysisManager &AM) { AM.getResult(F).print(OS); return PreservedAnalyses::all(); } Index: lib/Analysis/ScalarEvolutionAliasAnalysis.cpp =================================================================== --- lib/Analysis/ScalarEvolutionAliasAnalysis.cpp +++ lib/Analysis/ScalarEvolutionAliasAnalysis.cpp @@ -112,7 +112,7 @@ char SCEVAA::PassID; -SCEVAAResult SCEVAA::run(Function &F, AnalysisManager &AM) { +SCEVAAResult SCEVAA::run(Function &F, AnalysisManager &AM) { return SCEVAAResult(AM.getResult(F)); } Index: lib/Analysis/ScopedNoAliasAA.cpp =================================================================== --- lib/Analysis/ScopedNoAliasAA.cpp +++ lib/Analysis/ScopedNoAliasAA.cpp @@ -175,7 +175,7 @@ char ScopedNoAliasAA::PassID; ScopedNoAliasAAResult ScopedNoAliasAA::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { return ScopedNoAliasAAResult(); } Index: lib/Analysis/TargetLibraryInfo.cpp =================================================================== --- lib/Analysis/TargetLibraryInfo.cpp +++ lib/Analysis/TargetLibraryInfo.cpp @@ -1191,16 +1191,14 @@ return I->ScalarFnName; } -TargetLibraryInfo TargetLibraryAnalysis::run(Module &M, - ModuleAnalysisManager &) { +TargetLibraryInfo TargetLibraryAnalysis::run(Module &M, AnalysisManager &) { if (PresetInfoImpl) return TargetLibraryInfo(*PresetInfoImpl); return TargetLibraryInfo(lookupInfoImpl(Triple(M.getTargetTriple()))); } -TargetLibraryInfo TargetLibraryAnalysis::run(Function &F, - FunctionAnalysisManager &) { +TargetLibraryInfo TargetLibraryAnalysis::run(Function &F, AnalysisManager &) { if (PresetInfoImpl) return TargetLibraryInfo(*PresetInfoImpl); Index: lib/Analysis/TargetTransformInfo.cpp =================================================================== --- lib/Analysis/TargetTransformInfo.cpp +++ lib/Analysis/TargetTransformInfo.cpp @@ -427,7 +427,7 @@ : TTICallback(std::move(TTICallback)) {} TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F, - AnalysisManager &) { + AnalysisManager &) { return TTICallback(F); } @@ -458,8 +458,8 @@ } TargetTransformInfo &TargetTransformInfoWrapperPass::getTTI(const Function &F) { - AnalysisManager DummyFAM; - TTI = TIRA.run(F, DummyFAM); + AnalysisManager DummyAM; + TTI = TIRA.run(F, DummyAM); return *TTI; } Index: lib/Analysis/TypeBasedAliasAnalysis.cpp =================================================================== --- lib/Analysis/TypeBasedAliasAnalysis.cpp +++ lib/Analysis/TypeBasedAliasAnalysis.cpp @@ -585,7 +585,7 @@ char TypeBasedAA::PassID; -TypeBasedAAResult TypeBasedAA::run(Function &F, AnalysisManager &AM) { +TypeBasedAAResult TypeBasedAA::run(Function &F, AnalysisManager &AM) { return TypeBasedAAResult(); } Index: lib/Bitcode/Writer/BitcodeWriterPass.cpp =================================================================== --- lib/Bitcode/Writer/BitcodeWriterPass.cpp +++ lib/Bitcode/Writer/BitcodeWriterPass.cpp @@ -19,7 +19,7 @@ #include "llvm/Pass.h" using namespace llvm; -PreservedAnalyses BitcodeWriterPass::run(Module &M, ModuleAnalysisManager &) { +PreservedAnalyses BitcodeWriterPass::run(Module &M, AnalysisManager &) { std::unique_ptr Index; if (EmitSummaryIndex) Index = ModuleSummaryIndexBuilder(&M).takeIndex(); Index: lib/CodeGen/PreISelIntrinsicLowering.cpp =================================================================== --- lib/CodeGen/PreISelIntrinsicLowering.cpp +++ lib/CodeGen/PreISelIntrinsicLowering.cpp @@ -85,7 +85,7 @@ } PreservedAnalyses PreISelIntrinsicLoweringPass::run(Module &M, - ModuleAnalysisManager &AM) { + AnalysisManager &AM) { if (!lowerIntrinsics(M)) return PreservedAnalyses::all(); else Index: lib/CodeGen/UnreachableBlockElim.cpp =================================================================== --- lib/CodeGen/UnreachableBlockElim.cpp +++ lib/CodeGen/UnreachableBlockElim.cpp @@ -97,7 +97,7 @@ } PreservedAnalyses UnreachableBlockElimPass::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { bool Changed = eliminateUnreachableBlock(F); if (!Changed) return PreservedAnalyses::all(); Index: lib/IR/Dominators.cpp =================================================================== --- lib/IR/Dominators.cpp +++ lib/IR/Dominators.cpp @@ -301,7 +301,7 @@ //===----------------------------------------------------------------------===// DominatorTree DominatorTreeAnalysis::run(Function &F, - AnalysisManager &) { + AnalysisManager &) { DominatorTree DT; DT.recalculate(F); return DT; @@ -312,7 +312,7 @@ DominatorTreePrinterPass::DominatorTreePrinterPass(raw_ostream &OS) : OS(OS) {} PreservedAnalyses DominatorTreePrinterPass::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { OS << "DominatorTree for function: " << F.getName() << "\n"; AM.getResult(F).print(OS); @@ -320,7 +320,7 @@ } PreservedAnalyses DominatorTreeVerifierPass::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { AM.getResult(F).verifyDomTree(); return PreservedAnalyses::all(); Index: lib/IR/IRPrintingPasses.cpp =================================================================== --- lib/IR/IRPrintingPasses.cpp +++ lib/IR/IRPrintingPasses.cpp @@ -26,7 +26,7 @@ : OS(OS), Banner(Banner), ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {} -PreservedAnalyses PrintModulePass::run(Module &M, AnalysisManager &) { +PreservedAnalyses PrintModulePass::run(Module &M, AnalysisManager &) { OS << Banner; if (llvm::isFunctionInPrintList("*")) M.print(OS, nullptr, ShouldPreserveUseListOrder); @@ -43,7 +43,7 @@ : OS(OS), Banner(Banner) {} PreservedAnalyses PrintFunctionPass::run(Function &F, - AnalysisManager &) { + AnalysisManager &) { if (isFunctionInPrintList(F.getName())) OS << Banner << static_cast(F); return PreservedAnalyses::all(); @@ -62,8 +62,8 @@ : ModulePass(ID), P(OS, Banner, ShouldPreserveUseListOrder) {} bool runOnModule(Module &M) override { - ModuleAnalysisManager DummyMAM; - P.run(M, DummyMAM); + AnalysisManager DummyAM; + P.run(M, DummyAM); return false; } @@ -83,8 +83,8 @@ // This pass just prints a banner followed by the function as it's processed. bool runOnFunction(Function &F) override { - FunctionAnalysisManager DummyFAM; - P.run(F, DummyFAM); + AnalysisManager DummyAM; + P.run(F, DummyAM); return false; } Index: lib/IR/PassManager.cpp =================================================================== --- lib/IR/PassManager.cpp +++ lib/IR/PassManager.cpp @@ -17,8 +17,9 @@ namespace llvm { template class PassManager; template class PassManager; -template class AnalysisManager; -template class AnalysisManager; -template class InnerAnalysisManagerProxy; -template class OuterAnalysisManagerProxy; + +template struct ParentIRUnitTrackingAnalysis; +template <> char ParentIRUnitTrackingAnalysis::PassID = 0; +template struct ParentIRUnitTrackingAnalysis; +template <> char ParentIRUnitTrackingAnalysis::PassID = 0; } Index: lib/IR/Verifier.cpp =================================================================== --- lib/IR/Verifier.cpp +++ lib/IR/Verifier.cpp @@ -4422,18 +4422,18 @@ char VerifierAnalysis::PassID; VerifierAnalysis::Result VerifierAnalysis::run(Module &M, - ModuleAnalysisManager &) { + AnalysisManager &) { Result Res; Res.IRBroken = llvm::verifyModule(M, &dbgs(), &Res.DebugInfoBroken); return Res; } VerifierAnalysis::Result VerifierAnalysis::run(Function &F, - FunctionAnalysisManager &) { + AnalysisManager &) { return { llvm::verifyFunction(F, &dbgs()), false }; } -PreservedAnalyses VerifierPass::run(Module &M, ModuleAnalysisManager &AM) { +PreservedAnalyses VerifierPass::run(Module &M, AnalysisManager &AM) { auto Res = AM.getResult(M); if (FatalErrors) { if (Res.IRBroken) @@ -4451,7 +4451,7 @@ return PreservedAnalyses::all(); } -PreservedAnalyses VerifierPass::run(Function &F, FunctionAnalysisManager &AM) { +PreservedAnalyses VerifierPass::run(Function &F, AnalysisManager &AM) { auto res = AM.getResult(F); if (res.IRBroken && FatalErrors) report_fatal_error("Broken function found, compilation aborted!"); Index: lib/Passes/PassBuilder.cpp =================================================================== --- lib/Passes/PassBuilder.cpp +++ lib/Passes/PassBuilder.cpp @@ -135,7 +135,7 @@ /// \brief No-op module pass which does nothing. struct NoOpModulePass { - PreservedAnalyses run(Module &M, AnalysisManager &) { + PreservedAnalyses run(Module &M, AnalysisManager &) { return PreservedAnalyses::all(); } static StringRef name() { return "NoOpModulePass"; } @@ -148,14 +148,14 @@ public: struct Result {}; - Result run(Module &, AnalysisManager &) { 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, - AnalysisManager &) { + AnalysisManager &) { return PreservedAnalyses::all(); } static StringRef name() { return "NoOpCGSCCPass"; } @@ -168,7 +168,7 @@ public: struct Result {}; - Result run(LazyCallGraph::SCC &, AnalysisManager &) { + Result run(LazyCallGraph::SCC &, AnalysisManager &) { return Result(); } static StringRef name() { return "NoOpCGSCCAnalysis"; } @@ -176,7 +176,7 @@ /// \brief No-op function pass which does nothing. struct NoOpFunctionPass { - PreservedAnalyses run(Function &F, AnalysisManager &) { + PreservedAnalyses run(Function &F, AnalysisManager &) { return PreservedAnalyses::all(); } static StringRef name() { return "NoOpFunctionPass"; } @@ -189,13 +189,13 @@ public: struct Result {}; - Result run(Function &, AnalysisManager &) { 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, AnalysisManager &) { + PreservedAnalyses run(Loop &L, AnalysisManager &) { return PreservedAnalyses::all(); } static StringRef name() { return "NoOpLoopPass"; } @@ -208,7 +208,7 @@ public: struct Result {}; - Result run(Loop &, AnalysisManager &) { return Result(); } + Result run(Loop &, AnalysisManager &) { return Result(); } static StringRef name() { return "NoOpLoopAnalysis"; } }; @@ -219,27 +219,27 @@ } // End anonymous namespace. -void PassBuilder::registerModuleAnalyses(ModuleAnalysisManager &MAM) { +void PassBuilder::registerModuleAnalyses(AnalysisManager &AM) { #define MODULE_ANALYSIS(NAME, CREATE_PASS) \ - MAM.registerPass([&] { return CREATE_PASS; }); + AM.registerPass([&] { return CREATE_PASS; }); #include "PassRegistry.def" } -void PassBuilder::registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM) { +void PassBuilder::registerCGSCCAnalyses(AnalysisManager &AM) { #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \ - CGAM.registerPass([&] { return CREATE_PASS; }); + AM.registerPass([&] { return CREATE_PASS; }); #include "PassRegistry.def" } -void PassBuilder::registerFunctionAnalyses(FunctionAnalysisManager &FAM) { +void PassBuilder::registerFunctionAnalyses(AnalysisManager &AM) { #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \ - FAM.registerPass([&] { return CREATE_PASS; }); + AM.registerPass([&] { return CREATE_PASS; }); #include "PassRegistry.def" } -void PassBuilder::registerLoopAnalyses(LoopAnalysisManager &LAM) { +void PassBuilder::registerLoopAnalyses(AnalysisManager &AM) { #define LOOP_ANALYSIS(NAME, CREATE_PASS) \ - LAM.registerPass([&] { return CREATE_PASS; }); + AM.registerPass([&] { return CREATE_PASS; }); #include "PassRegistry.def" } @@ -751,20 +751,6 @@ return true; } -void PassBuilder::crossRegisterProxies(LoopAnalysisManager &LAM, - FunctionAnalysisManager &FAM, - CGSCCAnalysisManager &CGAM, - ModuleAnalysisManager &MAM) { - MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); }); - MAM.registerPass([&] { return CGSCCAnalysisManagerModuleProxy(CGAM); }); - CGAM.registerPass([&] { return FunctionAnalysisManagerCGSCCProxy(FAM); }); - CGAM.registerPass([&] { return ModuleAnalysisManagerCGSCCProxy(MAM); }); - FAM.registerPass([&] { return CGSCCAnalysisManagerFunctionProxy(CGAM); }); - FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); }); - FAM.registerPass([&] { return LoopAnalysisManagerFunctionProxy(LAM); }); - LAM.registerPass([&] { return FunctionAnalysisManagerLoopProxy(FAM); }); -} - bool PassBuilder::parseModulePassPipeline(ModulePassManager &MPM, ArrayRef Pipeline, bool VerifyEachPass, Index: lib/Passes/PassRegistry.def =================================================================== --- lib/Passes/PassRegistry.def +++ lib/Passes/PassRegistry.def @@ -24,6 +24,8 @@ MODULE_ANALYSIS("no-op-module", NoOpModuleAnalysis()) MODULE_ANALYSIS("profile-summary", ProfileSummaryAnalysis()) MODULE_ANALYSIS("targetlibinfo", TargetLibraryAnalysis()) +MODULE_ANALYSIS("parent-irunit-tracking", + ParentIRUnitTrackingAnalysis()) MODULE_ANALYSIS("verify", VerifierAnalysis()) #ifndef MODULE_ALIAS_ANALYSIS @@ -75,6 +77,8 @@ #define CGSCC_ANALYSIS(NAME, CREATE_PASS) #endif CGSCC_ANALYSIS("no-op-cgscc", NoOpCGSCCAnalysis()) +CGSCC_ANALYSIS("parent-irunit-tracking", + ParentIRUnitTrackingAnalysis()) #undef CGSCC_ANALYSIS #ifndef CGSCC_PASS @@ -109,6 +113,8 @@ FUNCTION_ANALYSIS("targetir", TM ? TM->getTargetIRAnalysis() : TargetIRAnalysis()) FUNCTION_ANALYSIS("verify", VerifierAnalysis()) +FUNCTION_ANALYSIS("parent-irunit-tracking", + ParentIRUnitTrackingAnalysis()) #ifndef FUNCTION_ALIAS_ANALYSIS #define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \ @@ -192,6 +198,7 @@ LOOP_ANALYSIS("no-op-loop", NoOpLoopAnalysis()) LOOP_ANALYSIS("access-info", LoopAccessAnalysis()) LOOP_ANALYSIS("ivusers", IVUsersAnalysis()) +LOOP_ANALYSIS("parent-irunit-tracking", ParentIRUnitTrackingAnalysis()) #undef LOOP_ANALYSIS #ifndef LOOP_PASS Index: lib/Transforms/IPO/ConstantMerge.cpp =================================================================== --- lib/Transforms/IPO/ConstantMerge.cpp +++ lib/Transforms/IPO/ConstantMerge.cpp @@ -192,7 +192,7 @@ } } -PreservedAnalyses ConstantMergePass::run(Module &M, ModuleAnalysisManager &) { +PreservedAnalyses ConstantMergePass::run(Module &M, AnalysisManager &) { if (!mergeConstants(M)) return PreservedAnalyses::all(); return PreservedAnalyses::none(); Index: lib/Transforms/IPO/CrossDSOCFI.cpp =================================================================== --- lib/Transforms/IPO/CrossDSOCFI.cpp +++ lib/Transforms/IPO/CrossDSOCFI.cpp @@ -155,7 +155,7 @@ return true; } -PreservedAnalyses CrossDSOCFIPass::run(Module &M, AnalysisManager &AM) { +PreservedAnalyses CrossDSOCFIPass::run(Module &M, AnalysisManager &AM) { CrossDSOCFI Impl; bool Changed = Impl.runOnModule(M); if (!Changed) Index: lib/Transforms/IPO/DeadArgumentElimination.cpp =================================================================== --- lib/Transforms/IPO/DeadArgumentElimination.cpp +++ lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -64,8 +64,8 @@ if (skipModule(M)) return false; DeadArgumentEliminationPass DAEP(ShouldHackArguments()); - ModuleAnalysisManager DummyMAM; - PreservedAnalyses PA = DAEP.run(M, DummyMAM); + AnalysisManager DummyAM; + PreservedAnalyses PA = DAEP.run(M, DummyAM); return !PA.areAllPreserved(); } @@ -1030,7 +1030,7 @@ } PreservedAnalyses DeadArgumentEliminationPass::run(Module &M, - ModuleAnalysisManager &) { + AnalysisManager &) { bool Changed = false; // First pass: Do a simple check to see if any functions can have their "..." Index: lib/Transforms/IPO/ElimAvailExtern.cpp =================================================================== --- lib/Transforms/IPO/ElimAvailExtern.cpp +++ lib/Transforms/IPO/ElimAvailExtern.cpp @@ -62,7 +62,7 @@ } PreservedAnalyses -EliminateAvailableExternallyPass::run(Module &M, ModuleAnalysisManager &) { +EliminateAvailableExternallyPass::run(Module &M, AnalysisManager &) { if (!eliminateAvailableExternally(M)) return PreservedAnalyses::all(); return PreservedAnalyses::none(); Index: lib/Transforms/IPO/ForceFunctionAttrs.cpp =================================================================== --- lib/Transforms/IPO/ForceFunctionAttrs.cpp +++ lib/Transforms/IPO/ForceFunctionAttrs.cpp @@ -81,7 +81,7 @@ } PreservedAnalyses ForceFunctionAttrsPass::run(Module &M, - ModuleAnalysisManager &) { + AnalysisManager &) { if (ForceAttributes.empty()) return PreservedAnalyses::all(); Index: lib/Transforms/IPO/FunctionAttrs.cpp =================================================================== --- lib/Transforms/IPO/FunctionAttrs.cpp +++ lib/Transforms/IPO/FunctionAttrs.cpp @@ -1035,14 +1035,11 @@ } PreservedAnalyses PostOrderFunctionAttrsPass::run(LazyCallGraph::SCC &C, - CGSCCAnalysisManager &AM) { - FunctionAnalysisManager &FAM = - AM.getResult(C).getManager(); - + AnalysisManager &AM) { // We pass a lambda into functions to wire them up to the analysis manager // for getting function analyses. auto AARGetter = [&](Function &F) -> AAResults & { - return FAM.getResult(F); + return AM.getResult(F); }; // Fill SCCNodes with the elements of the SCC. Also track whether there are @@ -1267,7 +1264,7 @@ } PreservedAnalyses -ReversePostOrderFunctionAttrsPass::run(Module &M, AnalysisManager &AM) { +ReversePostOrderFunctionAttrsPass::run(Module &M, AnalysisManager &AM) { auto &CG = AM.getResult(M); bool Changed = deduceFunctionAttributeInRPO(M, CG); Index: lib/Transforms/IPO/FunctionImport.cpp =================================================================== --- lib/Transforms/IPO/FunctionImport.cpp +++ lib/Transforms/IPO/FunctionImport.cpp @@ -785,7 +785,7 @@ } // anonymous namespace PreservedAnalyses FunctionImportPass::run(Module &M, - AnalysisManager &AM) { + AnalysisManager &AM) { if (!doImportingForModule(M, Index)) return PreservedAnalyses::all(); Index: lib/Transforms/IPO/GlobalDCE.cpp =================================================================== --- lib/Transforms/IPO/GlobalDCE.cpp +++ lib/Transforms/IPO/GlobalDCE.cpp @@ -50,8 +50,8 @@ if (skipModule(M)) return false; - ModuleAnalysisManager DummyMAM; - auto PA = Impl.run(M, DummyMAM); + AnalysisManager DummyAM; + auto PA = Impl.run(M, DummyAM); return !PA.areAllPreserved(); } @@ -78,7 +78,7 @@ return RI.getReturnValue() == nullptr; } -PreservedAnalyses GlobalDCEPass::run(Module &M, ModuleAnalysisManager &) { +PreservedAnalyses GlobalDCEPass::run(Module &M, AnalysisManager &) { bool Changed = false; // Remove empty functions from the global ctors list. Index: lib/Transforms/IPO/GlobalOpt.cpp =================================================================== --- lib/Transforms/IPO/GlobalOpt.cpp +++ lib/Transforms/IPO/GlobalOpt.cpp @@ -2565,13 +2565,11 @@ return Changed; } -PreservedAnalyses GlobalOptPass::run(Module &M, AnalysisManager &AM) { +PreservedAnalyses GlobalOptPass::run(Module &M, AnalysisManager &AM) { auto &DL = M.getDataLayout(); auto &TLI = AM.getResult(M); - auto &FAM = - AM.getResult(M).getManager(); - auto LookupDomTree = [&FAM](Function &F) -> DominatorTree &{ - return FAM.getResult(F); + auto LookupDomTree = [&AM](Function &F) -> DominatorTree & { + return AM.getResult(F); }; if (!optimizeGlobalsInModule(M, DL, &TLI, LookupDomTree)) return PreservedAnalyses::all(); Index: lib/Transforms/IPO/InferFunctionAttrs.cpp =================================================================== --- lib/Transforms/IPO/InferFunctionAttrs.cpp +++ lib/Transforms/IPO/InferFunctionAttrs.cpp @@ -34,7 +34,7 @@ } PreservedAnalyses InferFunctionAttrsPass::run(Module &M, - AnalysisManager &AM) { + AnalysisManager &AM) { auto &TLI = AM.getResult(M); if (!inferAllPrototypeAttributes(M, TLI)) Index: lib/Transforms/IPO/Internalize.cpp =================================================================== --- lib/Transforms/IPO/Internalize.cpp +++ lib/Transforms/IPO/Internalize.cpp @@ -239,7 +239,7 @@ InternalizePass::InternalizePass() : MustPreserveGV(PreserveAPIList()) {} -PreservedAnalyses InternalizePass::run(Module &M, AnalysisManager &AM) { +PreservedAnalyses InternalizePass::run(Module &M, AnalysisManager &AM) { if (!internalizeModule(M, AM.getCachedResult(M))) return PreservedAnalyses::all(); Index: lib/Transforms/IPO/LowerTypeTests.cpp =================================================================== --- lib/Transforms/IPO/LowerTypeTests.cpp +++ lib/Transforms/IPO/LowerTypeTests.cpp @@ -1060,7 +1060,7 @@ } PreservedAnalyses LowerTypeTestsPass::run(Module &M, - AnalysisManager &AM) { + AnalysisManager &AM) { LowerTypeTests Impl; init(&Impl, M); bool Changed = Impl.lower(); Index: lib/Transforms/IPO/PartialInlining.cpp =================================================================== --- lib/Transforms/IPO/PartialInlining.cpp +++ lib/Transforms/IPO/PartialInlining.cpp @@ -210,12 +210,10 @@ return new PartialInlinerLegacyPass(); } -PreservedAnalyses PartialInlinerPass::run(Module &M, - ModuleAnalysisManager &AM) { - auto &FAM = AM.getResult(M).getManager(); +PreservedAnalyses PartialInlinerPass::run(Module &M, AnalysisManager &AM) { std::function GetAssumptionCache = - [&FAM](Function &F) -> AssumptionCache & { - return FAM.getResult(F); + [&](Function &F) -> AssumptionCache & { + return AM.getResult(F); }; InlineFunctionInfo IFI(nullptr, &GetAssumptionCache); if (PartialInlinerImpl(IFI).run(M)) Index: lib/Transforms/IPO/SampleProfile.cpp =================================================================== --- lib/Transforms/IPO/SampleProfile.cpp +++ lib/Transforms/IPO/SampleProfile.cpp @@ -1253,7 +1253,7 @@ } PreservedAnalyses SampleProfileLoaderPass::run(Module &M, - AnalysisManager &AM) { + AnalysisManager &AM) { SampleProfileLoader SampleLoader(SampleProfileFile); Index: lib/Transforms/IPO/StripDeadPrototypes.cpp =================================================================== --- lib/Transforms/IPO/StripDeadPrototypes.cpp +++ lib/Transforms/IPO/StripDeadPrototypes.cpp @@ -54,7 +54,7 @@ } PreservedAnalyses StripDeadPrototypesPass::run(Module &M, - ModuleAnalysisManager &) { + AnalysisManager &) { if (stripDeadPrototypes(M)) return PreservedAnalyses::none(); return PreservedAnalyses::all(); Index: lib/Transforms/IPO/WholeProgramDevirt.cpp =================================================================== --- lib/Transforms/IPO/WholeProgramDevirt.cpp +++ lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -314,7 +314,7 @@ } PreservedAnalyses WholeProgramDevirtPass::run(Module &M, - ModuleAnalysisManager &) { + AnalysisManager &) { if (!DevirtModule(M).run()) return PreservedAnalyses::all(); return PreservedAnalyses::none(); Index: lib/Transforms/InstCombine/InstructionCombining.cpp =================================================================== --- lib/Transforms/InstCombine/InstructionCombining.cpp +++ lib/Transforms/InstCombine/InstructionCombining.cpp @@ -3175,7 +3175,7 @@ } PreservedAnalyses InstCombinePass::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { auto &AC = AM.getResult(F); auto &DT = AM.getResult(F); auto &TLI = AM.getResult(F); Index: lib/Transforms/Instrumentation/GCOVProfiling.cpp =================================================================== --- lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -453,7 +453,7 @@ } PreservedAnalyses GCOVProfilerPass::run(Module &M, - AnalysisManager &AM) { + AnalysisManager &AM) { GCOVProfiler Profiler(GCOVOpts); Index: lib/Transforms/Instrumentation/IndirectCallPromotion.cpp =================================================================== --- lib/Transforms/Instrumentation/IndirectCallPromotion.cpp +++ lib/Transforms/Instrumentation/IndirectCallPromotion.cpp @@ -653,7 +653,7 @@ return promoteIndirectCalls(M, InLTO | ICPLTOMode); } -PreservedAnalyses PGOIndirectCallPromotion::run(Module &M, AnalysisManager &AM) { +PreservedAnalyses PGOIndirectCallPromotion::run(Module &M, AnalysisManager &AM) { if (!promoteIndirectCalls(M, InLTO | ICPLTOMode)) return PreservedAnalyses::all(); Index: lib/Transforms/Instrumentation/InstrProfiling.cpp =================================================================== --- lib/Transforms/Instrumentation/InstrProfiling.cpp +++ lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -66,7 +66,7 @@ } // anonymous namespace -PreservedAnalyses InstrProfiling::run(Module &M, AnalysisManager &AM) { +PreservedAnalyses InstrProfiling::run(Module &M, AnalysisManager &AM) { if (!run(M)) return PreservedAnalyses::all(); Index: lib/Transforms/Instrumentation/PGOInstrumentation.cpp =================================================================== --- lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -964,15 +964,13 @@ } PreservedAnalyses PGOInstrumentationGen::run(Module &M, - AnalysisManager &AM) { - - auto &FAM = AM.getResult(M).getManager(); - auto LookupBPI = [&FAM](Function &F) { - return &FAM.getResult(F); + AnalysisManager &AM) { + auto LookupBPI = [&AM](Function &F) { + return &AM.getResult(F); }; - auto LookupBFI = [&FAM](Function &F) { - return &FAM.getResult(F); + auto LookupBFI = [&AM](Function &F) { + return &AM.getResult(F); }; if (!InstrumentAllFunctions(M, LookupBPI, LookupBFI)) @@ -1056,15 +1054,13 @@ } PreservedAnalyses PGOInstrumentationUse::run(Module &M, - AnalysisManager &AM) { - - auto &FAM = AM.getResult(M).getManager(); - auto LookupBPI = [&FAM](Function &F) { - return &FAM.getResult(F); + AnalysisManager &AM) { + auto LookupBPI = [&AM](Function &F) { + return &AM.getResult(F); }; - auto LookupBFI = [&FAM](Function &F) { - return &FAM.getResult(F); + auto LookupBFI = [&AM](Function &F) { + return &AM.getResult(F); }; if (!annotateAllFunctions(M, ProfileFileName, LookupBPI, LookupBFI)) Index: lib/Transforms/Scalar/ADCE.cpp =================================================================== --- lib/Transforms/Scalar/ADCE.cpp +++ lib/Transforms/Scalar/ADCE.cpp @@ -200,7 +200,7 @@ return !Worklist.empty(); } -PreservedAnalyses ADCEPass::run(Function &F, FunctionAnalysisManager &) { +PreservedAnalyses ADCEPass::run(Function &F, AnalysisManager &) { if (!AggressiveDeadCodeElimination(F).performDeadCodeElimination()) return PreservedAnalyses::all(); Index: lib/Transforms/Scalar/AlignmentFromAssumptions.cpp =================================================================== --- lib/Transforms/Scalar/AlignmentFromAssumptions.cpp +++ lib/Transforms/Scalar/AlignmentFromAssumptions.cpp @@ -428,7 +428,7 @@ } PreservedAnalyses -AlignmentFromAssumptionsPass::run(Function &F, FunctionAnalysisManager &AM) { +AlignmentFromAssumptionsPass::run(Function &F, AnalysisManager &AM) { AssumptionCache &AC = AM.getResult(F); ScalarEvolution &SE = AM.getResult(F); Index: lib/Transforms/Scalar/BDCE.cpp =================================================================== --- lib/Transforms/Scalar/BDCE.cpp +++ lib/Transforms/Scalar/BDCE.cpp @@ -69,7 +69,7 @@ return Changed; } -PreservedAnalyses BDCEPass::run(Function &F, FunctionAnalysisManager &AM) { +PreservedAnalyses BDCEPass::run(Function &F, AnalysisManager &AM) { auto &DB = AM.getResult(F); if (!bitTrackingDCE(F, DB)) return PreservedAnalyses::all(); Index: lib/Transforms/Scalar/ConstantHoisting.cpp =================================================================== --- lib/Transforms/Scalar/ConstantHoisting.cpp +++ lib/Transforms/Scalar/ConstantHoisting.cpp @@ -617,7 +617,7 @@ } PreservedAnalyses ConstantHoistingPass::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { auto &DT = AM.getResult(F); auto &TTI = AM.getResult(F); if (!runImpl(F, TTI, DT, F.getEntryBlock())) Index: lib/Transforms/Scalar/CorrelatedValuePropagation.cpp =================================================================== --- lib/Transforms/Scalar/CorrelatedValuePropagation.cpp +++ lib/Transforms/Scalar/CorrelatedValuePropagation.cpp @@ -475,7 +475,7 @@ } PreservedAnalyses -CorrelatedValuePropagationPass::run(Function &F, FunctionAnalysisManager &AM) { +CorrelatedValuePropagationPass::run(Function &F, AnalysisManager &AM) { LazyValueInfo *LVI = &AM.getResult(F); bool Changed = runImpl(F, LVI); Index: lib/Transforms/Scalar/DCE.cpp =================================================================== --- lib/Transforms/Scalar/DCE.cpp +++ lib/Transforms/Scalar/DCE.cpp @@ -123,7 +123,7 @@ return MadeChange; } -PreservedAnalyses DCEPass::run(Function &F, AnalysisManager &AM) { +PreservedAnalyses DCEPass::run(Function &F, AnalysisManager &AM) { if (eliminateDeadCode(F, AM.getCachedResult(F))) return PreservedAnalyses::none(); return PreservedAnalyses::all(); Index: lib/Transforms/Scalar/DeadStoreElimination.cpp =================================================================== --- lib/Transforms/Scalar/DeadStoreElimination.cpp +++ lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -1129,7 +1129,7 @@ //===----------------------------------------------------------------------===// // DSE Pass //===----------------------------------------------------------------------===// -PreservedAnalyses DSEPass::run(Function &F, FunctionAnalysisManager &AM) { +PreservedAnalyses DSEPass::run(Function &F, AnalysisManager &AM) { AliasAnalysis *AA = &AM.getResult(F); DominatorTree *DT = &AM.getResult(F); MemoryDependenceResults *MD = &AM.getResult(F); Index: lib/Transforms/Scalar/EarlyCSE.cpp =================================================================== --- lib/Transforms/Scalar/EarlyCSE.cpp +++ lib/Transforms/Scalar/EarlyCSE.cpp @@ -847,7 +847,7 @@ } PreservedAnalyses EarlyCSEPass::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { auto &TLI = AM.getResult(F); auto &TTI = AM.getResult(F); auto &DT = AM.getResult(F); Index: lib/Transforms/Scalar/Float2Int.cpp =================================================================== --- lib/Transforms/Scalar/Float2Int.cpp +++ lib/Transforms/Scalar/Float2Int.cpp @@ -528,7 +528,7 @@ namespace llvm { FunctionPass *createFloat2IntPass() { return new Float2IntLegacyPass(); } -PreservedAnalyses Float2IntPass::run(Function &F, FunctionAnalysisManager &) { +PreservedAnalyses Float2IntPass::run(Function &F, AnalysisManager &) { if (!runImpl(F)) return PreservedAnalyses::all(); else { Index: lib/Transforms/Scalar/GVN.cpp =================================================================== --- lib/Transforms/Scalar/GVN.cpp +++ lib/Transforms/Scalar/GVN.cpp @@ -583,7 +583,7 @@ // GVN Pass //===----------------------------------------------------------------------===// -PreservedAnalyses GVN::run(Function &F, AnalysisManager &AM) { +PreservedAnalyses GVN::run(Function &F, AnalysisManager &AM) { // FIXME: The order of evaluation of these 'getResult' calls is very // significant! Re-ordering these variables will cause GVN when run alone to // be less effective! We should fix memdep and basic-aa to not exhibit this Index: lib/Transforms/Scalar/GVNHoist.cpp =================================================================== --- lib/Transforms/Scalar/GVNHoist.cpp +++ lib/Transforms/Scalar/GVNHoist.cpp @@ -940,7 +940,7 @@ } // namespace PreservedAnalyses GVNHoistPass::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { DominatorTree &DT = AM.getResult(F); AliasAnalysis &AA = AM.getResult(F); MemoryDependenceResults &MD = AM.getResult(F); Index: lib/Transforms/Scalar/GuardWidening.cpp =================================================================== --- lib/Transforms/Scalar/GuardWidening.cpp +++ lib/Transforms/Scalar/GuardWidening.cpp @@ -653,7 +653,7 @@ } PreservedAnalyses GuardWideningPass::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { auto &DT = AM.getResult(F); auto &LI = AM.getResult(F); auto &PDT = AM.getResult(F); Index: lib/Transforms/Scalar/IndVarSimplify.cpp =================================================================== --- lib/Transforms/Scalar/IndVarSimplify.cpp +++ lib/Transforms/Scalar/IndVarSimplify.cpp @@ -2213,21 +2213,20 @@ return Changed; } -PreservedAnalyses IndVarSimplifyPass::run(Loop &L, AnalysisManager &AM) { - auto &FAM = AM.getResult(L).getManager(); +PreservedAnalyses IndVarSimplifyPass::run(Loop &L, AnalysisManager &AM) { Function *F = L.getHeader()->getParent(); const DataLayout &DL = F->getParent()->getDataLayout(); - auto *LI = FAM.getCachedResult(*F); - auto *SE = FAM.getCachedResult(*F); - auto *DT = FAM.getCachedResult(*F); + auto *LI = AM.getCachedResult(*F); + auto *SE = AM.getCachedResult(*F); + auto *DT = AM.getCachedResult(*F); assert((LI && SE && DT) && "Analyses required for indvarsimplify not available!"); // Optional analyses. - auto *TTI = FAM.getCachedResult(*F); - auto *TLI = FAM.getCachedResult(*F); + auto *TTI = AM.getCachedResult(*F); + auto *TLI = AM.getCachedResult(*F); IndVarSimplify IVS(LI, SE, DT, DL, TLI, TTI); if (!IVS.run(&L)) Index: lib/Transforms/Scalar/JumpThreading.cpp =================================================================== --- lib/Transforms/Scalar/JumpThreading.cpp +++ lib/Transforms/Scalar/JumpThreading.cpp @@ -134,7 +134,7 @@ } PreservedAnalyses JumpThreadingPass::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { auto &TLI = AM.getResult(F); auto &LVI = AM.getResult(F); Index: lib/Transforms/Scalar/LICM.cpp =================================================================== --- lib/Transforms/Scalar/LICM.cpp +++ lib/Transforms/Scalar/LICM.cpp @@ -173,16 +173,14 @@ }; } -PreservedAnalyses LICMPass::run(Loop &L, AnalysisManager &AM) { - const auto &FAM = - AM.getResult(L).getManager(); +PreservedAnalyses LICMPass::run(Loop &L, AnalysisManager &AM) { Function *F = L.getHeader()->getParent(); - auto *AA = FAM.getCachedResult(*F); - auto *LI = FAM.getCachedResult(*F); - auto *DT = FAM.getCachedResult(*F); - auto *TLI = FAM.getCachedResult(*F); - auto *SE = FAM.getCachedResult(*F); + auto *AA = AM.getCachedResult(*F); + auto *LI = AM.getCachedResult(*F); + auto *DT = AM.getCachedResult(*F); + auto *TLI = AM.getCachedResult(*F); + auto *SE = AM.getCachedResult(*F); assert((AA && LI && DT && TLI && SE) && "Analyses for LICM not available"); LoopInvariantCodeMotion LICM; Index: lib/Transforms/Scalar/LoopDeletion.cpp =================================================================== --- lib/Transforms/Scalar/LoopDeletion.cpp +++ lib/Transforms/Scalar/LoopDeletion.cpp @@ -215,13 +215,12 @@ return Changed; } -PreservedAnalyses LoopDeletionPass::run(Loop &L, AnalysisManager &AM) { - auto &FAM = AM.getResult(L).getManager(); +PreservedAnalyses LoopDeletionPass::run(Loop &L, AnalysisManager &AM) { Function *F = L.getHeader()->getParent(); - auto &DT = *FAM.getCachedResult(*F); - auto &SE = *FAM.getCachedResult(*F); - auto &LI = *FAM.getCachedResult(*F); + auto &DT = *AM.getCachedResult(*F); + auto &SE = *AM.getCachedResult(*F); + auto &LI = *AM.getCachedResult(*F); bool Changed = runImpl(&L, DT, SE, LI); if (!Changed) Index: lib/Transforms/Scalar/LoopDistribute.cpp =================================================================== --- lib/Transforms/Scalar/LoopDistribute.cpp +++ lib/Transforms/Scalar/LoopDistribute.cpp @@ -942,7 +942,7 @@ } // anonymous namespace PreservedAnalyses LoopDistributePass::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { // FIXME: This does not currently match the behavior from the old PM. // ProcessAllLoops with the old PM defaults to true when invoked from opt and // false when invoked from the optimization pipeline. @@ -955,10 +955,9 @@ auto &SE = AM.getResult(F); auto &ORE = AM.getResult(F); - auto &LAM = AM.getResult(F).getManager(); std::function GetLAA = [&](Loop &L) -> const LoopAccessInfo & { - return LAM.getResult(L); + return AM.getResult(L); }; bool Changed = runImpl(F, &LI, &DT, &SE, &ORE, GetLAA, ProcessAllLoops); Index: lib/Transforms/Scalar/LoopIdiomRecognize.cpp =================================================================== --- lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -172,18 +172,16 @@ } // End anonymous namespace. PreservedAnalyses LoopIdiomRecognizePass::run(Loop &L, - AnalysisManager &AM) { - const auto &FAM = - AM.getResult(L).getManager(); + AnalysisManager &AM) { Function *F = L.getHeader()->getParent(); // Use getCachedResult because Loop pass cannot trigger a function analysis. - auto *AA = FAM.getCachedResult(*F); - auto *DT = FAM.getCachedResult(*F); - auto *LI = FAM.getCachedResult(*F); - auto *SE = FAM.getCachedResult(*F); - auto *TLI = FAM.getCachedResult(*F); - const auto *TTI = FAM.getCachedResult(*F); + auto *AA = AM.getCachedResult(*F); + auto *DT = AM.getCachedResult(*F); + auto *LI = AM.getCachedResult(*F); + auto *SE = AM.getCachedResult(*F); + auto *TLI = AM.getCachedResult(*F); + const auto *TTI = AM.getCachedResult(*F); const auto *DL = &L.getHeader()->getModule()->getDataLayout(); assert((AA && DT && LI && SE && TLI && TTI && DL) && "Analyses for Loop Idiom Recognition not available"); Index: lib/Transforms/Scalar/LoopInstSimplify.cpp =================================================================== --- lib/Transforms/Scalar/LoopInstSimplify.cpp +++ lib/Transforms/Scalar/LoopInstSimplify.cpp @@ -184,16 +184,14 @@ } PreservedAnalyses LoopInstSimplifyPass::run(Loop &L, - AnalysisManager &AM) { - const auto &FAM = - AM.getResult(L).getManager(); + AnalysisManager &AM) { Function *F = L.getHeader()->getParent(); // Use getCachedResult because Loop pass cannot trigger a function analysis. - auto *DT = FAM.getCachedResult(*F); - auto *LI = FAM.getCachedResult(*F); - auto *AC = FAM.getCachedResult(*F); - const auto *TLI = FAM.getCachedResult(*F); + auto *DT = AM.getCachedResult(*F); + auto *LI = AM.getCachedResult(*F); + auto *AC = AM.getCachedResult(*F); + const auto *TLI = AM.getCachedResult(*F); assert((LI && AC && TLI) && "Analyses for Loop Inst Simplify not available"); if (!SimplifyLoopInst(&L, DT, LI, AC, TLI)) Index: lib/Transforms/Scalar/LoopRotation.cpp =================================================================== --- lib/Transforms/Scalar/LoopRotation.cpp +++ lib/Transforms/Scalar/LoopRotation.cpp @@ -619,18 +619,17 @@ LoopRotatePass::LoopRotatePass() {} -PreservedAnalyses LoopRotatePass::run(Loop &L, AnalysisManager &AM) { - auto &FAM = AM.getResult(L).getManager(); +PreservedAnalyses LoopRotatePass::run(Loop &L, AnalysisManager &AM) { Function *F = L.getHeader()->getParent(); - auto *LI = FAM.getCachedResult(*F); - const auto *TTI = FAM.getCachedResult(*F); - auto *AC = FAM.getCachedResult(*F); + auto *LI = AM.getCachedResult(*F); + const auto *TTI = AM.getCachedResult(*F); + auto *AC = AM.getCachedResult(*F); assert((LI && TTI && AC) && "Analyses for loop rotation not available"); // Optional analyses. - auto *DT = FAM.getCachedResult(*F); - auto *SE = FAM.getCachedResult(*F); + auto *DT = AM.getCachedResult(*F); + auto *SE = AM.getCachedResult(*F); LoopRotate LR(DefaultRotationThreshold, LI, TTI, AC, DT, SE); bool Changed = LR.processLoop(&L); Index: lib/Transforms/Scalar/LoopSimplifyCFG.cpp =================================================================== --- lib/Transforms/Scalar/LoopSimplifyCFG.cpp +++ lib/Transforms/Scalar/LoopSimplifyCFG.cpp @@ -64,13 +64,11 @@ return Changed; } -PreservedAnalyses LoopSimplifyCFGPass::run(Loop &L, AnalysisManager &AM) { - const auto &FAM = - AM.getResult(L).getManager(); +PreservedAnalyses LoopSimplifyCFGPass::run(Loop &L, AnalysisManager &AM) { Function *F = L.getHeader()->getParent(); - auto *LI = FAM.getCachedResult(*F); - auto *DT = FAM.getCachedResult(*F); + auto *LI = AM.getCachedResult(*F); + auto *DT = AM.getCachedResult(*F); assert((LI && DT) && "Analyses for LoopSimplifyCFG not available"); if (!simplifyLoopCFG(L, *DT, *LI)) Index: lib/Transforms/Scalar/LoopStrengthReduce.cpp =================================================================== --- lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -5023,16 +5023,14 @@ } PreservedAnalyses LoopStrengthReducePass::run(Loop &L, - AnalysisManager &AM) { - const auto &FAM = - AM.getResult(L).getManager(); + AnalysisManager &AM) { Function *F = L.getHeader()->getParent(); auto &IU = AM.getResult(L); - auto *SE = FAM.getCachedResult(*F); - auto *DT = FAM.getCachedResult(*F); - auto *LI = FAM.getCachedResult(*F); - auto *TTI = FAM.getCachedResult(*F); + auto *SE = AM.getCachedResult(*F); + auto *DT = AM.getCachedResult(*F); + auto *LI = AM.getCachedResult(*F); + auto *TTI = AM.getCachedResult(*F); assert((SE && DT && LI && TTI) && "Analyses for Loop Strength Reduce not available"); Index: lib/Transforms/Scalar/LoopUnrollPass.cpp =================================================================== --- lib/Transforms/Scalar/LoopUnrollPass.cpp +++ lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -1058,18 +1058,16 @@ return llvm::createLoopUnrollPass(-1, -1, 0, 0); } -PreservedAnalyses LoopUnrollPass::run(Loop &L, AnalysisManager &AM) { - const auto &FAM = - AM.getResult(L).getManager(); +PreservedAnalyses LoopUnrollPass::run(Loop &L, AnalysisManager &AM) { Function *F = L.getHeader()->getParent(); - DominatorTree *DT = FAM.getCachedResult(*F); - LoopInfo *LI = FAM.getCachedResult(*F); - ScalarEvolution *SE = FAM.getCachedResult(*F); - auto *TTI = FAM.getCachedResult(*F); - auto *AC = FAM.getCachedResult(*F); - auto *ORE = FAM.getCachedResult(*F); + DominatorTree *DT = AM.getCachedResult(*F); + LoopInfo *LI = AM.getCachedResult(*F); + ScalarEvolution *SE = AM.getCachedResult(*F); + auto *TTI = AM.getCachedResult(*F); + auto *AC = AM.getCachedResult(*F); + auto *ORE = AM.getCachedResult(*F); if (!DT) report_fatal_error("LoopUnrollPass: DominatorTreeAnalysis not cached at a higher level"); if (!LI) Index: lib/Transforms/Scalar/LowerAtomic.cpp =================================================================== --- lib/Transforms/Scalar/LowerAtomic.cpp +++ lib/Transforms/Scalar/LowerAtomic.cpp @@ -139,7 +139,7 @@ return Changed; } -PreservedAnalyses LowerAtomicPass::run(Function &F, FunctionAnalysisManager &) { +PreservedAnalyses LowerAtomicPass::run(Function &F, AnalysisManager &) { if (lowerAtomics(F)) return PreservedAnalyses::none(); return PreservedAnalyses::all(); @@ -157,8 +157,8 @@ bool runOnFunction(Function &F) override { if (skipFunction(F)) return false; - FunctionAnalysisManager DummyFAM; - auto PA = Impl.run(F, DummyFAM); + AnalysisManager DummyAM; + auto PA = Impl.run(F, DummyAM); return !PA.areAllPreserved(); } Index: lib/Transforms/Scalar/LowerExpectIntrinsic.cpp =================================================================== --- lib/Transforms/Scalar/LowerExpectIntrinsic.cpp +++ lib/Transforms/Scalar/LowerExpectIntrinsic.cpp @@ -171,7 +171,7 @@ } PreservedAnalyses LowerExpectIntrinsicPass::run(Function &F, - FunctionAnalysisManager &) { + AnalysisManager &) { if (lowerExpectIntrinsic(F)) return PreservedAnalyses::none(); Index: lib/Transforms/Scalar/LowerGuardIntrinsic.cpp =================================================================== --- lib/Transforms/Scalar/LowerGuardIntrinsic.cpp +++ lib/Transforms/Scalar/LowerGuardIntrinsic.cpp @@ -129,7 +129,7 @@ } PreservedAnalyses LowerGuardIntrinsicPass::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { if (lowerGuardIntrinsic(F)) return PreservedAnalyses::none(); Index: lib/Transforms/Scalar/MemCpyOptimizer.cpp =================================================================== --- lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -1367,7 +1367,7 @@ return MadeChange; } -PreservedAnalyses MemCpyOptPass::run(Function &F, FunctionAnalysisManager &AM) { +PreservedAnalyses MemCpyOptPass::run(Function &F, AnalysisManager &AM) { auto &MD = AM.getResult(F); auto &TLI = AM.getResult(F); Index: lib/Transforms/Scalar/MergedLoadStoreMotion.cpp =================================================================== --- lib/Transforms/Scalar/MergedLoadStoreMotion.cpp +++ lib/Transforms/Scalar/MergedLoadStoreMotion.cpp @@ -589,7 +589,7 @@ "MergedLoadStoreMotion", false, false) PreservedAnalyses -MergedLoadStoreMotionPass::run(Function &F, AnalysisManager &AM) { +MergedLoadStoreMotionPass::run(Function &F, AnalysisManager &AM) { MergedLoadStoreMotion Impl; auto *MD = AM.getCachedResult(F); auto &AA = AM.getResult(F); Index: lib/Transforms/Scalar/NaryReassociate.cpp =================================================================== --- lib/Transforms/Scalar/NaryReassociate.cpp +++ lib/Transforms/Scalar/NaryReassociate.cpp @@ -149,7 +149,7 @@ } PreservedAnalyses NaryReassociatePass::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { auto *AC = &AM.getResult(F); auto *DT = &AM.getResult(F); auto *SE = &AM.getResult(F); Index: lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp =================================================================== --- lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp +++ lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp @@ -123,7 +123,7 @@ } PreservedAnalyses -PartiallyInlineLibCallsPass::run(Function &F, AnalysisManager &AM) { +PartiallyInlineLibCallsPass::run(Function &F, AnalysisManager &AM) { auto &TLI = AM.getResult(F); auto &TTI = AM.getResult(F); if (!runPartiallyInlineLibCalls(F, &TLI, &TTI)) Index: lib/Transforms/Scalar/Reassociate.cpp =================================================================== --- lib/Transforms/Scalar/Reassociate.cpp +++ lib/Transforms/Scalar/Reassociate.cpp @@ -2171,7 +2171,7 @@ RewriteExprTree(I, Ops); } -PreservedAnalyses ReassociatePass::run(Function &F, FunctionAnalysisManager &) { +PreservedAnalyses ReassociatePass::run(Function &F, AnalysisManager &) { // 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 @@ -2248,8 +2248,8 @@ if (skipFunction(F)) return false; - FunctionAnalysisManager DummyFAM; - auto PA = Impl.run(F, DummyFAM); + AnalysisManager DummyAM; + auto PA = Impl.run(F, DummyAM); return !PA.areAllPreserved(); } Index: lib/Transforms/Scalar/SCCP.cpp =================================================================== --- lib/Transforms/Scalar/SCCP.cpp +++ lib/Transforms/Scalar/SCCP.cpp @@ -1631,7 +1631,7 @@ return MadeChanges; } -PreservedAnalyses SCCPPass::run(Function &F, AnalysisManager &AM) { +PreservedAnalyses SCCPPass::run(Function &F, AnalysisManager &AM) { const DataLayout &DL = F.getParent()->getDataLayout(); auto &TLI = AM.getResult(F); if (!runSCCP(F, DL, &TLI)) @@ -1941,7 +1941,7 @@ return MadeChanges; } -PreservedAnalyses IPSCCPPass::run(Module &M, AnalysisManager &AM) { +PreservedAnalyses IPSCCPPass::run(Module &M, AnalysisManager &AM) { const DataLayout &DL = M.getDataLayout(); auto &TLI = AM.getResult(M); if (!runIPSCCP(M, DL, &TLI)) Index: lib/Transforms/Scalar/SROA.cpp =================================================================== --- lib/Transforms/Scalar/SROA.cpp +++ lib/Transforms/Scalar/SROA.cpp @@ -4253,7 +4253,7 @@ return PA; } -PreservedAnalyses SROA::run(Function &F, AnalysisManager &AM) { +PreservedAnalyses SROA::run(Function &F, AnalysisManager &AM) { return runImpl(F, AM.getResult(F), AM.getResult(F)); } Index: lib/Transforms/Scalar/SimplifyCFGPass.cpp =================================================================== --- lib/Transforms/Scalar/SimplifyCFGPass.cpp +++ lib/Transforms/Scalar/SimplifyCFGPass.cpp @@ -187,7 +187,7 @@ : BonusInstThreshold(BonusInstThreshold) {} PreservedAnalyses SimplifyCFGPass::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { auto &TTI = AM.getResult(F); auto &AC = AM.getResult(F); Index: lib/Transforms/Scalar/Sink.cpp =================================================================== --- lib/Transforms/Scalar/Sink.cpp +++ lib/Transforms/Scalar/Sink.cpp @@ -254,7 +254,7 @@ return EverMadeChange; } -PreservedAnalyses SinkingPass::run(Function &F, AnalysisManager &AM) { +PreservedAnalyses SinkingPass::run(Function &F, AnalysisManager &AM) { auto &DT = AM.getResult(F); auto &LI = AM.getResult(F); auto &AA = AM.getResult(F); Index: lib/Transforms/Scalar/SpeculativeExecution.cpp =================================================================== --- lib/Transforms/Scalar/SpeculativeExecution.cpp +++ lib/Transforms/Scalar/SpeculativeExecution.cpp @@ -287,7 +287,7 @@ SpecExecOnlyIfDivergentTarget) {} PreservedAnalyses SpeculativeExecutionPass::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { auto *TTI = &AM.getResult(F); bool Changed = runImpl(F, TTI); Index: lib/Transforms/Scalar/TailRecursionElimination.cpp =================================================================== --- lib/Transforms/Scalar/TailRecursionElimination.cpp +++ lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -826,7 +826,7 @@ } PreservedAnalyses TailCallElimPass::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { TargetTransformInfo &TTI = AM.getResult(F); Index: lib/Transforms/Utils/AddDiscriminators.cpp =================================================================== --- lib/Transforms/Utils/AddDiscriminators.cpp +++ lib/Transforms/Utils/AddDiscriminators.cpp @@ -249,7 +249,7 @@ return addDiscriminators(F); } PreservedAnalyses AddDiscriminatorsPass::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { if (!addDiscriminators(F)) return PreservedAnalyses::all(); Index: lib/Transforms/Utils/BreakCriticalEdges.cpp =================================================================== --- lib/Transforms/Utils/BreakCriticalEdges.cpp +++ lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -73,7 +73,7 @@ } PreservedAnalyses BreakCriticalEdgesPass::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { auto *DT = AM.getCachedResult(F); auto *LI = AM.getCachedResult(F); unsigned N = SplitAllCriticalEdges(F, CriticalEdgeSplittingOptions(DT, LI)); Index: lib/Transforms/Utils/LCSSA.cpp =================================================================== --- lib/Transforms/Utils/LCSSA.cpp +++ lib/Transforms/Utils/LCSSA.cpp @@ -360,7 +360,7 @@ return formLCSSAOnAllLoops(LI, *DT, SE); } -PreservedAnalyses LCSSAPass::run(Function &F, AnalysisManager &AM) { +PreservedAnalyses LCSSAPass::run(Function &F, AnalysisManager &AM) { auto &LI = AM.getResult(F); auto &DT = AM.getResult(F); auto *SE = AM.getCachedResult(F); Index: lib/Transforms/Utils/LoopSimplify.cpp =================================================================== --- lib/Transforms/Utils/LoopSimplify.cpp +++ lib/Transforms/Utils/LoopSimplify.cpp @@ -857,7 +857,7 @@ } PreservedAnalyses LoopSimplifyPass::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { bool Changed = false; LoopInfo *LI = &AM.getResult(F); DominatorTree *DT = &AM.getResult(F); Index: lib/Transforms/Utils/Mem2Reg.cpp =================================================================== --- lib/Transforms/Utils/Mem2Reg.cpp +++ lib/Transforms/Utils/Mem2Reg.cpp @@ -53,7 +53,7 @@ return Changed; } -PreservedAnalyses PromotePass::run(Function &F, AnalysisManager &AM) { +PreservedAnalyses PromotePass::run(Function &F, AnalysisManager &AM) { auto &DT = AM.getResult(F); auto &AC = AM.getResult(F); if (!promoteMemoryToRegister(F, DT, AC)) Index: lib/Transforms/Utils/MemorySSA.cpp =================================================================== --- lib/Transforms/Utils/MemorySSA.cpp +++ lib/Transforms/Utils/MemorySSA.cpp @@ -2083,14 +2083,14 @@ char MemorySSAAnalysis::PassID; -MemorySSA MemorySSAAnalysis::run(Function &F, AnalysisManager &AM) { +MemorySSA MemorySSAAnalysis::run(Function &F, AnalysisManager &AM) { auto &DT = AM.getResult(F); auto &AA = AM.getResult(F); return MemorySSA(F, &AA, &DT); } PreservedAnalyses MemorySSAPrinterPass::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { OS << "MemorySSA for function: " << F.getName() << "\n"; AM.getResult(F).print(OS); @@ -2098,7 +2098,7 @@ } PreservedAnalyses MemorySSAVerifierPass::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { AM.getResult(F).verifyMemorySSA(); return PreservedAnalyses::all(); Index: lib/Transforms/Utils/SimplifyInstructions.cpp =================================================================== --- lib/Transforms/Utils/SimplifyInstructions.cpp +++ lib/Transforms/Utils/SimplifyInstructions.cpp @@ -126,7 +126,7 @@ } PreservedAnalyses InstSimplifierPass::run(Function &F, - AnalysisManager &AM) { + AnalysisManager &AM) { auto *DT = AM.getCachedResult(F); auto &TLI = AM.getResult(F); auto &AC = AM.getResult(F); Index: lib/Transforms/Utils/SymbolRewriter.cpp =================================================================== --- lib/Transforms/Utils/SymbolRewriter.cpp +++ lib/Transforms/Utils/SymbolRewriter.cpp @@ -526,7 +526,7 @@ } namespace llvm { -PreservedAnalyses RewriteSymbolPass::run(Module &M, ModuleAnalysisManager &AM) { +PreservedAnalyses RewriteSymbolPass::run(Module &M, AnalysisManager &AM) { if (!runImpl(M)) return PreservedAnalyses::all(); Index: lib/Transforms/Vectorize/LoopVectorize.cpp =================================================================== --- lib/Transforms/Vectorize/LoopVectorize.cpp +++ lib/Transforms/Vectorize/LoopVectorize.cpp @@ -6817,7 +6817,7 @@ PreservedAnalyses LoopVectorizePass::run(Function &F, - FunctionAnalysisManager &AM) { + AnalysisManager &AM) { auto &SE = AM.getResult(F); auto &LI = AM.getResult(F); auto &TTI = AM.getResult(F); @@ -6829,10 +6829,9 @@ auto &DB = AM.getResult(F); auto &ORE = AM.getResult(F); - auto &LAM = AM.getResult(F).getManager(); std::function GetLAA = [&](Loop &L) -> const LoopAccessInfo & { - return LAM.getResult(L); + return AM.getResult(L); }; bool Changed = runImpl(F, SE, LI, TTI, DT, BFI, TLI, DB, AA, AC, GetLAA, ORE); Index: lib/Transforms/Vectorize/SLPVectorizer.cpp =================================================================== --- lib/Transforms/Vectorize/SLPVectorizer.cpp +++ lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -3507,7 +3507,7 @@ }; } // end anonymous namespace -PreservedAnalyses SLPVectorizerPass::run(Function &F, FunctionAnalysisManager &AM) { +PreservedAnalyses SLPVectorizerPass::run(Function &F, AnalysisManager &AM) { auto *SE = &AM.getResult(F); auto *TTI = &AM.getResult(F); auto *TLI = AM.getCachedResult(F); Index: test/Other/analysis-manager/transitive-invalidation.ll =================================================================== --- /dev/null +++ test/Other/analysis-manager/transitive-invalidation.ll @@ -0,0 +1,30 @@ +; RUN: opt '-passes=require,invalidate' -aa-pipeline=basic-aa \ +; RUN: -debug-pass-manager -disable-output < %s 2>&1 | FileCheck %s + +; CHECK: Running pass: InvalidateAnalysisPass +; CHECK-NEXT: Invalidating analysis: BasicAA +; CHECK-NEXT: Invalidating analysis: AAManager +; CHECK: Running pass: InvalidateAnalysisPass +; CHECK-NEXT: Invalidating analysis: BasicAA +; CHECK-NEXT: Invalidating analysis: AAManager + +; RUN: opt '-passes=require,function(require),invalidate' -aa-pipeline=globals-aa \ +; RUN: -debug-pass-manager -disable-output < %s 2>&1 | FileCheck %s --check-prefix=GLOBALS-AA +; GLOBALS-AA: Running pass: InvalidateAnalysisPass +; GLOBALS-AA-NEXT: Invalidating analysis: GlobalsAA +; GLOBALS-AA-NEXT: Invalidating analysis: AAManager +; GLOBALS-AA-NEXT: Invalidating analysis: AAManager + + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define void @foo() { +entry: + ret void +} + +define void @bar() { +entry: + ret void +} Index: test/Other/new-pass-manager.ll =================================================================== --- test/Other/new-pass-manager.ll +++ test/Other/new-pass-manager.ll @@ -20,7 +20,6 @@ ; RUN: | FileCheck %s --check-prefix=CHECK-CGSCC-PASS ; CHECK-CGSCC-PASS: Starting llvm::Module pass manager run ; CHECK-CGSCC-PASS-NEXT: Running pass: ModuleToPostOrderCGSCCPassAdaptor -; CHECK-CGSCC-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}> ; CHECK-CGSCC-PASS-NEXT: Running analysis: LazyCallGraphAnalysis ; CHECK-CGSCC-PASS-NEXT: Running an SCC pass across the RefSCC: [(foo)] ; CHECK-CGSCC-PASS-NEXT: Starting llvm::LazyCallGraph::SCC pass manager run @@ -36,7 +35,6 @@ ; RUN: | FileCheck %s --check-prefix=CHECK-FUNCTION-PASS ; CHECK-FUNCTION-PASS: Starting llvm::Module pass manager run ; CHECK-FUNCTION-PASS-NEXT: Running pass: ModuleToFunctionPassAdaptor -; CHECK-FUNCTION-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}> ; CHECK-FUNCTION-PASS-NEXT: Starting llvm::Function pass manager run ; CHECK-FUNCTION-PASS-NEXT: Running pass: NoOpFunctionPass ; CHECK-FUNCTION-PASS-NEXT: Finished llvm::Function pass manager run @@ -66,7 +64,6 @@ ; CHECK-FUNCTION-PRINT: Starting llvm::Module pass manager run ; CHECK-FUNCTION-PRINT: Running pass: VerifierPass ; CHECK-FUNCTION-PRINT: Running pass: ModuleToFunctionPassAdaptor -; CHECK-FUNCTION-PRINT: Running analysis: InnerAnalysisManagerProxy<{{.*}}> ; CHECK-FUNCTION-PRINT: Starting llvm::Function pass manager run ; CHECK-FUNCTION-PRINT: Running pass: PrintFunctionPass ; CHECK-FUNCTION-PRINT-NOT: ModuleID @@ -389,7 +386,6 @@ ; RUN: | FileCheck %s --check-prefix=CHECK-REPEAT-CGSCC-PASS ; CHECK-REPEAT-CGSCC-PASS: Starting llvm::Module pass manager run ; CHECK-REPEAT-CGSCC-PASS-NEXT: Running pass: ModuleToPostOrderCGSCCPassAdaptor -; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}> ; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: LazyCallGraphAnalysis ; CHECK-REPEAT-CGSCC-PASS-NEXT: Running an SCC pass across the RefSCC: [(foo)] ; CHECK-REPEAT-CGSCC-PASS-NEXT: Starting llvm::LazyCallGraph::SCC pass manager run @@ -411,7 +407,6 @@ ; RUN: | FileCheck %s --check-prefix=CHECK-REPEAT-FUNCTION-PASS ; CHECK-REPEAT-FUNCTION-PASS: Starting llvm::Module pass manager run ; CHECK-REPEAT-FUNCTION-PASS-NEXT: Running pass: ModuleToFunctionPassAdaptor -; CHECK-REPEAT-FUNCTION-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}> ; CHECK-REPEAT-FUNCTION-PASS-NEXT: Starting llvm::Function pass manager run ; CHECK-REPEAT-FUNCTION-PASS-NEXT: Running pass: RepeatedPass ; CHECK-REPEAT-FUNCTION-PASS-NEXT: Starting llvm::Function pass manager run @@ -431,11 +426,10 @@ ; RUN: | FileCheck %s --check-prefix=CHECK-REPEAT-LOOP-PASS ; CHECK-REPEAT-LOOP-PASS: Starting llvm::Module pass manager run ; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: ModuleToFunctionPassAdaptor -; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}> ; CHECK-REPEAT-LOOP-PASS-NEXT: Starting llvm::Function pass manager run ; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: FunctionToLoopPassAdaptor -; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}> ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: LoopAnalysis +; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: ParentIRUnitTrackingAnalysis ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: DominatorTreeAnalysis ; CHECK-REPEAT-LOOP-PASS-NEXT: Starting llvm::Loop pass manager run ; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: RepeatedPass Index: tools/opt/NewPMDriver.cpp =================================================================== --- tools/opt/NewPMDriver.cpp +++ tools/opt/NewPMDriver.cpp @@ -63,20 +63,16 @@ return false; } - LoopAnalysisManager LAM(DebugPM); - FunctionAnalysisManager FAM(DebugPM); - CGSCCAnalysisManager CGAM(DebugPM); - ModuleAnalysisManager MAM(DebugPM); + AnalysisManager AM(DebugPM); // Register the AA manager first so that our version is the one used. - FAM.registerPass([&] { return std::move(AA); }); + AM.registerPass([&] { return std::move(AA); }); // Register all the basic analyses with the managers. - PB.registerModuleAnalyses(MAM); - PB.registerCGSCCAnalyses(CGAM); - PB.registerFunctionAnalyses(FAM); - PB.registerLoopAnalyses(LAM); - PB.crossRegisterProxies(LAM, FAM, CGAM, MAM); + PB.registerModuleAnalyses(AM); + PB.registerCGSCCAnalyses(AM); + PB.registerFunctionAnalyses(AM); + PB.registerLoopAnalyses(AM); ModulePassManager MPM(DebugPM); if (VK > VK_NoVerifier) @@ -109,7 +105,7 @@ cl::PrintOptionValues(); // Now that we have all of the passes ready, run them. - MPM.run(M, MAM); + MPM.run(M, AM); // Declare success. if (OK != OK_NoOutput) Index: unittests/Analysis/CGSCCPassManagerTest.cpp =================================================================== --- unittests/Analysis/CGSCCPassManagerTest.cpp +++ unittests/Analysis/CGSCCPassManagerTest.cpp @@ -34,7 +34,7 @@ TestModuleAnalysis(int &Runs) : Runs(Runs) {} - Result run(Module &M, ModuleAnalysisManager &AM) { + Result run(Module &M, AnalysisManager &AM) { ++Runs; return Result(M.size()); } @@ -59,7 +59,7 @@ TestSCCAnalysis(int &Runs) : Runs(Runs) {} - Result run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM) { + Result run(LazyCallGraph::SCC &C, AnalysisManager &AM) { ++Runs; return Result(C.size()); } @@ -84,7 +84,7 @@ TestFunctionAnalysis(int &Runs) : Runs(Runs) {} - Result run(Function &F, FunctionAnalysisManager &AM) { + Result run(Function &F, AnalysisManager &AM) { ++Runs; int Count = 0; for (Instruction &I : instructions(F)) { @@ -113,7 +113,7 @@ TestImmutableFunctionAnalysis(int &Runs) : Runs(Runs) {} - Result run(Function &F, FunctionAnalysisManager &AM) { + Result run(Function &F, AnalysisManager &AM) { ++Runs; return Result(); } @@ -129,7 +129,7 @@ struct TestModulePass { TestModulePass(int &RunCount) : RunCount(RunCount) {} - PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM) { + PreservedAnalyses run(Module &M, AnalysisManager &AM) { ++RunCount; (void)AM.getResult(M); return PreservedAnalyses::all(); @@ -149,15 +149,11 @@ AnalyzedModuleFunctionCount(AnalyzedModuleFunctionCount), OnlyUseCachedResults(OnlyUseCachedResults) {} - PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM) { + PreservedAnalyses run(LazyCallGraph::SCC &C, AnalysisManager &AM) { ++RunCount; - const ModuleAnalysisManager &MAM = - AM.getResult(C).getManager(); - FunctionAnalysisManager &FAM = - AM.getResult(C).getManager(); if (TestModuleAnalysis::Result *TMA = - MAM.getCachedResult( + AM.getCachedResult( *C.begin()->getFunction().getParent())) AnalyzedModuleFunctionCount += TMA->FunctionCount; @@ -167,7 +163,7 @@ AnalyzedSCCFunctionCount += AR->FunctionCount; for (LazyCallGraph::Node &N : C) if (TestFunctionAnalysis::Result *FAR = - FAM.getCachedResult(N.getFunction())) + AM.getCachedResult(N.getFunction())) AnalyzedInstrCount += FAR->InstructionCount; } else { // Typical path just runs the analysis as needed. @@ -175,11 +171,11 @@ AnalyzedSCCFunctionCount += AR.FunctionCount; for (LazyCallGraph::Node &N : C) { TestFunctionAnalysis::Result &FAR = - FAM.getResult(N.getFunction()); + AM.getResult(N.getFunction()); AnalyzedInstrCount += FAR.InstructionCount; // Just ensure we get the immutable results. - (void)FAM.getResult(N.getFunction()); + (void)AM.getResult(N.getFunction()); } } @@ -198,7 +194,7 @@ struct TestFunctionPass { TestFunctionPass(int &RunCount) : RunCount(RunCount) {} - PreservedAnalyses run(Function &F, AnalysisManager &) { + PreservedAnalyses run(Function &F, AnalysisManager &) { ++RunCount; return PreservedAnalyses::none(); } @@ -250,29 +246,30 @@ "entry:\n" " ret void\n" "}\n"); - FunctionAnalysisManager FAM(/*DebugLogging*/ true); + AnalysisManager AM(/*DebugLogging*/ true); + AM.registerPass( + [&] { return ParentIRUnitTrackingAnalysis(); }); + AM.registerPass( + [&] { return ParentIRUnitTrackingAnalysis(); }); + AM.registerPass( + [&] { return ParentIRUnitTrackingAnalysis(); }); + int FunctionAnalysisRuns = 0; - FAM.registerPass([&] { return TestFunctionAnalysis(FunctionAnalysisRuns); }); + AM.registerPass( + [&] { return TestFunctionAnalysis(FunctionAnalysisRuns); }); int ImmutableFunctionAnalysisRuns = 0; - FAM.registerPass([&] { + AM.registerPass([&] { return TestImmutableFunctionAnalysis(ImmutableFunctionAnalysisRuns); }); - CGSCCAnalysisManager CGAM(/*DebugLogging*/ true); int SCCAnalysisRuns = 0; - CGAM.registerPass([&] { return TestSCCAnalysis(SCCAnalysisRuns); }); + AM.registerPass( + [&] { return TestSCCAnalysis(SCCAnalysisRuns); }); - ModuleAnalysisManager MAM(/*DebugLogging*/ true); int ModuleAnalysisRuns = 0; - MAM.registerPass([&] { return LazyCallGraphAnalysis(); }); - MAM.registerPass([&] { return TestModuleAnalysis(ModuleAnalysisRuns); }); - - MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); }); - MAM.registerPass([&] { return CGSCCAnalysisManagerModuleProxy(CGAM); }); - CGAM.registerPass([&] { return FunctionAnalysisManagerCGSCCProxy(FAM); }); - CGAM.registerPass([&] { return ModuleAnalysisManagerCGSCCProxy(MAM); }); - FAM.registerPass([&] { return CGSCCAnalysisManagerFunctionProxy(CGAM); }); - FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); }); + AM.registerPass([&] { return LazyCallGraphAnalysis(); }); + AM.registerPass( + [&] { return TestModuleAnalysis(ModuleAnalysisRuns); }); ModulePassManager MPM(/*DebugLogging*/ true); int ModulePassRunCount1 = 0; @@ -293,7 +290,7 @@ CGPM1.addPass(createCGSCCToFunctionPassAdaptor(std::move(FPM1))); MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM1))); - MPM.run(*M, MAM); + MPM.run(*M, AM); EXPECT_EQ(1, ModulePassRunCount1); Index: unittests/Analysis/LoopPassManagerTest.cpp =================================================================== --- unittests/Analysis/LoopPassManagerTest.cpp +++ unittests/Analysis/LoopPassManagerTest.cpp @@ -42,7 +42,7 @@ TestLoopAnalysis(int &Runs) : Runs(Runs) {} /// \brief Run the analysis pass over the loop and return a result. - Result run(Loop &L, AnalysisManager &AM) { + Result run(Loop &L, AnalysisManager &AM) { ++Runs; int Count = 0; @@ -65,7 +65,7 @@ : VisitedLoops(VisitedLoops), AnalyzedBlockCount(AnalyzedBlockCount), OnlyUseCachedResults(OnlyUseCachedResults) {} - PreservedAnalyses run(Loop &L, AnalysisManager &AM) { + PreservedAnalyses run(Loop &L, AnalysisManager &AM) { VisitedLoops.push_back(L.getName()); if (OnlyUseCachedResults) { @@ -91,7 +91,7 @@ public: TestLoopInvalidatingPass(StringRef LoopName) : Name(LoopName) {} - PreservedAnalyses run(Loop &L, AnalysisManager &AM) { + PreservedAnalyses run(Loop &L, AnalysisManager &AM) { return L.getName() == Name ? getLoopPassPreservedAnalyses() : PreservedAnalyses::all(); } @@ -144,20 +144,20 @@ } while (0) TEST_F(LoopPassManagerTest, Basic) { - LoopAnalysisManager LAM(true); + AnalysisManager AM(true); + AM.registerPass( + [&] { return ParentIRUnitTrackingAnalysis(); }); + AM.registerPass( + [&] { return ParentIRUnitTrackingAnalysis(); }); + AM.registerPass( + [&] { return ParentIRUnitTrackingAnalysis(); }); + int LoopAnalysisRuns = 0; - LAM.registerPass([&] { return TestLoopAnalysis(LoopAnalysisRuns); }); + AM.registerPass([&] { return TestLoopAnalysis(LoopAnalysisRuns); }); - FunctionAnalysisManager FAM(true); // We need DominatorTreeAnalysis for LoopAnalysis. - FAM.registerPass([&] { return DominatorTreeAnalysis(); }); - FAM.registerPass([&] { return LoopAnalysis(); }); - FAM.registerPass([&] { return LoopAnalysisManagerFunctionProxy(LAM); }); - LAM.registerPass([&] { return FunctionAnalysisManagerLoopProxy(FAM); }); - - ModuleAnalysisManager MAM(true); - MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); }); - FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); }); + AM.registerPass([&] { return DominatorTreeAnalysis(); }); + AM.registerPass([&] { return LoopAnalysis(); }); ModulePassManager MPM(true); FunctionPassManager FPM(true); @@ -185,7 +185,7 @@ } MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM))); - MPM.run(*M, MAM); + MPM.run(*M, AM); StringRef ExpectedLoops[] = {"loop.0.0", "loop.0.1", "loop.0", "loop.g.0"}; Index: unittests/IR/PassManagerTest.cpp =================================================================== --- unittests/IR/PassManagerTest.cpp +++ unittests/IR/PassManagerTest.cpp @@ -29,7 +29,7 @@ TestFunctionAnalysis(int &Runs) : Runs(Runs) {} /// \brief Run the analysis pass over the function and return a result. - Result run(Function &F, FunctionAnalysisManager &AM) { + Result run(Function &F, AnalysisManager &AM) { ++Runs; int Count = 0; for (Function::iterator BBI = F.begin(), BBE = F.end(); BBI != BBE; ++BBI) @@ -57,7 +57,7 @@ TestModuleAnalysis(int &Runs) : Runs(Runs) {} - Result run(Module &M, ModuleAnalysisManager &AM) { + Result run(Module &M, AnalysisManager &AM) { ++Runs; int Count = 0; for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) @@ -77,7 +77,7 @@ struct TestModulePass : PassInfoMixin { TestModulePass(int &RunCount) : RunCount(RunCount) {} - PreservedAnalyses run(Module &M, ModuleAnalysisManager &) { + PreservedAnalyses run(Module &M, AnalysisManager &) { ++RunCount; return PreservedAnalyses::none(); } @@ -86,20 +86,20 @@ }; struct TestPreservingModulePass : PassInfoMixin { - PreservedAnalyses run(Module &M, ModuleAnalysisManager &) { + PreservedAnalyses run(Module &M, AnalysisManager &) { return PreservedAnalyses::all(); } }; struct TestMinPreservingModulePass : PassInfoMixin { - PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM) { + PreservedAnalyses run(Module &M, AnalysisManager &AM) { PreservedAnalyses PA; // Force running an analysis. (void)AM.getResult(M); - PA.preserve(); + PA.preserve>(); return PA; } }; @@ -112,13 +112,11 @@ AnalyzedFunctionCount(AnalyzedFunctionCount), OnlyUseCachedResults(OnlyUseCachedResults) {} - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) { + PreservedAnalyses run(Function &F, AnalysisManager &AM) { ++RunCount; - const ModuleAnalysisManager &MAM = - AM.getResult(F).getManager(); if (TestModuleAnalysis::Result *TMA = - MAM.getCachedResult(*F.getParent())) + AM.getCachedResult(*F.getParent())) AnalyzedFunctionCount += TMA->FunctionCount; if (OnlyUseCachedResults) { @@ -147,7 +145,7 @@ : PassInfoMixin { TestInvalidationFunctionPass(StringRef FunctionName) : Name(FunctionName) {} - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) { + PreservedAnalyses run(Function &F, AnalysisManager &AM) { return F.getName() == Name ? PreservedAnalyses::none() : PreservedAnalyses::all(); } @@ -215,17 +213,19 @@ } TEST_F(PassManagerTest, Basic) { - FunctionAnalysisManager FAM; + AnalysisManager AM(true); + AM.registerPass( + [&] { return ParentIRUnitTrackingAnalysis(); }); + int FunctionAnalysisRuns = 0; - FAM.registerPass([&] { return TestFunctionAnalysis(FunctionAnalysisRuns); }); + AM.registerPass( + [&] { return TestFunctionAnalysis(FunctionAnalysisRuns); }); - ModuleAnalysisManager MAM; int ModuleAnalysisRuns = 0; - MAM.registerPass([&] { return TestModuleAnalysis(ModuleAnalysisRuns); }); - MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); }); - FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); }); + AM.registerPass( + [&] { return TestModuleAnalysis(ModuleAnalysisRuns); }); - ModulePassManager MPM; + ModulePassManager MPM(true); // Count the runs over a Function. int FunctionPassRunCount1 = 0; @@ -233,11 +233,11 @@ int AnalyzedFunctionCount1 = 0; { // Pointless scoped copy to test move assignment. - ModulePassManager NestedMPM; - FunctionPassManager FPM; + ModulePassManager NestedMPM(true); + FunctionPassManager FPM(true); { // Pointless scope to test move assignment. - FunctionPassManager NestedFPM; + FunctionPassManager NestedFPM(true); NestedFPM.addPass(TestFunctionPass( FunctionPassRunCount1, AnalyzedInstrCount1, AnalyzedFunctionCount1)); FPM = std::move(NestedFPM); @@ -255,7 +255,7 @@ int AnalyzedInstrCount2 = 0; int AnalyzedFunctionCount2 = 0; { - FunctionPassManager FPM; + FunctionPassManager FPM(true); FPM.addPass(TestFunctionPass(FunctionPassRunCount2, AnalyzedInstrCount2, AnalyzedFunctionCount2)); MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM))); @@ -268,7 +268,7 @@ int AnalyzedInstrCount3 = 0; int AnalyzedFunctionCount3 = 0; { - FunctionPassManager FPM; + FunctionPassManager FPM(true); FPM.addPass(TestFunctionPass(FunctionPassRunCount3, AnalyzedInstrCount3, AnalyzedFunctionCount3)); FPM.addPass(TestInvalidationFunctionPass("f")); @@ -281,7 +281,7 @@ int AnalyzedInstrCount4 = 0; int AnalyzedFunctionCount4 = 0; { - FunctionPassManager FPM; + FunctionPassManager FPM(true); FPM.addPass(TestFunctionPass(FunctionPassRunCount4, AnalyzedInstrCount4, AnalyzedFunctionCount4)); MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM))); @@ -292,7 +292,7 @@ int AnalyzedInstrCount5 = 0; int AnalyzedFunctionCount5 = 0; { - FunctionPassManager FPM; + FunctionPassManager FPM(true); FPM.addPass(TestInvalidationFunctionPass("f")); FPM.addPass(TestFunctionPass(FunctionPassRunCount5, AnalyzedInstrCount5, AnalyzedFunctionCount5, @@ -300,7 +300,7 @@ MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM))); } - MPM.run(*M, MAM); + MPM.run(*M, AM); // Validate module pass counters. EXPECT_EQ(1, ModulePassRunCount); Index: unittests/IR/VerifierTest.cpp =================================================================== --- unittests/IR/VerifierTest.cpp +++ unittests/IR/VerifierTest.cpp @@ -192,9 +192,9 @@ ModulePassManager MPM(true); MPM.addPass(VerifierPass(false)); - ModuleAnalysisManager MAM(true); - MAM.registerPass([&] { return VerifierAnalysis(); }); - MPM.run(M, MAM); + AnalysisManager AM(true); + AM.registerPass([&] { return VerifierAnalysis(); }); + MPM.run(M, AM); EXPECT_FALSE(verifyModule(M)); } #endif