54 cl::desc(
"Run the Loop vectorization passes"));
58 cl::desc(
"Run the SLP vectorization passes"));
63 cl::desc(
"Run GVN instead of Early CSE after vectorization passes"));
67 cl::desc(
"Run cleanup optimization passes after vectorization."));
71 cl::desc(
"Run the loop rerolling pass"));
79 cl::desc(
"Run the SLP vectorizer (and BB vectorizer) after the Loop " 80 "vectorizer instead of before"));
86 cl::desc(
"Enable the new, experimental CFL alias analysis"),
89 "Enable unification-based CFL-AA"),
91 "Enable inclusion-based CFL-AA"),
93 "Enable both variants of CFL-AA")));
97 cl::desc(
"Enable the new, experimental LoopInterchange Pass"));
101 cl::desc(
"Enable Unroll And Jam Pass"));
105 cl::desc(
"Enable preparation for ThinLTO."));
108 cl::desc(
"Enable hot-cold splitting pass"));
113 cl::desc(
"Enable PGO instrumentation."));
117 cl::desc(
"Specify the path of profile data file."));
121 cl::desc(
"Enable use phase of PGO instrumentation and specify the path " 122 "of profile data file"));
126 cl::desc(
"Enable the experimental Loop Versioning LICM pass"));
130 cl::desc(
"Disable pre-instrumentation inliner"));
134 cl::desc(
"Control the amount of inlining in pre-instrumentation inliner " 139 cl::desc(
"Enable the EarlyCSE w/ MemorySSA pass (default = on)"));
143 cl::desc(
"Enable the GVN hoisting pass (default = off)"));
148 cl::desc(
"Disable shrink-wrap library calls"));
152 cl::desc(
"Enable the simple loop unswitch pass. Also enables independent " 153 "cleanup passes integrated into the loop pass manager pipeline."));
157 cl::desc(
"Enable the GVN sinking pass (default = off)"));
161 cl::desc(
"Enable control height reduction optimization (CHR)"));
166 LibraryInfo =
nullptr;
168 DisableUnrollLoops =
false;
173 DisableGVNLoadPRE =
false;
175 VerifyOutput =
false;
176 MergeFunctions =
false;
177 PrepareForLTO =
false;
182 PerformThinLTO =
false;
183 DivergentTarget =
false;
199 return GlobalExtensions.isConstructed() && !GlobalExtensions->empty();
203 PassManagerBuilder::ExtensionPointTy Ty,
205 GlobalExtensions->push_back(std::make_pair(Ty, std::move(Fn)));
209 Extensions.push_back(std::make_pair(Ty, std::move(Fn)));
215 for (
auto &
Ext : *GlobalExtensions) {
216 if (
Ext.first == ETy)
217 Ext.second(*
this, PM);
220 for (
unsigned i = 0, e =
Extensions.size(); i != e; ++i)
225 void PassManagerBuilder::addInitialAliasAnalysisPasses(
249 void PassManagerBuilder::addInstructionCombiningPass(
251 bool ExpensiveCombines = OptLevel > 2;
257 addExtensionsToPM(EP_EarlyAsPossible, FPM);
264 if (OptLevel == 0)
return;
266 addInitialAliasAnalysisPasses(FPM);
276 if (!EnablePGOInstrGen && PGOInstrUse.empty() && PGOSampleUse.empty())
280 if (OptLevel > 0 && SizeLevel == 0 && !DisablePreInliner &&
281 PGOSampleUse.empty()) {
297 addExtensionsToPM(EP_Peephole, MPM);
299 if (EnablePGOInstrGen) {
303 if (!PGOInstrGen.empty())
309 if (!PGOInstrUse.empty())
318 void PassManagerBuilder::addFunctionSimplificationPasses(
339 addInstructionCombiningPass(MPM);
340 if (SizeLevel == 0 && !DisableLibCallsShrinkWrap)
342 addExtensionsToPM(EP_Peephole, MPM);
353 if (EnableSimpleLoopUnswitch) {
363 if (EnableSimpleLoopUnswitch)
371 addInstructionCombiningPass(MPM);
375 addExtensionsToPM(EP_LateLoopOptimizations, MPM);
378 if (EnableLoopInterchange)
382 DisableUnrollLoops));
383 addExtensionsToPM(EP_LoopOptimizerEnd, MPM);
401 addInstructionCombiningPass(MPM);
402 addExtensionsToPM(EP_Peephole, MPM);
408 addExtensionsToPM(EP_ScalarOptimizerLate, MPM);
418 addInstructionCombiningPass(MPM);
419 addExtensionsToPM(EP_Peephole, MPM);
421 if (EnableCHR && OptLevel >= 3 &&
422 (!PGOInstrUse.empty() || !PGOSampleUse.empty()))
428 if (!PGOSampleUse.empty()) {
439 addPGOInstrPasses(MPM);
455 if (PerformThinLTO) {
463 addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
465 if (PrepareForLTO || PrepareForThinLTO) {
480 addInitialAliasAnalysisPasses(MPM);
491 !PGOSampleUse.empty()));
496 bool PrepareForThinLTOUsingPGOSampleProfile =
497 PrepareForThinLTO && !PGOSampleUse.empty();
498 if (PrepareForThinLTOUsingPGOSampleProfile)
499 DisableUnrollLoops =
true;
504 addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
517 addInstructionCombiningPass(MPM);
518 addExtensionsToPM(EP_Peephole, MPM);
526 if (!PerformThinLTO && !PrepareForThinLTOUsingPGOSampleProfile)
527 addPGOInstrPasses(MPM);
536 bool RunInliner =
false;
547 addExtensionsToPM(EP_CGSCCOptimizerLate, MPM);
548 addFunctionSimplificationPasses(MPM);
558 if (OptLevel > 1 && !PrepareForLTO && !PrepareForThinLTO)
586 if (PrepareForThinLTO) {
589 addExtensionsToPM(EP_OptimizerLast, MPM);
606 if (UseLoopVersioningLICM) {
630 addExtensionsToPM(EP_VectorizerStart, MPM);
654 addInstructionCombiningPass(MPM);
664 addInstructionCombiningPass(MPM);
668 addInstructionCombiningPass(MPM);
685 addExtensionsToPM(EP_Peephole, MPM);
686 addInstructionCombiningPass(MPM);
688 if (EnableUnrollAndJam && !DisableUnrollLoops) {
696 DisableUnrollLoops));
698 if (!DisableUnrollLoops) {
700 addInstructionCombiningPass(MPM);
741 if (EnableHotColdSplit)
748 addExtensionsToPM(EP_OptimizerLast, MPM);
759 if (!PGOSampleUse.empty()) {
769 addInitialAliasAnalysisPasses(PM);
833 addInstructionCombiningPass(PM);
834 addExtensionsToPM(EP_Peephole, PM);
855 addInstructionCombiningPass(PM);
856 addExtensionsToPM(EP_Peephole, PM);
878 if (EnableLoopInterchange)
882 DisableUnrollLoops));
892 addInstructionCombiningPass(PM);
895 addInstructionCombiningPass(PM);
908 addInstructionCombiningPass(PM);
909 addExtensionsToPM(EP_Peephole, PM);
914 void PassManagerBuilder::addLateLTOOptimizationPasses(
933 PerformThinLTO =
true;
957 populateModulePassManager(PM);
961 PerformThinLTO =
false;
972 addLTOOptimizationPasses(PM);
990 addLateLTOOptimizationPasses(PM);
1016 unsigned OptLevel) {
1023 unsigned SizeLevel) {
1079 if (RunInliner && !Builder->
Inliner)
Super simple passes to force specific function attrs from the commandline into the IR for debugging p...
Defines passes for running instruction simplification across chunks of IR.
ModulePass * createNameAnonGlobalPass()
===------------------------------------------------------------------—===//
FunctionPass * createGVNPass(bool NoLoads=false)
Create a legacy GVN pass.
Pass * createLoopRerollPass()
Thresholds to tune inline cost analysis.
ModulePass * createStripDeadPrototypesPass()
createStripDeadPrototypesPass - This pass removes any function declarations (prototypes) that are not...
ModulePass * createPGOInstrumentationGenLegacyPass()
static cl::opt< bool > UseLoopVersioningLICM("enable-loop-versioning-licm", cl::init(false), cl::Hidden, cl::desc("Enable the experimental Loop Versioning LICM pass"))
PassManagerBuilder - This class is used to set up a standard optimization sequence for languages like...
This is the interface for LLVM's inclusion-based alias analysis implemented with CFL graph reachabili...
This class represents lattice values for constants.
This is the interface for a simple mod/ref and alias analysis over globals.
Pass * createLoopVectorizePass(bool InterleaveOnlyWhenForced=false, bool VectorizeOnlyWhenForced=false)
static cl::opt< bool > EnableEarlyCSEMemSSA("enable-earlycse-memssa", cl::init(true), cl::Hidden, cl::desc("Enable the EarlyCSE w/ MemorySSA pass (default = on)"))
FunctionPass * createPGOMemOPSizeOptLegacyPass()
ModulePass * createMergeFunctionsPass()
createMergeFunctionsPass - This pass discovers identical functions and collapses them.
void populateThinLTOPassManager(legacy::PassManagerBase &PM)
static cl::opt< bool > EnableGVNHoist("enable-gvn-hoist", cl::init(false), cl::Hidden, cl::desc("Enable the GVN hoisting pass (default = off)"))
Pass * createSimpleLoopUnrollPass(int OptLevel=2, bool OnlyWhenForced=false)
This is the interface for a metadata-based scoped no-alias analysis.
static cl::opt< std::string > RunPGOInstrUse("profile-use", cl::init(""), cl::Hidden, cl::value_desc("filename"), cl::desc("Enable use phase of PGO instrumentation and specify the path " "of profile data file"))
FunctionPass * createVerifierPass(bool FatalErrors=true)
ModulePass * createIPSCCPPass()
createIPSCCPPass - This pass propagates constants from call sites into the bodies of functions...
FunctionPass * createFloat2IntPass()
virtual void add(Pass *P)=0
Add a pass to the queue of passes to run.
static cl::opt< std::string > PGOOutputFile("profile-generate-file", cl::init(""), cl::Hidden, cl::desc("Specify the path of profile data file."))
ModulePass * createEliminateAvailableExternallyPass()
This transform is designed to eliminate available external globals (functions or global variables) ...
FunctionPass * createGVNHoistPass()
static cl::opt< bool > RunPGOInstrGen("profile-generate", cl::init(false), cl::Hidden, cl::desc("Enable PGO instrumentation."))
ModulePass * createInstrProfilingLegacyPass(const InstrProfOptions &Options=InstrProfOptions())
Insert frontend instrumentation based profiling.
ModulePass * createCanonicalizeAliasesPass()
ImmutablePass * createScopedNoAliasAAWrapperPass()
FunctionPass * createAlignmentFromAssumptionsPass()
Pass * Inliner
Inliner - Specifies the inliner to use.
FunctionPass * createJumpThreadingPass(int Threshold=-1)
FunctionPass * createCFGSimplificationPass(unsigned Threshold=1, bool ForwardSwitchCond=false, bool ConvertSwitch=false, bool KeepLoops=true, bool SinkCommon=false, std::function< bool(const Function &)> Ftor=nullptr)
static cl::opt< bool > RunLoopVectorization("vectorize-loops", cl::Hidden, cl::desc("Run the Loop vectorization passes"))
ModulePass * createPartialInliningPass()
createPartialInliningPass - This pass inlines parts of functions.
Pass * createLoopUnrollPass(int OptLevel=2, bool OnlyWhenForced=false, int Threshold=-1, int Count=-1, int AllowPartial=-1, int Runtime=-1, int UpperBound=-1, int AllowPeeling=-1)
Attribute unwrap(LLVMAttributeRef Attr)
static void addGlobalExtension(ExtensionPointTy Ty, ExtensionFn Fn)
Adds an extension that will be used by all PassManagerBuilder instances.
Optional< int > HintThreshold
Threshold to use for callees with inline hint.
void populateLTOPassManager(legacy::PassManagerBase &PM)
ModulePass * createCrossDSOCFIPass()
This pass export CFI checks for use by external modules.
static cl::opt< bool > ExtraVectorizerPasses("extra-vectorizer-passes", cl::init(false), cl::Hidden, cl::desc("Run cleanup optimization passes after vectorization."))
FunctionPass * createReassociatePass()
Pass * createArgumentPromotionPass(unsigned maxElements=3)
createArgumentPromotionPass - This pass promotes "by reference" arguments to be passed by value if th...
FunctionPass * createAggressiveInstCombinerPass()
static cl::opt< bool > EnablePrepareForThinLTO("prepare-for-thinlto", cl::init(false), cl::Hidden, cl::desc("Enable preparation for ThinLTO."))
FunctionPass * createSCCPPass()
std::function< void(const PassManagerBuilder &Builder, legacy::PassManagerBase &PM)> ExtensionFn
Extensions are passed the builder itself (so they can see how it is configured) as well as the pass m...
unsigned OptLevel
The Optimization Level - Specify the basic optimization level.
static cl::opt< bool > UseGVNAfterVectorization("use-gvn-after-vectorization", cl::init(false), cl::Hidden, cl::desc("Run GVN instead of Early CSE after vectorization passes"))
void populateModulePassManager(legacy::PassManagerBase &MPM)
populateModulePassManager - This sets up the primary pass manager.
static cl::opt< bool > DisablePreInliner("disable-preinline", cl::init(false), cl::Hidden, cl::desc("Disable pre-instrumentation inliner"))
ModulePass * createCalledValuePropagationPass()
createCalledValuePropagationPass - Attach metadata to indirct call sites indicating the set of functi...
void add(Pass *P) override
Add a pass to the queue of passes to run.
FunctionPass * createInstSimplifyLegacyPass()
Create a legacy pass that does instruction simplification on each instruction in a function...
Pass * createLoopInstSimplifyPass()
static ManagedStatic< SmallVector< std::pair< PassManagerBuilder::ExtensionPointTy, PassManagerBuilder::ExtensionFn >, 8 > > GlobalExtensions
Set of global extensions, automatically added as part of the standard set.
static cl::opt< bool > RunSLPVectorization("vectorize-slp", cl::Hidden, cl::desc("Run the SLP vectorization passes"))
ModulePass * createSampleProfileLoaderPass()
FunctionPass * createInstructionCombiningPass(bool ExpensiveCombines=true)
ModulePass * createGlobalDCEPass()
createGlobalDCEPass - This transform is designed to eliminate unreachable internal globals (functions...
static cl::opt< bool > EnableUnrollAndJam("enable-unroll-and-jam", cl::init(false), cl::Hidden, cl::desc("Enable Unroll And Jam Pass"))
Pass * createLoopUnrollAndJamPass(int OptLevel=2)
Pass * createCorrelatedValuePropagationPass()
This is the interface for LLVM's unification-based alias analysis implemented with CFL graph reachabi...
initializer< Ty > init(const Ty &Val)
This is the interface for a metadata-based TBAA.
FunctionPass * createTailCallEliminationPass()
This file provides the interface for LLVM's Global Value Numbering pass which eliminates fully redund...
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
FunctionPass * createPromoteMemoryToRegisterPass()
ModulePass * createDeadArgEliminationPass()
createDeadArgEliminationPass - This pass removes arguments from functions which are not used by the b...
FunctionPass * createDivRemPairsPass()
FunctionPass * createDeadStoreEliminationPass()
ModulePass * createLowerTypeTestsPass(ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary)
This pass lowers type metadata and the llvm.type.test intrinsic to bitsets.
ModulePass * createPGOInstrumentationUseLegacyPass(StringRef Filename=StringRef(""))
ModulePass * createBarrierNoopPass()
createBarrierNoopPass - This pass is purely a module pass barrier in a pass manager.
FunctionPass * createMemCpyOptPass()
The public interface to this file...
FunctionPass * createBitTrackingDCEPass()
static const struct @395 Extensions[]
ModulePass * createConstantMergePass()
createConstantMergePass - This function returns a new pass that merges duplicate global constants tog...
Pass * createLoopSinkPass()
ModulePass * createGlobalOptimizerPass()
createGlobalOptimizerPass - This function returns a new pass that optimizes non-address taken interna...
Pass * createReversePostOrderFunctionAttrsPass()
createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call graph in RPO to deduce and...
void populateFunctionPassManager(legacy::FunctionPassManager &FPM)
populateFunctionPassManager - This fills in the function pass manager, which is expected to be run on...
Pass * createWarnMissedTransformationsPass()
FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
Pass * createPostOrderFunctionAttrsLegacyPass()
Create a legacy pass manager instance of a pass to compute function attrs in post-order.
std::string InstrProfileOutput
Pass * createLoopVersioningLICMPass()
ModulePass * createGlobalSplitPass()
This pass splits globals into pieces for the benefit of whole-program devirtualization and control-fl...
static cl::opt< bool > EnableLoopInterchange("enable-loopinterchange", cl::init(false), cl::Hidden, cl::desc("Enable the new, experimental LoopInterchange Pass"))
cl::opt< bool > EnableHotColdSplit("hot-cold-split", cl::init(false), cl::Hidden, cl::desc("Enable hot-cold splitting pass"))
Pass * createLoopInterchangePass()
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
FunctionPass * createLoopLoadEliminationPass()
static cl::opt< bool > RunSLPAfterLoopVectorization("run-slp-after-loop-vectorization", cl::init(true), cl::Hidden, cl::desc("Run the SLP vectorizer (and BB vectorizer) after the Loop " "vectorizer instead of before"))
Pass * createSimpleLoopUnswitchLegacyPass(bool NonTrivial=false)
Create the legacy pass object for the simple loop unswitcher.
static cl::opt< CFLAAType > UseCFLAA("use-cfl-aa", cl::init(CFLAAType::None), cl::Hidden, cl::desc("Enable the new, experimental CFL alias analysis"), cl::values(clEnumValN(CFLAAType::None, "none", "Disable CFL-AA"), clEnumValN(CFLAAType::Steensgaard, "steens", "Enable unification-based CFL-AA"), clEnumValN(CFLAAType::Andersen, "anders", "Enable inclusion-based CFL-AA"), clEnumValN(CFLAAType::Both, "both", "Enable both variants of CFL-AA")))
Pass * createLoopSimplifyCFGPass()
FunctionPass * createSpeculativeExecutionIfHasBranchDivergencePass()
FunctionPass * createMergedLoadStoreMotionPass()
createMergedLoadStoreMotionPass - The public interface to this file.
FunctionPass * createLibCallsShrinkWrapPass()
struct LLVMOpaquePassManager * LLVMPassManagerRef
Pass * createLoopDeletionPass()
Pass * createLoopUnswitchPass(bool OptimizeForSize=false, bool hasBranchDivergence=false)
Options for the frontend instrumentation based profiling pass.
static cl::opt< unsigned > Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"), cl::init(100), cl::Hidden)
static cl::opt< bool > EnableGVNSink("enable-gvn-sink", cl::init(false), cl::Hidden, cl::desc("Enable the GVN sinking pass (default = off)"))
Pass * createLoopIdiomPass()
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
ModulePass * createWholeProgramDevirtPass(ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary)
This pass implements whole-program devirtualization using type metadata.
Interfaces for passes which infer implicit function attributes from the name and signature of functio...
LLVMAttributeRef wrap(Attribute Attr)
ModulePass * createHotColdSplittingPass()
createHotColdSplittingPass - This pass outlines cold blocks into a separate function(s).
unsigned SizeLevel
SizeLevel - How much we're optimizing for size.
static cl::opt< bool > DisableLibCallsShrinkWrap("disable-libcalls-shrinkwrap", cl::init(false), cl::Hidden, cl::desc("Disable shrink-wrap library calls"))
FunctionPass * createGVNSinkPass()
ModulePass * createGlobalsAAWrapperPass()
FunctionPass * createSROAPass()
Pass * createInferFunctionAttrsLegacyPass()
Create a legacy pass manager instance of a pass to infer function attributes.
static bool GlobalExtensionsNotEmpty()
Check if GlobalExtensions is constructed and not empty.
Provides passes for computing function attributes based on interprocedural analyses.
ImmutablePass * createCFLSteensAAWrapperPass()
ImmutablePass * createTypeBasedAAWrapperPass()
Pass * createSLPVectorizerPass()
static cl::opt< bool > EnableCHR("enable-chr", cl::init(true), cl::Hidden, cl::desc("Enable control height reduction optimization (CHR)"))
Pass * createFunctionInliningPass()
createFunctionInliningPass - Return a new pass object that uses a heuristic to inline direct function...
Pass * createPruneEHPass()
createPruneEHPass - Return a new pass object which transforms invoke instructions into calls...
LLVM Value Representation.
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
static cl::opt< int > PreInlineThreshold("preinline-threshold", cl::Hidden, cl::init(75), cl::ZeroOrMore, cl::desc("Control the amount of inlining in pre-instrumentation inliner " "(default = 75)"))
FunctionPass * createNewGVNPass()
This is the interface for LLVM's primary stateless and local alias analysis.
static cl::opt< bool > RunPartialInlining("enable-partial-inlining", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Run Partial inlinining pass"))
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
FunctionPass * createControlHeightReductionLegacyPass()
static cl::opt< bool > EnableSimpleLoopUnswitch("enable-simple-loop-unswitch", cl::init(false), cl::Hidden, cl::desc("Enable the simple loop unswitch pass. Also enables independent " "cleanup passes integrated into the loop pass manager pipeline."))
ImmutablePass * createCFLAndersAAWrapperPass()
void addExtension(ExtensionPointTy Ty, ExtensionFn Fn)
FunctionPass * createEntryExitInstrumenterPass()
ModulePass * createPGOIndirectCallPromotionLegacyPass(bool InLTO=false, bool SamplePGO=false)
Pass * createForceFunctionAttrsLegacyPass()
Create a legacy pass manager instance of a pass to force function attrs.
Pass * createLoopRotatePass(int MaxHeaderSize=-1)
Pass * createIndVarSimplifyPass()
FunctionPass * createAggressiveDCEPass()
int DefaultThreshold
The default threshold to start with for a callee.
FunctionPass * createLoopDistributePass()
FunctionPass * createLowerExpectIntrinsicPass()
static cl::opt< bool > RunLoopRerolling("reroll-loops", cl::Hidden, cl::desc("Run the loop rerolling pass"))
static cl::opt< bool > RunNewGVN("enable-newgvn", cl::init(false), cl::Hidden, cl::desc("Run the NewGVN pass"))
FunctionPass * createCallSiteSplittingPass()