LLVM  16.0.0git
PassManagerBuilder.cpp
Go to the documentation of this file.
1 //===- PassManagerBuilder.cpp - Build Standard Pass -----------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the PassManagerBuilder class, which is used to set up a
10 // "standard" optimization sequence suitable for languages like C and C++.
11 //
12 //===----------------------------------------------------------------------===//
13 
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/ADT/SmallVector.h"
29 #include "llvm/Transforms/IPO.h"
36 #include "llvm/Transforms/Scalar.h"
41 #include "llvm/Transforms/Utils.h"
43 
44 using namespace llvm;
45 
47  OptLevel = 2;
48  SizeLevel = 0;
49  LibraryInfo = nullptr;
50  Inliner = nullptr;
51  DisableUnrollLoops = false;
52  SLPVectorize = false;
53  LoopVectorize = true;
54  LoopsInterleaved = true;
57  DisableGVNLoadPRE = false;
59  VerifyInput = false;
60  VerifyOutput = false;
61  MergeFunctions = false;
62  DivergentTarget = false;
63  CallGraphProfile = true;
64 }
65 
67  delete LibraryInfo;
68  delete Inliner;
69 }
70 
71 /// Set of global extensions, automatically added as part of the standard set.
72 static ManagedStatic<
76  8>>
79 
80 /// Check if GlobalExtensions is constructed and not empty.
81 /// Since GlobalExtensions is a managed static, calling 'empty()' will trigger
82 /// the construction of the object.
83 static bool GlobalExtensionsNotEmpty() {
84  return GlobalExtensions.isConstructed() && !GlobalExtensions->empty();
85 }
86 
90  auto ExtensionID = GlobalExtensionsCounter++;
91  GlobalExtensions->push_back(std::make_tuple(Ty, std::move(Fn), ExtensionID));
92  return ExtensionID;
93 }
94 
97  // RegisterStandardPasses may try to call this function after GlobalExtensions
98  // has already been destroyed; doing so should not generate an error.
99  if (!GlobalExtensions.isConstructed())
100  return;
101 
102  auto GlobalExtension =
103  llvm::find_if(*GlobalExtensions, [ExtensionID](const auto &elem) {
104  return std::get<2>(elem) == ExtensionID;
105  });
106  assert(GlobalExtension != GlobalExtensions->end() &&
107  "The extension ID to be removed should always be valid.");
108 
109  GlobalExtensions->erase(GlobalExtension);
110 }
111 
113  Extensions.push_back(std::make_pair(Ty, std::move(Fn)));
114 }
115 
116 void PassManagerBuilder::addExtensionsToPM(ExtensionPointTy ETy,
117  legacy::PassManagerBase &PM) const {
118  if (GlobalExtensionsNotEmpty()) {
119  for (auto &Ext : *GlobalExtensions) {
120  if (std::get<0>(Ext) == ETy)
121  std::get<1>(Ext)(*this, PM);
122  }
123  }
124  for (const auto &[PT, Fn] : Extensions)
125  if (PT == ETy)
126  Fn(*this, PM);
127 }
128 
129 void PassManagerBuilder::addInitialAliasAnalysisPasses(
130  legacy::PassManagerBase &PM) const {
131  // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that
132  // BasicAliasAnalysis wins if they disagree. This is intended to help
133  // support "obvious" type-punning idioms.
136 }
137 
140  addExtensionsToPM(EP_EarlyAsPossible, FPM);
141 
142  // Add LibraryInfo if we have some.
143  if (LibraryInfo)
145 
146  if (OptLevel == 0) return;
147 
148  addInitialAliasAnalysisPasses(FPM);
149 
150  // Lower llvm.expect to metadata before attempting transforms.
151  // Compare/branch metadata may alter the behavior of passes like SimplifyCFG.
154  FPM.add(createSROAPass());
155  FPM.add(createEarlyCSEPass());
156 }
157 
158 void PassManagerBuilder::addFunctionSimplificationPasses(
160  // Start of function pass.
161  // Break up aggregate allocas, using SSAUpdater.
162  assert(OptLevel >= 1 && "Calling function optimizer with no optimization level!");
163  MPM.add(createSROAPass());
164  MPM.add(createEarlyCSEPass(true /* Enable mem-ssa. */)); // Catch trivial redundancies
165 
166  if (OptLevel > 1) {
167  // Speculative execution if the target has divergent branches; otherwise nop.
169 
170  MPM.add(createJumpThreadingPass()); // Thread jumps.
171  MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals
172  }
173  MPM.add(
174  createCFGSimplificationPass(SimplifyCFGOptions().convertSwitchRangeToICmp(
175  true))); // Merge & remove BBs
176  // Combine silly seq's
178  if (SizeLevel == 0)
180  addExtensionsToPM(EP_Peephole, MPM);
181 
182  // TODO: Investigate the cost/benefit of tail call elimination on debugging.
183  if (OptLevel > 1)
184  MPM.add(createTailCallEliminationPass()); // Eliminate tail calls
185  MPM.add(
186  createCFGSimplificationPass(SimplifyCFGOptions().convertSwitchRangeToICmp(
187  true))); // Merge & remove BBs
188  MPM.add(createReassociatePass()); // Reassociate expressions
189 
190  // Begin the loop pass pipeline.
191 
192  // The simple loop unswitch pass relies on separate cleanup passes. Schedule
193  // them first so when we re-process a loop they run before other loop
194  // passes.
197 
198  // Try to remove as much code from the loop header as possible,
199  // to reduce amount of IR that will have to be duplicated. However,
200  // do not perform speculative hoisting the first time as LICM
201  // will destroy metadata that may not need to be destroyed if run
202  // after loop rotation.
203  // TODO: Investigate promotion cap for O1.
205  /*AllowSpeculation=*/false));
206  // Rotate Loop - disable header duplication at -Oz
207  MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1, false));
208  // TODO: Investigate promotion cap for O1.
210  /*AllowSpeculation=*/true));
212  // FIXME: We break the loop pass pipeline here in order to do full
213  // simplifycfg. Eventually loop-simplifycfg should be enhanced to replace the
214  // need for this.
216  SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
218  // We resume loop passes creating a second loop pipeline here.
219  MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
220  MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
221  addExtensionsToPM(EP_LateLoopOptimizations, MPM);
222  MPM.add(createLoopDeletionPass()); // Delete dead loops
223 
224  // Unroll small loops and perform peeling.
227  addExtensionsToPM(EP_LoopOptimizerEnd, MPM);
228  // This ends the loop pass pipelines.
229 
230  // Break up allocas that may now be splittable after loop unrolling.
231  MPM.add(createSROAPass());
232 
233  if (OptLevel > 1) {
234  MPM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds
235  MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
236  }
237  MPM.add(createSCCPPass()); // Constant prop with SCCP
238 
239  // Delete dead bit computations (instcombine runs after to fold away the dead
240  // computations, and then ADCE will run later to exploit any new DCE
241  // opportunities that creates).
242  MPM.add(createBitTrackingDCEPass()); // Delete dead bit computations
243 
244  // Run instcombine after redundancy elimination to exploit opportunities
245  // opened up by them.
247  addExtensionsToPM(EP_Peephole, MPM);
248  if (OptLevel > 1) {
249  MPM.add(createJumpThreadingPass()); // Thread jumps
251  }
252  MPM.add(createAggressiveDCEPass()); // Delete dead instructions
253 
254  MPM.add(createMemCpyOptPass()); // Remove memcpy / form memset
255  // TODO: Investigate if this is too expensive at O1.
256  if (OptLevel > 1) {
257  MPM.add(createDeadStoreEliminationPass()); // Delete dead stores
259  /*AllowSpeculation=*/true));
260  }
261 
262  addExtensionsToPM(EP_ScalarOptimizerLate, MPM);
263 
264  // Merge & remove BBs and sink & hoist common instructions.
266  SimplifyCFGOptions().hoistCommonInsts(true).sinkCommonInsts(true)));
267  // Clean up after everything.
269  addExtensionsToPM(EP_Peephole, MPM);
270 }
271 
272 /// FIXME: Should LTO cause any differences to this set of passes?
273 void PassManagerBuilder::addVectorPasses(legacy::PassManagerBase &PM,
274  bool IsFullLTO) {
276 
277  if (IsFullLTO) {
278  // The vectorizer may have significantly shortened a loop body; unroll
279  // again. Unroll small loops to hide loop backedge latency and saturate any
280  // parallel execution resources of an out-of-order processor. We also then
281  // need to clean up redundancies and loop invariant code.
282  // FIXME: It would be really good to use a loop-integrated instruction
283  // combiner for cleanup here so that the unrolling and LICM can be pipelined
284  // across the loop nests.
288  }
289 
290  if (!IsFullLTO) {
291  // Eliminate loads by forwarding stores from the previous iteration to loads
292  // of the current iteration.
294  }
295  // Cleanup after the loop optimization passes.
297 
298  // Now that we've formed fast to execute loop structures, we do further
299  // optimizations. These are run afterward as they might block doing complex
300  // analyses and transforms such as what are needed for loop vectorization.
301 
302  // Cleanup after loop vectorization, etc. Simplification passes like CVP and
303  // GVN, loop transforms, and others have already run, so it's now better to
304  // convert to more optimized IR using more aggressive simplify CFG options.
305  // The extra sinking transform can create larger basic blocks, so do this
306  // before SLP vectorization.
308  .forwardSwitchCondToPhi(true)
309  .convertSwitchRangeToICmp(true)
310  .convertSwitchToLookupTable(true)
311  .needCanonicalLoops(false)
312  .hoistCommonInsts(true)
313  .sinkCommonInsts(true)));
314 
315  if (IsFullLTO) {
316  PM.add(createSCCPPass()); // Propagate exposed constants
317  PM.add(createInstructionCombiningPass()); // Clean up again
319  }
320 
321  // Optimize parallel scalar instruction chains into SIMD instructions.
322  if (SLPVectorize) {
324  }
325 
326  // Enhance/cleanup vector code.
328 
329  if (!IsFullLTO) {
330  addExtensionsToPM(EP_Peephole, PM);
332 
333  // Unroll small loops
336 
337  if (!DisableUnrollLoops) {
338  // LoopUnroll may generate some redundency to cleanup.
340 
341  // Runtime unrolling will introduce runtime check in loop prologue. If the
342  // unrolled loop is a inner loop, then the prologue will be inside the
343  // outer loop. LICM pass can help to promote the runtime check out if the
344  // checked value is loop invariant.
346  /*AllowSpeculation=*/true));
347  }
348 
350  }
351 
352  // After vectorization and unrolling, assume intrinsics may tell us more
353  // about pointer alignments.
355 
356  if (IsFullLTO)
358 }
359 
363 
364  // Allow forcing function attributes as a debugging and tuning aid.
366 
367  // If all optimizations are disabled, just run the always-inline pass and,
368  // if enabled, the function merging pass.
369  if (OptLevel == 0) {
370  if (Inliner) {
371  MPM.add(Inliner);
372  Inliner = nullptr;
373  }
374 
375  // FIXME: The BarrierNoopPass is a HACK! The inliner pass above implicitly
376  // creates a CGSCC pass manager, but we don't want to add extensions into
377  // that pass manager. To prevent this we insert a no-op module pass to reset
378  // the pass manager to get the same behavior as EP_OptimizerLast in non-O0
379  // builds. The function merging pass is
380  if (MergeFunctions)
382  else if (GlobalExtensionsNotEmpty() || !Extensions.empty())
383  MPM.add(createBarrierNoopPass());
384 
385  addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
386 
388  return;
389  }
390 
391  // Add LibraryInfo if we have some.
392  if (LibraryInfo)
394 
395  addInitialAliasAnalysisPasses(MPM);
396 
397  // Infer attributes about declarations if possible.
399 
400  addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
401 
402  if (OptLevel > 2)
404 
405  MPM.add(createIPSCCPPass()); // IP SCCP
407 
408  MPM.add(createGlobalOptimizerPass()); // Optimize out global vars
409  // Promote any localized global vars.
411 
412  MPM.add(createDeadArgEliminationPass()); // Dead argument elimination
413 
414  MPM.add(createInstructionCombiningPass()); // Clean up after IPCP & DAE
415  addExtensionsToPM(EP_Peephole, MPM);
416  MPM.add(
417  createCFGSimplificationPass(SimplifyCFGOptions().convertSwitchRangeToICmp(
418  true))); // Clean up after IPCP & DAE
419 
420  // We add a module alias analysis pass here. In part due to bugs in the
421  // analysis infrastructure this "works" in that the analysis stays alive
422  // for the entire SCC pass run below.
424 
425  // Start of CallGraph SCC passes.
426  bool RunInliner = false;
427  if (Inliner) {
428  MPM.add(Inliner);
429  Inliner = nullptr;
430  RunInliner = true;
431  }
432 
433  // Try to perform OpenMP specific optimizations. This is a (quick!) no-op if
434  // there are no OpenMP runtime calls present in the module.
435  if (OptLevel > 1)
437 
439 
440  addExtensionsToPM(EP_CGSCCOptimizerLate, MPM);
441  addFunctionSimplificationPasses(MPM);
442 
443  // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
444  // pass manager that we are specifically trying to avoid. To prevent this
445  // we must insert a no-op module pass to reset the pass manager.
446  MPM.add(createBarrierNoopPass());
447 
448  if (OptLevel > 1)
449  // Remove avail extern fns and globals definitions if we aren't
450  // compiling an object file for later LTO. For LTO we want to preserve
451  // these so they are eligible for inlining at link-time. Note if they
452  // are unreferenced they will be removed by GlobalDCE later, so
453  // this only impacts referenced available externally globals.
454  // Eventually they will be suppressed during codegen, but eliminating
455  // here enables more opportunity for GlobalDCE as it may make
456  // globals referenced by available external functions dead
457  // and saves running remaining passes on the eliminated functions.
459 
461 
462  // The inliner performs some kind of dead code elimination as it goes,
463  // but there are cases that are not really caught by it. We might
464  // at some point consider teaching the inliner about them, but it
465  // is OK for now to run GlobalOpt + GlobalDCE in tandem as their
466  // benefits generally outweight the cost, making the whole pipeline
467  // faster.
468  if (RunInliner) {
470  MPM.add(createGlobalDCEPass());
471  }
472 
473  // We add a fresh GlobalsModRef run at this point. This is particularly
474  // useful as the above will have inlined, DCE'ed, and function-attr
475  // propagated everything. We should at this point have a reasonably minimal
476  // and richly annotated call graph. By computing aliasing and mod/ref
477  // information for all local globals here, the late loop passes and notably
478  // the vectorizer will be able to use them to help recognize vectorizable
479  // memory operations.
480  //
481  // Note that this relies on a bug in the pass manager which preserves
482  // a module analysis into a function pass pipeline (and throughout it) so
483  // long as the first function pass doesn't invalidate the module analysis.
484  // Thus both Float2Int and LoopRotate have to preserve AliasAnalysis for
485  // this to work. Fortunately, it is trivial to preserve AliasAnalysis
486  // (doing nothing preserves it as it is required to be conservatively
487  // correct in the face of IR changes).
489 
490  MPM.add(createFloat2IntPass());
492 
493  addExtensionsToPM(EP_VectorizerStart, MPM);
494 
495  // Re-rotate loops in all our loop nests. These may have fallout out of
496  // rotated form due to GVN or other transformations, and the vectorizer relies
497  // on the rotated form. Disable header duplication at -Oz.
498  MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1, false));
499 
500  // Distribute loops to allow partial vectorization. I.e. isolate dependences
501  // into separate loop that would otherwise inhibit vectorization. This is
502  // currently only performed for loops marked with the metadata
503  // llvm.loop.distribute=true or when -enable-loop-distribute is specified.
505 
506  addVectorPasses(MPM, /* IsFullLTO */ false);
507 
508  // FIXME: We shouldn't bother with this anymore.
509  MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
510 
511  // GlobalOpt already deletes dead functions and globals, at -O2 try a
512  // late pass of GlobalDCE. It is capable of deleting dead cycles.
513  if (OptLevel > 1) {
514  MPM.add(createGlobalDCEPass()); // Remove dead fns and globals.
515  MPM.add(createConstantMergePass()); // Merge dup global constants
516  }
517 
518  if (MergeFunctions)
520 
521  // LoopSink pass sinks instructions hoisted by LICM, which serves as a
522  // canonicalization pass that enables other optimizations. As a result,
523  // LoopSink pass needs to be a very late IR pass to avoid undoing LICM
524  // result too early.
525  MPM.add(createLoopSinkPass());
526  // Get rid of LCSSA nodes.
528 
529  // This hoists/decomposes div/rem ops. It should run after other sink/hoist
530  // passes to avoid re-sinking, but before SimplifyCFG because it can allow
531  // flattening of blocks.
532  MPM.add(createDivRemPairsPass());
533 
534  // LoopSink (and other loop passes since the last simplifyCFG) might have
535  // resulted in single-entry-single-exit or empty blocks. Clean up the CFG.
537  SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
538 
539  addExtensionsToPM(EP_OptimizerLast, MPM);
540 
542 }
543 
546  return wrap(PMB);
547 }
548 
551  delete Builder;
552 }
553 
554 void
556  unsigned OptLevel) {
558  Builder->OptLevel = OptLevel;
559 }
560 
561 void
563  unsigned SizeLevel) {
565  Builder->SizeLevel = SizeLevel;
566 }
567 
568 void
570  LLVMBool Value) {
571  // NOTE: The DisableUnitAtATime switch has been removed.
572 }
573 
574 void
576  LLVMBool Value) {
578  Builder->DisableUnrollLoops = Value;
579 }
580 
581 void
583  LLVMBool Value) {
584  // NOTE: The simplify-libcalls pass has been removed.
585 }
586 
587 void
589  unsigned Threshold) {
591  Builder->Inliner = createFunctionInliningPass(Threshold);
592 }
593 
594 void
596  LLVMPassManagerRef PM) {
598  legacy::FunctionPassManager *FPM = unwrap<legacy::FunctionPassManager>(PM);
599  Builder->populateFunctionPassManager(*FPM);
600 }
601 
602 void
604  LLVMPassManagerRef PM) {
607  Builder->populateModulePassManager(*MPM);
608 }
llvm::PassManagerBuilder::LicmMssaOptCap
unsigned LicmMssaOptCap
Definition: PassManagerBuilder.h:166
llvm::createLoopLoadEliminationPass
FunctionPass * createLoopLoadEliminationPass()
Definition: LoopLoadElimination.cpp:721
llvm::PassManagerBuilder::EP_OptimizerLast
@ EP_OptimizerLast
EP_OptimizerLast – This extension point allows adding passes that run after everything else.
Definition: PassManagerBuilder.h:87
TypeBasedAliasAnalysis.h
Instrumentation.h
llvm::createMergedLoadStoreMotionPass
FunctionPass * createMergedLoadStoreMotionPass(bool SplitFooterBB=false)
createMergedLoadStoreMotionPass - The public interface to this file.
Definition: MergedLoadStoreMotion.cpp:400
llvm::createSimpleLoopUnswitchLegacyPass
Pass * createSimpleLoopUnswitchLegacyPass(bool NonTrivial=false)
Create the legacy pass object for the simple loop unswitcher.
Definition: SimpleLoopUnswitch.cpp:3345
LLVMPassManagerBuilderPopulateFunctionPassManager
void LLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM)
See llvm::PassManagerBuilder::populateFunctionPassManager.
Definition: PassManagerBuilder.cpp:595
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::createTailCallEliminationPass
FunctionPass * createTailCallEliminationPass()
Definition: TailRecursionElimination.cpp:917
llvm::PassManagerBuilder::PassManagerBuilder
PassManagerBuilder()
Definition: PassManagerBuilder.cpp:46
Scalar.h
llvm::PassManagerBuilder::VerifyOutput
bool VerifyOutput
Definition: PassManagerBuilder.h:163
llvm::createCFGSimplificationPass
FunctionPass * createCFGSimplificationPass(SimplifyCFGOptions Options=SimplifyCFGOptions(), std::function< bool(const Function &)> Ftor=nullptr)
Definition: SimplifyCFGPass.cpp:432
llvm::SetLicmMssaNoAccForPromotionCap
cl::opt< unsigned > SetLicmMssaNoAccForPromotionCap
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1199
llvm::createLoopSimplifyCFGPass
Pass * createLoopSimplifyCFGPass()
Definition: LoopSimplifyCFG.cpp:782
ManagedStatic.h
llvm::PassManagerBuilder::LoopVectorize
bool LoopVectorize
Definition: PassManagerBuilder.h:158
CGPassBuilderOption.h
GlobalsModRef.h
llvm::createEarlyCSEPass
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
Definition: EarlyCSE.cpp:1790
llvm::createDeadArgEliminationPass
ModulePass * createDeadArgEliminationPass()
createDeadArgEliminationPass - This pass removes arguments from functions which are not used by the b...
llvm::PassManagerBuilder::DisableGVNLoadPRE
bool DisableGVNLoadPRE
Definition: PassManagerBuilder.h:160
LLVMPassManagerBuilderSetDisableSimplifyLibCalls
void LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB, LLVMBool Value)
See llvm::PassManagerBuilder::DisableSimplifyLibCalls.
Definition: PassManagerBuilder.cpp:582
llvm::createVectorCombinePass
Pass * createVectorCombinePass()
Definition: VectorCombine.cpp:1845
llvm::createLoopIdiomPass
Pass * createLoopIdiomPass()
Definition: LoopIdiomRecognize.cpp:345
llvm::createDeadStoreEliminationPass
FunctionPass * createDeadStoreEliminationPass()
Definition: DeadStoreElimination.cpp:2292
llvm::PassManagerBuilder::ExtensionPointTy
ExtensionPointTy
Definition: PassManagerBuilder.h:66
llvm::PassManagerBuilder::ForgetAllSCEVInLoopUnroll
bool ForgetAllSCEVInLoopUnroll
Definition: PassManagerBuilder.h:161
LLVMPassManagerBuilderDispose
void LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB)
Definition: PassManagerBuilder.cpp:549
llvm::createBarrierNoopPass
ModulePass * createBarrierNoopPass()
createBarrierNoopPass - This pass is purely a module pass barrier in a pass manager.
Definition: BarrierNoopPass.cpp:43
llvm::createMemCpyOptPass
FunctionPass * createMemCpyOptPass()
The public interface to this file...
Definition: MemCpyOptimizer.cpp:293
llvm::createMergeFunctionsPass
ModulePass * createMergeFunctionsPass()
createMergeFunctionsPass - This pass discovers identical functions and collapses them.
llvm::createGVNPass
FunctionPass * createGVNPass(bool NoMemDepAnalysis=false)
Create a legacy GVN pass.
Definition: GVN.cpp:3244
STLExtras.h
llvm::createCallSiteSplittingPass
FunctionPass * createCallSiteSplittingPass()
Definition: CallSiteSplitting.cpp:573
LegacyPassManager.h
PassManagerBuilder.h
llvm::createInferFunctionAttrsLegacyPass
Pass * createInferFunctionAttrsLegacyPass()
Create a legacy pass manager instance of a pass to infer function attributes.
Definition: InferFunctionAttrs.cpp:87
llvm::createStripDeadPrototypesPass
ModulePass * createStripDeadPrototypesPass()
createStripDeadPrototypesPass - This pass removes any function declarations (prototypes) that are not...
llvm::PassManagerBuilder::EP_LoopOptimizerEnd
@ EP_LoopOptimizerEnd
EP_LoopOptimizerEnd - This extension point allows adding loop passes to the end of the loop optimizer...
Definition: PassManagerBuilder.h:78
llvm::createFloat2IntPass
FunctionPass * createFloat2IntPass()
Definition: Float2Int.cpp:532
llvm::createDivRemPairsPass
FunctionPass * createDivRemPairsPass()
Definition: DivRemPairs.cpp:430
llvm::createSLPVectorizerPass
Pass * createSLPVectorizerPass()
Definition: SLPVectorizer.cpp:13234
CommandLine.h
GlobalExtensions
static ManagedStatic< SmallVector< std::tuple< PassManagerBuilder::ExtensionPointTy, PassManagerBuilder::ExtensionFn, PassManagerBuilder::GlobalExtensionID >, 8 > > GlobalExtensions
Set of global extensions, automatically added as part of the standard set.
Definition: PassManagerBuilder.cpp:77
llvm::createForceFunctionAttrsLegacyPass
Pass * createForceFunctionAttrsLegacyPass()
Create a legacy pass manager instance of a pass to force function attrs.
llvm::createLoopSinkPass
Pass * createLoopSinkPass()
llvm::PassManagerBuilder::addGlobalExtension
static GlobalExtensionID addGlobalExtension(ExtensionPointTy Ty, ExtensionFn Fn)
Adds an extension that will be used by all PassManagerBuilder instances.
Definition: PassManagerBuilder.cpp:88
llvm::PassManagerBuilder::LibraryInfo
TargetLibraryInfoImpl * LibraryInfo
LibraryInfo - Specifies information about the runtime library for the optimizer.
Definition: PassManagerBuilder.h:139
AggressiveInstCombine.h
llvm::ManagedStatic
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
Definition: ManagedStatic.h:83
TargetLibraryInfo.h
GlobalExtensionsCounter
static PassManagerBuilder::GlobalExtensionID GlobalExtensionsCounter
Definition: PassManagerBuilder.cpp:78
llvm::createLibCallsShrinkWrapPass
FunctionPass * createLibCallsShrinkWrapPass()
Definition: LibCallsShrinkWrap.cpp:548
llvm::unwrap
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:284
llvm::PassManagerBuilder::Inliner
Pass * Inliner
Inliner - Specifies the inliner to use.
Definition: PassManagerBuilder.h:143
llvm::PassManagerBuilder::MergeFunctions
bool MergeFunctions
Definition: PassManagerBuilder.h:164
llvm::createIndVarSimplifyPass
Pass * createIndVarSimplifyPass()
Definition: IndVarSimplify.cpp:2158
GVN.h
llvm::createAnnotationRemarksLegacyPass
FunctionPass * createAnnotationRemarksLegacyPass()
Definition: AnnotationRemarks.cpp:117
llvm::createGlobalOptimizerPass
ModulePass * createGlobalOptimizerPass()
createGlobalOptimizerPass - This function returns a new pass that optimizes non-address taken interna...
Definition: GlobalOpt.cpp:2624
llvm::createLoopDistributePass
FunctionPass * createLoopDistributePass()
llvm::PassManagerBuilder::LicmMssaNoAccForPromotionCap
unsigned LicmMssaNoAccForPromotionCap
Definition: PassManagerBuilder.h:167
CFLAndersAliasAnalysis.h
Utils.h
ScopedNoAliasAA.h
llvm::PassManagerBuilder::LoopsInterleaved
bool LoopsInterleaved
Definition: PassManagerBuilder.h:159
llvm::createSimpleLoopUnrollPass
Pass * createSimpleLoopUnrollPass(int OptLevel=2, bool OnlyWhenForced=false, bool ForgetAllSCEV=false)
Definition: LoopUnrollPass.cpp:1466
llvm::createFunctionInliningPass
Pass * createFunctionInliningPass()
createFunctionInliningPass - Return a new pass object that uses a heuristic to inline direct function...
Definition: InlineSimple.cpp:91
llvm::legacy::PassManagerBase::add
virtual void add(Pass *P)=0
Add a pass to the queue of passes to run.
LLVMPassManagerBuilderUseInlinerWithThreshold
void LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB, unsigned Threshold)
See llvm::PassManagerBuilder::Inliner.
Definition: PassManagerBuilder.cpp:588
llvm::PassManagerBuilder
PassManagerBuilder - This class is used to set up a standard optimization sequence for languages like...
Definition: PassManagerBuilder.h:57
llvm::createGlobalsAAWrapperPass
ModulePass * createGlobalsAAWrapperPass()
Definition: GlobalsModRef.cpp:1016
llvm::createIPSCCPPass
ModulePass * createIPSCCPPass()
createIPSCCPPass - This pass propagates constants from call sites into the bodies of functions,...
Definition: SCCP.cpp:110
llvm::PassManagerBuilder::~PassManagerBuilder
~PassManagerBuilder()
Definition: PassManagerBuilder.cpp:66
ForceFunctionAttrs.h
Attributor.h
llvm::MipsISD::Ext
@ Ext
Definition: MipsISelLowering.h:159
llvm::PassManagerBuilder::EP_ScalarOptimizerLate
@ EP_ScalarOptimizerLate
EP_ScalarOptimizerLate - This extension point allows adding optimization passes after most of the mai...
Definition: PassManagerBuilder.h:83
llvm::TargetLibraryInfoWrapperPass
Definition: TargetLibraryInfo.h:474
llvm::createReversePostOrderFunctionAttrsPass
Pass * createReversePostOrderFunctionAttrsPass()
createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call graph in RPO to deduce and...
Definition: FunctionAttrs.cpp:1905
IPO.h
llvm::createGlobalDCEPass
ModulePass * createGlobalDCEPass()
createGlobalDCEPass - This transform is designed to eliminate unreachable internal globals (functions...
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::PassManagerBuilder::ExtensionFn
std::function< void(const PassManagerBuilder &Builder, legacy::PassManagerBase &PM)> ExtensionFn
Extensions are passed to the builder itself (so they can see how it is configured) as well as the pas...
Definition: PassManagerBuilder.h:63
llvm::createLowerExpectIntrinsicPass
FunctionPass * createLowerExpectIntrinsicPass()
LLVMPassManagerBuilderRef
struct LLVMOpaquePassManagerBuilder * LLVMPassManagerBuilderRef
Definition: PassManagerBuilder.h:20
llvm::PassManagerBuilder::OptLevel
unsigned OptLevel
The Optimization Level - Specify the basic optimization level.
Definition: PassManagerBuilder.h:130
llvm::createCorrelatedValuePropagationPass
Pass * createCorrelatedValuePropagationPass()
Definition: CorrelatedValuePropagation.cpp:132
InferFunctionAttrs.h
SimpleLoopUnswitch.h
llvm::createPostOrderFunctionAttrsLegacyPass
Pass * createPostOrderFunctionAttrsLegacyPass()
Create a legacy pass manager instance of a pass to compute function attrs in post-order.
Definition: FunctionAttrs.cpp:1853
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::PassManagerBuilder::GlobalExtensionID
int GlobalExtensionID
Definition: PassManagerBuilder.h:64
llvm::PassManagerBuilder::VerifyInput
bool VerifyInput
Definition: PassManagerBuilder.h:162
llvm::createTypeBasedAAWrapperPass
ImmutablePass * createTypeBasedAAWrapperPass()
llvm::legacy::FunctionPassManager::add
void add(Pass *P) override
Add a pass to the queue of passes to run.
Definition: LegacyPassManager.cpp:1335
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:651
llvm::createSCCPPass
FunctionPass * createSCCPPass()
Definition: SCCP.cpp:368
LLVMPassManagerRef
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition: Types.h:127
llvm::wrap
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:279
llvm::PassManagerBuilder::CallGraphProfile
bool CallGraphProfile
Definition: PassManagerBuilder.h:156
llvm::PassManagerBuilder::SLPVectorize
bool SLPVectorize
Definition: PassManagerBuilder.h:157
llvm::PassManagerBuilder::EP_Peephole
@ EP_Peephole
EP_Peephole - This extension point allows adding passes that perform peephole optimizations similar t...
Definition: PassManagerBuilder.h:102
llvm::createCalledValuePropagationPass
ModulePass * createCalledValuePropagationPass()
createCalledValuePropagationPass - Attach metadata to indirct call sites indicating the set of functi...
llvm::createReassociatePass
FunctionPass * createReassociatePass()
llvm::find_if
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1736
LLVMPassManagerBuilderSetOptLevel
void LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB, unsigned OptLevel)
See llvm::PassManagerBuilder::OptLevel.
Definition: PassManagerBuilder.cpp:555
llvm::ForgetSCEVInLoopUnroll
cl::opt< bool > ForgetSCEVInLoopUnroll
llvm::createAggressiveDCEPass
FunctionPass * createAggressiveDCEPass()
Definition: ADCE.cpp:760
llvm::PassManagerBuilder::removeGlobalExtension
static void removeGlobalExtension(GlobalExtensionID ExtensionID)
Removes an extension that was previously added using addGlobalExtension.
Definition: PassManagerBuilder.cpp:95
LLVMPassManagerBuilderSetSizeLevel
void LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB, unsigned SizeLevel)
See llvm::PassManagerBuilder::SizeLevel.
Definition: PassManagerBuilder.cpp:562
LLVMBool
int LLVMBool
Definition: Types.h:28
llvm::PassManagerBuilder::EP_VectorizerStart
@ EP_VectorizerStart
EP_VectorizerStart - This extension point allows adding optimization passes before the vectorizer and...
Definition: PassManagerBuilder.h:92
LoopUnrollPass.h
llvm::createScopedNoAliasAAWrapperPass
ImmutablePass * createScopedNoAliasAAWrapperPass()
llvm::createBitTrackingDCEPass
FunctionPass * createBitTrackingDCEPass()
Definition: BDCE.cpp:207
llvm::createAlignmentFromAssumptionsPass
FunctionPass * createAlignmentFromAssumptionsPass()
Definition: AlignmentFromAssumptions.cpp:83
LLVMPassManagerBuilderSetDisableUnitAtATime
void LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB, LLVMBool Value)
See llvm::PassManagerBuilder::DisableUnitAtATime.
Definition: PassManagerBuilder.cpp:569
llvm::PassManagerBuilder::populateModulePassManager
void populateModulePassManager(legacy::PassManagerBase &MPM)
populateModulePassManager - This sets up the primary pass manager.
Definition: PassManagerBuilder.cpp:360
llvm::PassManagerBuilder::EP_ModuleOptimizerEarly
@ EP_ModuleOptimizerEarly
EP_ModuleOptimizerEarly - This extension point allows adding passes just before the main module-level...
Definition: PassManagerBuilder.h:74
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::createLoopRotatePass
Pass * createLoopRotatePass(int MaxHeaderSize=-1, bool PrepareForLTO=false)
Definition: LoopRotation.cpp:149
LLVMPassManagerBuilderSetDisableUnrollLoops
void LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB, LLVMBool Value)
See llvm::PassManagerBuilder::DisableUnrollLoops.
Definition: PassManagerBuilder.cpp:575
PassManagerBuilder.h
llvm::PassManagerBuilder::SizeLevel
unsigned SizeLevel
SizeLevel - How much we're optimizing for size.
Definition: PassManagerBuilder.h:134
llvm::createInstSimplifyLegacyPass
FunctionPass * createInstSimplifyLegacyPass()
Definition: InstSimplifyPass.cpp:125
llvm::PassManagerBuilder::EP_LateLoopOptimizations
@ EP_LateLoopOptimizations
EP_LateLoopOptimizations - This extension point allows adding late loop canonicalization and simplifi...
Definition: PassManagerBuilder.h:110
llvm::createLoopInstSimplifyPass
Pass * createLoopInstSimplifyPass()
Definition: LoopInstSimplify.cpp:245
LLVMPassManagerBuilderCreate
LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate()
See llvm::PassManagerBuilder.
Definition: PassManagerBuilder.cpp:544
llvm::createPromoteMemoryToRegisterPass
FunctionPass * createPromoteMemoryToRegisterPass()
Definition: Mem2Reg.cpp:114
llvm::createInstructionCombiningPass
FunctionPass * createInstructionCombiningPass()
Definition: InstructionCombining.cpp:4756
LLVMPassManagerBuilderPopulateModulePassManager
void LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM)
See llvm::PassManagerBuilder::populateModulePassManager.
Definition: PassManagerBuilder.cpp:603
llvm::createEliminateAvailableExternallyPass
ModulePass * createEliminateAvailableExternallyPass()
This transform is designed to eliminate available external globals (functions or global variables)
llvm::PassManagerBuilder::populateFunctionPassManager
void populateFunctionPassManager(legacy::FunctionPassManager &FPM)
populateFunctionPassManager - This fills in the function pass manager, which is expected to be run on...
Definition: PassManagerBuilder.cpp:138
llvm::SimplifyCFGOptions
Definition: SimplifyCFGOptions.h:23
llvm::createLICMPass
Pass * createLICMPass()
Definition: LICM.cpp:349
llvm::PassManagerBuilder::DisableUnrollLoops
bool DisableUnrollLoops
Definition: PassManagerBuilder.h:155
llvm::PassManagerBuilder::EP_EarlyAsPossible
@ EP_EarlyAsPossible
EP_EarlyAsPossible - This extension point allows adding passes before any other transformations,...
Definition: PassManagerBuilder.h:70
SmallVector.h
llvm::createLowerConstantIntrinsicsPass
FunctionPass * createLowerConstantIntrinsicsPass()
Definition: LowerConstantIntrinsics.cpp:203
llvm::createJumpThreadingPass
FunctionPass * createJumpThreadingPass(int Threshold=-1)
Definition: JumpThreading.cpp:176
llvm::createConstantMergePass
ModulePass * createConstantMergePass()
createConstantMergePass - This function returns a new pass that merges duplicate global constants tog...
llvm::legacy::FunctionPassManager
FunctionPassManager manages FunctionPasses.
Definition: LegacyPassManager.h:71
llvm::PassManagerBuilder::EP_EnabledOnOptLevel0
@ EP_EnabledOnOptLevel0
EP_EnabledOnOptLevel0 - This extension point allows adding passes that should not be disabled by O0 o...
Definition: PassManagerBuilder.h:97
llvm::legacy::PassManagerBase
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Definition: LegacyPassManager.h:39
LICM.h
Vectorize.h
llvm::createWarnMissedTransformationsPass
Pass * createWarnMissedTransformationsPass()
Definition: WarnMissedTransforms.cpp:148
llvm::PassManagerBuilder::addExtension
void addExtension(ExtensionPointTy Ty, ExtensionFn Fn)
Definition: PassManagerBuilder.cpp:112
InstCombine.h
llvm::createSpeculativeExecutionIfHasBranchDivergencePass
FunctionPass * createSpeculativeExecutionIfHasBranchDivergencePass()
Definition: SpeculativeExecution.cpp:329
llvm::PassManagerBuilder::DivergentTarget
bool DivergentTarget
Definition: PassManagerBuilder.h:165
llvm::PassManagerBuilder::EP_CGSCCOptimizerLate
@ EP_CGSCCOptimizerLate
EP_CGSCCOptimizerLate - This extension point allows adding CallGraphSCC passes at the end of the main...
Definition: PassManagerBuilder.h:115
llvm::SetLicmMssaOptCap
cl::opt< unsigned > SetLicmMssaOptCap
llvm::createLoopDeletionPass
Pass * createLoopDeletionPass()
Definition: LoopDeletion.cpp:568
llvm::createSROAPass
FunctionPass * createSROAPass()
Definition: SROA.cpp:4859
MPM
ModulePassManager MPM
Definition: PassBuilderBindings.cpp:70
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
FunctionAttrs.h
CFLSteensAliasAnalysis.h
llvm::createLoopVectorizePass
Pass * createLoopVectorizePass()
Definition: LoopVectorize.cpp:7364
GlobalExtensionsNotEmpty
static bool GlobalExtensionsNotEmpty()
Check if GlobalExtensions is constructed and not empty.
Definition: PassManagerBuilder.cpp:83
llvm::createLoopUnrollPass
Pass * createLoopUnrollPass(int OptLevel=2, bool OnlyWhenForced=false, bool ForgetAllSCEV=false, int Threshold=-1, int Count=-1, int AllowPartial=-1, int Runtime=-1, int UpperBound=-1, int AllowPeeling=-1)
Definition: LoopUnrollPass.cpp:1449
llvm::createAnnotation2MetadataLegacyPass
ModulePass * createAnnotation2MetadataLegacyPass()
Definition: Annotation2Metadata.cpp:98
llvm::createOpenMPOptCGSCCLegacyPass
Pass * createOpenMPOptCGSCCLegacyPass()
createOpenMPOptLegacyPass - OpenMP specific optimizations.
Definition: OpenMPOpt.cpp:5289