15#ifndef LLVM_PASSES_PASSBUILDER_H
16#define LLVM_PASSES_PASSBUILDER_H
37class ModuleSummaryIndex;
38template <
typename T>
class IntrusiveRefCntPtr;
109 std::optional<PGOOptions> PGOOpt;
128 std::optional<PGOOptions> PGOOpt = std::nullopt,
250 bool LTOPreLink =
false);
258 bool ThinLTO,
bool EmitSummary);
301 bool LTOPreLink =
false);
394 std::optional<RegAllocFilterFunc>
408 PeepholeEPCallbacks.push_back(
C);
422 LateLoopOptimizationsEPCallbacks.push_back(
C);
432 LoopOptimizerEndEPCallbacks.push_back(
C);
442 ScalarOptimizerLateEPCallbacks.push_back(
C);
453 CGSCCOptimizerLateEPCallbacks.push_back(
C);
464 VectorizerStartEPCallbacks.push_back(
C);
474 PipelineStartEPCallbacks.push_back(
C);
483 PipelineEarlySimplificationEPCallbacks.push_back(
C);
492 OptimizerEarlyEPCallbacks.push_back(
C);
501 OptimizerLastEPCallbacks.push_back(
C);
510 FullLinkTimeOptimizationEarlyEPCallbacks.push_back(
C);
519 FullLinkTimeOptimizationLastEPCallbacks.push_back(
C);
526 AAParsingCallbacks.push_back(
C);
534 CGSCCAnalysisRegistrationCallbacks.push_back(
C);
538 FunctionAnalysisRegistrationCallbacks.push_back(
C);
542 LoopAnalysisRegistrationCallbacks.push_back(
C);
546 ModuleAnalysisRegistrationCallbacks.push_back(
C);
550 MachineFunctionAnalysisRegistrationCallbacks.push_back(
C);
561 CGSCCPipelineParsingCallbacks.push_back(
C);
566 FunctionPipelineParsingCallbacks.push_back(
C);
571 LoopPipelineParsingCallbacks.push_back(
C);
576 ModulePipelineParsingCallbacks.push_back(
C);
581 MachineFunctionPipelineParsingCallbacks.push_back(
C);
590 RegClassFilterParsingCallbacks.push_back(
C);
604 bool IsCS,
bool AtomicCounterUpdate,
605 std::string ProfileFile,
606 std::string ProfileRemappingFile,
649 return Name.starts_with(
"<") &&
Name.ends_with(
">");
667 template <
typename ParametersParseCallableT>
671 using ParametersT =
typename decltype(Parser(
StringRef{}))::value_type;
673 StringRef Params =
Name;
674 if (!Params.consume_front(
PassName)) {
676 "unable to strip pass name from parametrized pass specification");
678 if (!Params.empty() &&
679 (!Params.consume_front(
"<") || !Params.consume_back(
">"))) {
683 Expected<ParametersT>
Result = Parser(Params);
684 assert((Result ||
Result.template errorIsA<StringError>()) &&
685 "Pass parameter parser can only return StringErrors.");
693 StringRef OptionName,
699 buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
707 static std::optional<std::vector<PipelineElement>>
708 parsePipelineText(StringRef Text);
715 const PipelineElement &
E);
716 bool parseAAPassName(AAManager &AA, StringRef
Name);
719 ArrayRef<PipelineElement> Pipeline);
721 ArrayRef<PipelineElement> Pipeline);
723 ArrayRef<PipelineElement> Pipeline);
725 ArrayRef<PipelineElement> Pipeline);
727 ArrayRef<PipelineElement> Pipeline);
736 bool RunProfileGen,
bool IsCS,
737 bool AtomicCounterUpdate, std::string ProfileFile,
738 std::string ProfileRemappingFile,
739 IntrusiveRefCntPtr<vfs::FileSystem> FS);
746 LateLoopOptimizationsEPCallbacks;
748 LoopOptimizerEndEPCallbacks;
750 ScalarOptimizerLateEPCallbacks;
752 CGSCCOptimizerLateEPCallbacks;
754 VectorizerStartEPCallbacks;
757 OptimizerEarlyEPCallbacks;
759 OptimizerLastEPCallbacks;
761 FullLinkTimeOptimizationEarlyEPCallbacks;
763 FullLinkTimeOptimizationLastEPCallbacks;
765 PipelineStartEPCallbacks;
767 PipelineEarlySimplificationEPCallbacks;
770 ModuleAnalysisRegistrationCallbacks;
772 ArrayRef<PipelineElement>)>,
774 ModulePipelineParsingCallbacks;
777 TopLevelPipelineParsingCallbacks;
780 CGSCCAnalysisRegistrationCallbacks;
782 ArrayRef<PipelineElement>)>,
784 CGSCCPipelineParsingCallbacks;
787 FunctionAnalysisRegistrationCallbacks;
789 ArrayRef<PipelineElement>)>,
791 FunctionPipelineParsingCallbacks;
794 LoopAnalysisRegistrationCallbacks;
796 ArrayRef<PipelineElement>)>,
798 LoopPipelineParsingCallbacks;
804 MachineFunctionAnalysisRegistrationCallbacks;
806 ArrayRef<PipelineElement>)>,
808 MachineFunctionPipelineParsingCallbacks;
811 RegClassFilterParsingCallbacks;
828template <
typename AnalysisT,
typename IRUnitT,
typename AnalysisManagerT,
829 typename... ExtraArgTs>
837 PipelineName = PipelineName.
substr(11, PipelineName.
size() - 12);
838 if (PipelineName != AnalysisName)
846 PipelineName = PipelineName.
substr(8, PipelineName.
size() - 9);
847 if (PipelineName != AnalysisName)
aarch64 falkor hwpf fix Falkor HW Prefetch Fix Late Phase
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This header provides classes for managing passes over SCCs of the call graph.
This header provides classes for managing a pipeline of passes over loops in LLVM IR.
This header enumerates the LLVM-provided high-level optimization levels.
Define option tunables for PGO.
CGSCCAnalysisManager CGAM
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
PassInstrumentationCallbacks PIC
This header defines various interfaces for pass management in LLVM.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const char PassName[]
A manager for alias analyses.
A container for analyses that lazily runs them and caches their results.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
An SCC of the call graph.
A lazily constructed view of the call graph of a module.
This class represents a loop nest and can be used to query its properties.
Represents a single loop in the control flow graph.
Module pass, wrapping the inliner pass.
Class to hold module path string table and global value map, and encapsulate methods for operating on...
A Module instance is used to store all the information related to an LLVM module.
Result run(LazyCallGraph::SCC &, CGSCCAnalysisManager &, LazyCallGraph &G)
Result run(Function &, FunctionAnalysisManager &)
Result run(Loop &, LoopAnalysisManager &, LoopStandardAnalysisResults &)
Result run(Module &, ModuleAnalysisManager &)
This class provides access to building LLVM's passes.
ModulePassManager buildO0DefaultPipeline(OptimizationLevel Level, bool LTOPreLink=false)
Build an O0 pipeline with the minimal semantically required passes.
void invokeFullLinkTimeOptimizationLastEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level)
ModuleInlinerWrapperPass buildInlinerPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the module pipeline that performs inlining as well as the inlining-driven cleanups.
void registerAnalysisRegistrationCallback(const std::function< void(MachineFunctionAnalysisManager &)> &C)
void printPassNames(raw_ostream &OS)
Print pass names.
static bool checkParametrizedPassName(StringRef Name, StringRef PassName)
void invokeOptimizerLastEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level)
void registerPipelineEarlySimplificationEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
void invokeVectorizerStartEPCallbacks(FunctionPassManager &FPM, OptimizationLevel Level)
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, ModulePassManager &, ArrayRef< PipelineElement >)> &C)
AAManager buildDefaultAAPipeline()
Build the default AAManager with the default alias analysis pipeline registered.
Error parseAAPipeline(AAManager &AA, StringRef PipelineText)
Parse a textual alias analysis pipeline into the provided AA manager.
void invokeCGSCCOptimizerLateEPCallbacks(CGSCCPassManager &CGPM, OptimizationLevel Level)
ModulePassManager buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, ThinLTO-targeting default optimization pipeline to a pass manager.
void registerAnalysisRegistrationCallback(const std::function< void(ModuleAnalysisManager &)> &C)
void registerPipelineStartEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
void invokeScalarOptimizerLateEPCallbacks(FunctionPassManager &FPM, OptimizationLevel Level)
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, LoopPassManager &, ArrayRef< PipelineElement >)> &C)
void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
std::optional< RegAllocFilterFunc > parseRegAllocFilter(StringRef RegAllocFilterName)
Parse RegAllocFilterName to get RegAllocFilterFunc.
PassInstrumentationCallbacks * getPassInstrumentationCallbacks() const
Returns PIC.
void registerLateLoopOptimizationsEPCallback(const std::function< void(LoopPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
void crossRegisterProxies(LoopAnalysisManager &LAM, FunctionAnalysisManager &FAM, CGSCCAnalysisManager &CGAM, ModuleAnalysisManager &MAM, MachineFunctionAnalysisManager *MFAM=nullptr)
Cross register the analysis managers through their proxies.
void registerLoopOptimizerEndEPCallback(const std::function< void(LoopPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
void registerParseAACallback(const std::function< bool(StringRef Name, AAManager &AA)> &C)
Register a callback for parsing an AliasAnalysis Name to populate the given AAManager AA.
void registerOptimizerLastEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
void registerVectorizerStartEPCallback(const std::function< void(FunctionPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
void registerAnalysisRegistrationCallback(const std::function< void(LoopAnalysisManager &)> &C)
void registerPeepholeEPCallback(const std::function< void(FunctionPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
void registerAnalysisRegistrationCallback(const std::function< void(FunctionAnalysisManager &)> &C)
void registerScalarOptimizerLateEPCallback(const std::function< void(FunctionPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
ModulePassManager buildPerModuleDefaultPipeline(OptimizationLevel Level, bool LTOPreLink=false)
Build a per-module default optimization pipeline.
void registerAnalysisRegistrationCallback(const std::function< void(CGSCCAnalysisManager &)> &C)
{{@ Register callbacks for analysis registration with this PassBuilder instance.
void invokePipelineStartEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level)
FunctionPassManager buildFunctionSimplificationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the core LLVM function canonicalization and simplification pipeline.
void registerCGSCCOptimizerLateEPCallback(const std::function< void(CGSCCPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
void invokePeepholeEPCallbacks(FunctionPassManager &FPM, OptimizationLevel Level)
Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText)
Parse a textual pass pipeline description into a ModulePassManager.
void invokeLoopOptimizerEndEPCallbacks(LoopPassManager &LPM, OptimizationLevel Level)
void registerOptimizerEarlyEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
void registerRegClassFilterParsingCallback(const std::function< RegAllocFilterFunc(StringRef)> &C)
Register callbacks to parse target specific filter field if regalloc pass needs it.
ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level, ModuleSummaryIndex *ExportSummary)
Build an LTO default optimization pipeline to a pass manager.
ModulePassManager buildModuleInlinerPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the module pipeline that performs inlining with module inliner pass.
ModulePassManager buildThinLTODefaultPipeline(OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary)
Build a ThinLTO default optimization pipeline to a pass manager.
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, CGSCCPassManager &, ArrayRef< PipelineElement >)> &C)
{{@ Register pipeline parsing callbacks with this pass builder instance.
void registerFullLinkTimeOptimizationEarlyEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
void invokeLateLoopOptimizationsEPCallbacks(LoopPassManager &LPM, OptimizationLevel Level)
void invokeOptimizerEarlyEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level)
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, FunctionPassManager &, ArrayRef< PipelineElement >)> &C)
void registerModuleAnalyses(ModuleAnalysisManager &MAM)
Registers all available module analysis passes.
void invokePipelineEarlySimplificationEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level)
void registerFullLinkTimeOptimizationLastEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM)
Registers all available CGSCC analysis passes.
void invokeFullLinkTimeOptimizationEarlyEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level)
ModulePassManager buildFatLTODefaultPipeline(OptimizationLevel Level, bool ThinLTO, bool EmitSummary)
Build a fat object default optimization pipeline.
static auto parsePassParameters(ParametersParseCallableT &&Parser, StringRef Name, StringRef PassName) -> decltype(Parser(StringRef{}))
This performs customized parsing of pass name with parameters.
ModulePassManager buildModuleSimplificationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the core LLVM module canonicalization and simplification pipeline.
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, MachineFunctionPassManager &, ArrayRef< PipelineElement >)> &C)
static Expected< bool > parseSinglePassOption(StringRef Params, StringRef OptionName, StringRef PassName)
Handle passes only accept one bool-valued parameter.
void registerMachineFunctionAnalyses(MachineFunctionAnalysisManager &MFAM)
Registers all available machine function analysis passes.
ModulePassManager buildModuleOptimizationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase LTOPhase)
Construct the core LLVM module optimization pipeline.
void registerParseTopLevelPipelineCallback(const std::function< bool(ModulePassManager &, ArrayRef< PipelineElement >)> &C)
Register a callback for a top-level pipeline entry.
void addPGOInstrPassesForO0(ModulePassManager &MPM, bool RunProfileGen, bool IsCS, bool AtomicCounterUpdate, std::string ProfileFile, std::string ProfileRemappingFile, IntrusiveRefCntPtr< vfs::FileSystem > FS)
Add PGOInstrumenation passes for O0 only.
ModulePassManager buildLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, LTO-targeting default optimization pipeline to a pass manager.
void registerFunctionAnalyses(FunctionAnalysisManager &FAM)
Registers all available function analysis passes.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same_v< PassT, PassManager > > addPass(PassT &&Pass)
Tunable parameters for passes in the default pipelines.
unsigned LicmMssaNoAccForPromotionCap
Tuning option to disable promotion to scalars in LICM with MemorySSA, if the number of access is too ...
bool SLPVectorization
Tuning option to enable/disable slp loop vectorization, set based on opt level.
int InlinerThreshold
Tuning option to override the default inliner threshold.
bool EagerlyInvalidateAnalyses
bool CallGraphProfile
Tuning option to enable/disable call graph profile.
bool MergeFunctions
Tuning option to enable/disable function merging.
bool ForgetAllSCEVInLoopUnroll
Tuning option to forget all SCEV loops in LoopUnroll.
unsigned LicmMssaOptCap
Tuning option to cap the number of calls to retrive clobbering accesses in MemorySSA,...
bool LoopInterleaving
Tuning option to set loop interleaving on/off, set based on opt level.
PipelineTuningOptions()
Constructor sets pipeline tuning defaults based on cl::opts.
bool LoopUnrolling
Tuning option to enable/disable loop unrolling. Its default value is true.
bool LoopVectorization
Tuning option to enable/disable loop vectorization, set based on opt level.
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.
StringRef - Represent a constant reference to a string, i.e.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr size_t size() const
size - Get the string size.
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
Primary interface to the complete machine description for the target machine.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.
std::function< bool(const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI, const Register Reg)> RegAllocFilterFunc
Filter function for register classes during regalloc.
PassManager< Function > FunctionPassManager
Convenience typedef for a pass manager over functions.
bool parseAnalysisUtilityPasses(StringRef AnalysisName, StringRef PipelineName, PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs... > &PM)
This utility template takes care of adding require<> and invalidate<> passes for an analysis to a giv...
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
PassManager< MachineFunction > MachineFunctionPassManager
Convenience typedef for a pass manager over functions.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
AnalysisManager< Loop, LoopStandardAnalysisResults & > LoopAnalysisManager
The loop analysis manager.
ThinOrFullLTOPhase
This enumerates the LLVM full LTO or ThinLTO optimization phases.
PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & > LoopPassManager
The Loop pass manager.
PassManager< LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, CGSCCUpdateResult & > CGSCCPassManager
The CGSCC pass manager.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
cl::opt< bool > PrintPipelinePasses
Common option used by multiple tools to print pipeline passes.
AnalysisManager< LazyCallGraph::SCC, LazyCallGraph & > CGSCCAnalysisManager
The CGSCC analysis manager.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
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...
A no-op pass template which simply forces a specific analysis result to be invalidated.
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
No-op CGSCC pass which does nothing.
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &, LazyCallGraph &, CGSCCUpdateResult &UR)
No-op function pass which does nothing.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &)
No-op loop nest pass which does nothing.
PreservedAnalyses run(LoopNest &L, LoopAnalysisManager &, LoopStandardAnalysisResults &, LPMUpdater &)
No-op loop pass which does nothing.
PreservedAnalyses run(Loop &L, LoopAnalysisManager &, LoopStandardAnalysisResults &, LPMUpdater &)
No-op machine function pass which does nothing.
PreservedAnalyses run(MachineFunction &, MachineFunctionAnalysisManager &)
No-op module pass which does nothing.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
A struct to capture parsed pass pipeline names.
std::vector< PipelineElement > InnerPipeline
A CRTP mix-in to automatically provide informational APIs needed for passes.
A utility pass template to force an analysis result to be available.