88#ifndef LLVM_ANALYSIS_CGSCCPASSMANAGER_H
89#define LLVM_ANALYSIS_CGSCCPASSMANAGER_H
103template <
typename T,
unsigned int N>
class SmallPriorityWorklist;
104struct CGSCCUpdateResult;
109#define DEBUG_TYPE "cgscc"
115 AnalysisManager<LazyCallGraph::SCC, LazyCallGraph &>;
148template <
typename AnalysisT>
151 :
PassInfoMixin<RequireAnalysisPass<AnalysisT, LazyCallGraph::SCC,
152 CGSCCAnalysisManager, LazyCallGraph &,
153 CGSCCUpdateResult &>> {
156 (void)AM.template getResult<AnalysisT>(
C, CG);
161 auto ClassName = AnalysisT::name();
162 auto PassName = MapClassName2PassName(ClassName);
177 : InnerAM(&InnerAM),
G(&
G) {}
345 Pass->printPipeline(
OS, MapClassName2PassName);
352 std::unique_ptr<PassConceptT>
Pass;
357template <
typename CGSCCPassT>
358ModuleToPostOrderCGSCCPassAdaptor
366 std::unique_ptr<ModuleToPostOrderCGSCCPassAdaptor::PassConceptT>(
367 new PassModelT(std::forward<CGSCCPassT>(
Pass))));
453 bool EagerlyInvalidate,
bool NoRerun)
459 NoRerun(Arg.NoRerun) {}
479 if (EagerlyInvalidate || NoRerun) {
481 if (EagerlyInvalidate)
483 if (EagerlyInvalidate && NoRerun)
490 Pass->printPipeline(
OS, MapClassName2PassName);
497 std::unique_ptr<PassConceptT>
Pass;
498 bool EagerlyInvalidate;
504template <
typename FunctionPassT>
505CGSCCToFunctionPassAdaptor
507 bool EagerlyInvalidate =
false,
508 bool NoRerun =
false) {
514 std::unique_ptr<CGSCCToFunctionPassAdaptor::PassConceptT>(
515 new PassModelT(std::forward<FunctionPassT>(
Pass))),
516 EagerlyInvalidate, NoRerun);
565 OS <<
"devirt<" << MaxIterations <<
">(";
566 Pass->printPipeline(
OS, MapClassName2PassName);
571 std::unique_ptr<PassConceptT>
Pass;
577template <
typename CGSCCPassT>
586 std::unique_ptr<DevirtSCCRepeatedPass::PassConceptT>(
587 new PassModelT(std::forward<CGSCCPassT>(
Pass))),
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_TEMPLATE_ABI
This header defines various interfaces for pass management in LLVM.
Implements a lazy call graph analysis and related passes for the new pass manager.
Machine Check Debug Module
This file implements a map that provides insertion order iteration.
FunctionAnalysisManager FAM
static const char PassName[]
API to communicate dependencies between analyses during invalidation.
A container for analyses that lazily runs them and caches their results.
CGSCCAnalysisManager & getManager()
Accessor for the analysis manager.
Result(CGSCCAnalysisManager &InnerAM, LazyCallGraph &G)
Adaptor that maps from a SCC to its functions.
CGSCCToFunctionPassAdaptor(std::unique_ptr< PassConceptT > Pass, bool EagerlyInvalidate, bool NoRerun)
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
CGSCCToFunctionPassAdaptor & operator=(CGSCCToFunctionPassAdaptor RHS)
CGSCCToFunctionPassAdaptor(CGSCCToFunctionPassAdaptor &&Arg)
friend void swap(CGSCCToFunctionPassAdaptor &LHS, CGSCCToFunctionPassAdaptor &RHS)
A helper that repeats an SCC pass each time an indirect call is refined to a direct call by that pass...
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
DevirtSCCRepeatedPass(std::unique_ptr< PassConceptT > Pass, int MaxIterations)
LLVM_ABI bool invalidate(LazyCallGraph::SCC &C, const PreservedAnalyses &PA, CGSCCAnalysisManager::Invalidator &Inv)
void updateFAM(FunctionAnalysisManager &FAM)
FunctionAnalysisManager & getManager()
Accessor for the analysis manager.
Result(FunctionAnalysisManager &FAM)
A proxy from a FunctionAnalysisManager to an SCC.
LLVM_ABI Result run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &)
Computes the FunctionAnalysisManager and stores it in the result proxy.
bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA, typename AnalysisManager< IRUnitT, ExtraArgTs... >::Invalidator &Inv)
Handler for invalidation of the outer IR unit, IRUnitT.
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
Result run(IRUnitT &IR, AnalysisManager< IRUnitT, ExtraArgTs... > &AM, ExtraArgTs...)
Run the analysis pass and create our proxy result object.
A node in the call graph.
An SCC of the call graph.
A lazily constructed view of the call graph of a module.
The core module pass which does a post-order walk of the SCCs and runs a CGSCC pass over each one.
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Runs the CGSCC pass across every SCC in the module.
ModuleToPostOrderCGSCCPassAdaptor & operator=(ModuleToPostOrderCGSCCPassAdaptor RHS)
ModuleToPostOrderCGSCCPassAdaptor(std::unique_ptr< PassConceptT > Pass)
friend void swap(ModuleToPostOrderCGSCCPassAdaptor &LHS, ModuleToPostOrderCGSCCPassAdaptor &RHS)
ModuleToPostOrderCGSCCPassAdaptor(ModuleToPostOrderCGSCCPassAdaptor &&Arg)
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
A Module instance is used to store all the information related to an LLVM module.
An analysis over an "inner" IR unit that provides access to an analysis manager over a "outer" IR uni...
Manages a sequence of passes over a particular unit of IR.
Pass interface - Implemented by all 'passes'.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Result run(Function &F, FunctionAnalysisManager &FAM)
static LLVM_ABI AnalysisKey Key
Implements a dense probed hash-table based set with some number of buckets stored inline.
A version of PriorityWorklist that selects small size optimized data structures for the vector and ma...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
DevirtSCCRepeatedPass createDevirtSCCRepeatedPass(CGSCCPassT &&Pass, int MaxIterations)
A function to deduce a function pass type and wrap it in the templated adaptor.
LLVM_ABI LazyCallGraph::SCC & updateCGAndAnalysisManagerForFunctionPass(LazyCallGraph &G, LazyCallGraph::SCC &C, LazyCallGraph::Node &N, CGSCCAnalysisManager &AM, CGSCCUpdateResult &UR, FunctionAnalysisManager &FAM)
Helper to update the call graph after running a function pass.
template class LLVM_TEMPLATE_ABI OuterAnalysisManagerProxy< CGSCCAnalysisManager, Function >
LLVM_ABI LazyCallGraph::SCC & updateCGAndAnalysisManagerForCGSCCPass(LazyCallGraph &G, LazyCallGraph::SCC &C, LazyCallGraph::Node &N, CGSCCAnalysisManager &AM, CGSCCUpdateResult &UR, FunctionAnalysisManager &FAM)
Helper to update the call graph after running a CGSCC pass.
ModuleToPostOrderCGSCCPassAdaptor createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT &&Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
CGSCCToFunctionPassAdaptor createCGSCCToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false, bool NoRerun=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
AnalysisManager< LazyCallGraph::SCC, LazyCallGraph & > CGSCCAnalysisManager
The CGSCC analysis manager.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
SmallMapVector< Value *, WeakTrackingVH, 16 > IndirectVHs
Weak VHs to keep track of indirect calls for the purposes of detecting devirtualization.
SmallPriorityWorklist< LazyCallGraph::SCC *, 1 > & CWorklist
Worklist of the SCCs queued for processing.
SmallDenseSet< std::pair< LazyCallGraph::Node *, LazyCallGraph::SCC * >, 4 > & InlinedInternalEdges
A hacky area where the inliner can retain history about inlining decisions that mutated the call grap...
SmallVector< Function *, 4 > & DeadFunctions
Functions that a pass has considered to be dead to be removed at the end of the call graph walk in ba...
SmallPtrSetImpl< LazyCallGraph::SCC * > & InvalidatedSCCs
The set of invalidated SCCs which should be skipped if they are found in CWorklist.
LazyCallGraph::SCC * UpdatedC
If non-null, the updated current SCC being processed.
PreservedAnalyses CrossSCCPA
Preserved analyses across SCCs.
A CRTP mix-in to automatically provide informational APIs needed for passes.
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &)
A utility pass template to force an analysis result to be available.
A MapVector that performs no allocations if smaller than a certain size.
Template for the abstract base class used to dispatch polymorphically over pass objects.
A template wrapper used to implement the polymorphic API.