LLVM  15.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 
46 namespace llvm {
47 cl::opt<bool> RunPartialInlining("enable-partial-inlining", cl::init(false),
49  cl::desc("Run Partial inlinining pass"));
50 
51 static cl::opt<bool>
52 UseGVNAfterVectorization("use-gvn-after-vectorization",
53  cl::init(false), cl::Hidden,
54  cl::desc("Run GVN instead of Early CSE after vectorization passes"));
55 
57  "extra-vectorizer-passes", cl::init(false), cl::Hidden,
58  cl::desc("Run cleanup optimization passes after vectorization."));
59 
60 static cl::opt<bool>
61 RunLoopRerolling("reroll-loops", cl::Hidden,
62  cl::desc("Run the loop rerolling pass"));
63 
64 cl::opt<bool> RunNewGVN("enable-newgvn", cl::init(false), cl::Hidden,
65  cl::desc("Run the NewGVN pass"));
66 
67 // Experimental option to use CFL-AA
69  UseCFLAA("use-cfl-aa", cl::init(::CFLAAType::None), cl::Hidden,
70  cl::desc("Enable the new, experimental CFL alias analysis"),
71  cl::values(clEnumValN(::CFLAAType::None, "none", "Disable CFL-AA"),
73  "Enable unification-based CFL-AA"),
74  clEnumValN(::CFLAAType::Andersen, "anders",
75  "Enable inclusion-based CFL-AA"),
76  clEnumValN(::CFLAAType::Both, "both",
77  "Enable both variants of CFL-AA")));
78 
80  "enable-loopinterchange", cl::init(false), cl::Hidden,
81  cl::desc("Enable the experimental LoopInterchange Pass"));
82 
83 cl::opt<bool> EnableUnrollAndJam("enable-unroll-and-jam", cl::init(false),
84  cl::Hidden,
85  cl::desc("Enable Unroll And Jam Pass"));
86 
87 cl::opt<bool> EnableLoopFlatten("enable-loop-flatten", cl::init(false),
88  cl::Hidden,
89  cl::desc("Enable the LoopFlatten Pass"));
90 
91 cl::opt<bool> EnableDFAJumpThreading("enable-dfa-jump-thread",
92  cl::desc("Enable DFA jump threading."),
93  cl::init(false), cl::Hidden);
94 
95 static cl::opt<bool>
96  EnablePrepareForThinLTO("prepare-for-thinlto", cl::init(false), cl::Hidden,
97  cl::desc("Enable preparation for ThinLTO."));
98 
99 static cl::opt<bool>
100  EnablePerformThinLTO("perform-thinlto", cl::init(false), cl::Hidden,
101  cl::desc("Enable performing ThinLTO."));
102 
103 cl::opt<bool> EnableHotColdSplit("hot-cold-split", cl::init(false),
104  cl::ZeroOrMore, cl::desc("Enable hot-cold splitting pass"));
105 
106 cl::opt<bool> EnableIROutliner("ir-outliner", cl::init(false), cl::Hidden,
107  cl::desc("Enable ir outliner pass"));
108 
110  "enable-loop-versioning-licm", cl::init(false), cl::Hidden,
111  cl::desc("Enable the experimental Loop Versioning LICM pass"));
112 
114  DisablePreInliner("disable-preinline", cl::init(false), cl::Hidden,
115  cl::desc("Disable pre-instrumentation inliner"));
116 
118  "preinline-threshold", cl::Hidden, cl::init(75), cl::ZeroOrMore,
119  cl::desc("Control the amount of inlining in pre-instrumentation inliner "
120  "(default = 75)"));
121 
123  EnableGVNHoist("enable-gvn-hoist", cl::init(false), cl::ZeroOrMore,
124  cl::desc("Enable the GVN hoisting pass (default = off)"));
125 
126 static cl::opt<bool>
127  DisableLibCallsShrinkWrap("disable-libcalls-shrinkwrap", cl::init(false),
128  cl::Hidden,
129  cl::desc("Disable shrink-wrap library calls"));
130 
132  EnableGVNSink("enable-gvn-sink", cl::init(false), cl::ZeroOrMore,
133  cl::desc("Enable the GVN sinking pass (default = off)"));
134 
135 // This option is used in simplifying testing SampleFDO optimizations for
136 // profile loading.
138  EnableCHR("enable-chr", cl::init(true), cl::Hidden,
139  cl::desc("Enable control height reduction optimization (CHR)"));
140 
142  "flattened-profile-used", cl::init(false), cl::Hidden,
143  cl::desc("Indicate the sample profile being used is flattened, i.e., "
144  "no inline hierachy exists in the profile. "));
145 
147  "enable-order-file-instrumentation", cl::init(false), cl::Hidden,
148  cl::desc("Enable order file instrumentation (default = off)"));
149 
151  "enable-matrix", cl::init(false), cl::Hidden,
152  cl::desc("Enable lowering of the matrix intrinsics"));
153 
155  "enable-constraint-elimination", cl::init(false), cl::Hidden,
156  cl::desc(
157  "Enable pass to eliminate conditions based on linear constraints."));
158 
160  "enable-function-specialization", cl::init(false), cl::Hidden,
161  cl::desc("Enable Function Specialization pass"));
162 
164  "attributor-enable", cl::Hidden, cl::init(AttributorRunOption::NONE),
165  cl::desc("Enable the attributor inter-procedural deduction pass."),
167  "enable all attributor runs"),
169  "enable module-wide attributor runs"),
171  "enable call graph SCC attributor runs"),
173  "disable attributor runs")));
174 
176 } // namespace llvm
177 
179  OptLevel = 2;
180  SizeLevel = 0;
181  LibraryInfo = nullptr;
182  Inliner = nullptr;
183  DisableUnrollLoops = false;
184  SLPVectorize = false;
185  LoopVectorize = true;
186  LoopsInterleaved = true;
188  NewGVN = RunNewGVN;
191  DisableGVNLoadPRE = false;
193  VerifyInput = false;
194  VerifyOutput = false;
195  MergeFunctions = false;
196  PrepareForLTO = false;
197  EnablePGOInstrGen = false;
198  EnablePGOCSInstrGen = false;
199  EnablePGOCSInstrUse = false;
200  PGOInstrGen = "";
201  PGOInstrUse = "";
202  PGOSampleUse = "";
205  DivergentTarget = false;
206  CallGraphProfile = true;
207 }
208 
210  delete LibraryInfo;
211  delete Inliner;
212 }
213 
214 /// Set of global extensions, automatically added as part of the standard set.
215 static ManagedStatic<
219  8>>
222 
223 /// Check if GlobalExtensions is constructed and not empty.
224 /// Since GlobalExtensions is a managed static, calling 'empty()' will trigger
225 /// the construction of the object.
227  return GlobalExtensions.isConstructed() && !GlobalExtensions->empty();
228 }
229 
233  auto ExtensionID = GlobalExtensionsCounter++;
234  GlobalExtensions->push_back(std::make_tuple(Ty, std::move(Fn), ExtensionID));
235  return ExtensionID;
236 }
237 
240  // RegisterStandardPasses may try to call this function after GlobalExtensions
241  // has already been destroyed; doing so should not generate an error.
242  if (!GlobalExtensions.isConstructed())
243  return;
244 
245  auto GlobalExtension =
246  llvm::find_if(*GlobalExtensions, [ExtensionID](const auto &elem) {
247  return std::get<2>(elem) == ExtensionID;
248  });
249  assert(GlobalExtension != GlobalExtensions->end() &&
250  "The extension ID to be removed should always be valid.");
251 
252  GlobalExtensions->erase(GlobalExtension);
253 }
254 
256  Extensions.push_back(std::make_pair(Ty, std::move(Fn)));
257 }
258 
259 void PassManagerBuilder::addExtensionsToPM(ExtensionPointTy ETy,
260  legacy::PassManagerBase &PM) const {
261  if (GlobalExtensionsNotEmpty()) {
262  for (auto &Ext : *GlobalExtensions) {
263  if (std::get<0>(Ext) == ETy)
264  std::get<1>(Ext)(*this, PM);
265  }
266  }
267  for (unsigned i = 0, e = Extensions.size(); i != e; ++i)
268  if (Extensions[i].first == ETy)
269  Extensions[i].second(*this, PM);
270 }
271 
272 void PassManagerBuilder::addInitialAliasAnalysisPasses(
273  legacy::PassManagerBase &PM) const {
274  switch (UseCFLAA) {
275  case ::CFLAAType::Steensgaard:
277  break;
278  case ::CFLAAType::Andersen:
280  break;
281  case ::CFLAAType::Both:
284  break;
285  default:
286  break;
287  }
288 
289  // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that
290  // BasicAliasAnalysis wins if they disagree. This is intended to help
291  // support "obvious" type-punning idioms.
294 }
295 
298  addExtensionsToPM(EP_EarlyAsPossible, FPM);
299 
300  // Add LibraryInfo if we have some.
301  if (LibraryInfo)
303 
304  // The backends do not handle matrix intrinsics currently.
305  // Make sure they are also lowered in O0.
306  // FIXME: A lightweight version of the pass should run in the backend
307  // pipeline on demand.
308  if (EnableMatrix && OptLevel == 0)
310 
311  if (OptLevel == 0) return;
312 
313  addInitialAliasAnalysisPasses(FPM);
314 
315  // Lower llvm.expect to metadata before attempting transforms.
316  // Compare/branch metadata may alter the behavior of passes like SimplifyCFG.
319  FPM.add(createSROAPass());
320  FPM.add(createEarlyCSEPass());
321 }
322 
323 void PassManagerBuilder::addFunctionSimplificationPasses(
325  // Start of function pass.
326  // Break up aggregate allocas, using SSAUpdater.
327  assert(OptLevel >= 1 && "Calling function optimizer with no optimization level!");
328  MPM.add(createSROAPass());
329  MPM.add(createEarlyCSEPass(true /* Enable mem-ssa. */)); // Catch trivial redundancies
332 
333  if (OptLevel > 1) {
334  if (EnableGVNHoist)
335  MPM.add(createGVNHoistPass());
336  if (EnableGVNSink) {
337  MPM.add(createGVNSinkPass());
339  SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
340  }
341  }
342 
345 
346  if (OptLevel > 1) {
347  // Speculative execution if the target has divergent branches; otherwise nop.
349 
350  MPM.add(createJumpThreadingPass()); // Thread jumps.
351  MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals
352  }
353  MPM.add(
354  createCFGSimplificationPass(SimplifyCFGOptions().convertSwitchRangeToICmp(
355  true))); // Merge & remove BBs
356  // Combine silly seq's
357  if (OptLevel > 2)
362  addExtensionsToPM(EP_Peephole, MPM);
363 
364  // TODO: Investigate the cost/benefit of tail call elimination on debugging.
365  if (OptLevel > 1)
366  MPM.add(createTailCallEliminationPass()); // Eliminate tail calls
367  MPM.add(
368  createCFGSimplificationPass(SimplifyCFGOptions().convertSwitchRangeToICmp(
369  true))); // Merge & remove BBs
370  MPM.add(createReassociatePass()); // Reassociate expressions
371 
372  // The matrix extension can introduce large vector operations early, which can
373  // benefit from running vector-combine early on.
374  if (EnableMatrix)
376 
377  // Begin the loop pass pipeline.
378 
379  // The simple loop unswitch pass relies on separate cleanup passes. Schedule
380  // them first so when we re-process a loop they run before other loop
381  // passes.
384 
385  // Try to remove as much code from the loop header as possible,
386  // to reduce amount of IR that will have to be duplicated. However,
387  // do not perform speculative hoisting the first time as LICM
388  // will destroy metadata that may not need to be destroyed if run
389  // after loop rotation.
390  // TODO: Investigate promotion cap for O1.
392  /*AllowSpeculation=*/false));
393  // Rotate Loop - disable header duplication at -Oz
394  MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1, PrepareForLTO));
395  // TODO: Investigate promotion cap for O1.
397  /*AllowSpeculation=*/true));
399  // FIXME: We break the loop pass pipeline here in order to do full
400  // simplifycfg. Eventually loop-simplifycfg should be enhanced to replace the
401  // need for this.
403  SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
405  // We resume loop passes creating a second loop pipeline here.
406  if (EnableLoopFlatten) {
407  MPM.add(createLoopFlattenPass()); // Flatten loops
409  }
410  MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
411  MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
412  addExtensionsToPM(EP_LateLoopOptimizations, MPM);
413  MPM.add(createLoopDeletionPass()); // Delete dead loops
414 
416  MPM.add(createLoopInterchangePass()); // Interchange loops
417 
418  // Unroll small loops and perform peeling.
421  addExtensionsToPM(EP_LoopOptimizerEnd, MPM);
422  // This ends the loop pass pipelines.
423 
424  // Break up allocas that may now be splittable after loop unrolling.
425  MPM.add(createSROAPass());
426 
427  if (OptLevel > 1) {
428  MPM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds
429  MPM.add(NewGVN ? createNewGVNPass()
430  : createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
431  }
432  MPM.add(createSCCPPass()); // Constant prop with SCCP
433 
436 
437  // Delete dead bit computations (instcombine runs after to fold away the dead
438  // computations, and then ADCE will run later to exploit any new DCE
439  // opportunities that creates).
440  MPM.add(createBitTrackingDCEPass()); // Delete dead bit computations
441 
442  // Run instcombine after redundancy elimination to exploit opportunities
443  // opened up by them.
445  addExtensionsToPM(EP_Peephole, MPM);
446  if (OptLevel > 1) {
447  if (EnableDFAJumpThreading && SizeLevel == 0)
449 
450  MPM.add(createJumpThreadingPass()); // Thread jumps
452  }
453  MPM.add(createAggressiveDCEPass()); // Delete dead instructions
454 
455  MPM.add(createMemCpyOptPass()); // Remove memcpy / form memset
456  // TODO: Investigate if this is too expensive at O1.
457  if (OptLevel > 1) {
458  MPM.add(createDeadStoreEliminationPass()); // Delete dead stores
460  /*AllowSpeculation=*/true));
461  }
462 
463  addExtensionsToPM(EP_ScalarOptimizerLate, MPM);
464 
465  if (RerollLoops)
466  MPM.add(createLoopRerollPass());
467 
468  // Merge & remove BBs and sink & hoist common instructions.
470  SimplifyCFGOptions().hoistCommonInsts(true).sinkCommonInsts(true)));
471  // Clean up after everything.
473  addExtensionsToPM(EP_Peephole, MPM);
474 
475  if (EnableCHR && OptLevel >= 3 &&
476  (!PGOInstrUse.empty() || !PGOSampleUse.empty() || EnablePGOCSInstrGen))
478 }
479 
480 /// FIXME: Should LTO cause any differences to this set of passes?
481 void PassManagerBuilder::addVectorPasses(legacy::PassManagerBase &PM,
482  bool IsFullLTO) {
484 
485  if (IsFullLTO) {
486  // The vectorizer may have significantly shortened a loop body; unroll
487  // again. Unroll small loops to hide loop backedge latency and saturate any
488  // parallel execution resources of an out-of-order processor. We also then
489  // need to clean up redundancies and loop invariant code.
490  // FIXME: It would be really good to use a loop-integrated instruction
491  // combiner for cleanup here so that the unrolling and LICM can be pipelined
492  // across the loop nests.
493  // We do UnrollAndJam in a separate LPM to ensure it happens before unroll
499  }
500 
501  if (!IsFullLTO) {
502  // Eliminate loads by forwarding stores from the previous iteration to loads
503  // of the current iteration.
505  }
506  // Cleanup after the loop optimization passes.
508 
509  if (OptLevel > 1 && ExtraVectorizerPasses) {
510  // At higher optimization levels, try to clean up any runtime overlap and
511  // alignment checks inserted by the vectorizer. We want to track correlated
512  // runtime checks for two inner loops in the same outer loop, fold any
513  // common computations, hoist loop-invariant aspects out of any outer loop,
514  // and unswitch the runtime checks if possible. Once hoisted, we may have
515  // dead (or speculatable) control flows or more combining opportunities.
516  PM.add(createEarlyCSEPass());
520  /*AllowSpeculation=*/true));
523  SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
525  }
526 
527  // Now that we've formed fast to execute loop structures, we do further
528  // optimizations. These are run afterward as they might block doing complex
529  // analyses and transforms such as what are needed for loop vectorization.
530 
531  // Cleanup after loop vectorization, etc. Simplification passes like CVP and
532  // GVN, loop transforms, and others have already run, so it's now better to
533  // convert to more optimized IR using more aggressive simplify CFG options.
534  // The extra sinking transform can create larger basic blocks, so do this
535  // before SLP vectorization.
537  .forwardSwitchCondToPhi(true)
538  .convertSwitchRangeToICmp(true)
539  .convertSwitchToLookupTable(true)
540  .needCanonicalLoops(false)
541  .hoistCommonInsts(true)
542  .sinkCommonInsts(true)));
543 
544  if (IsFullLTO) {
545  PM.add(createSCCPPass()); // Propagate exposed constants
546  PM.add(createInstructionCombiningPass()); // Clean up again
548  }
549 
550  // Optimize parallel scalar instruction chains into SIMD instructions.
551  if (SLPVectorize) {
553  if (OptLevel > 1 && ExtraVectorizerPasses)
554  PM.add(createEarlyCSEPass());
555  }
556 
557  // Enhance/cleanup vector code.
559 
560  if (!IsFullLTO) {
561  addExtensionsToPM(EP_Peephole, PM);
563 
565  // Unroll and Jam. We do this before unroll but need to be in a separate
566  // loop pass manager in order for the outer loop to be processed by
567  // unroll and jam before the inner loop is unrolled.
569  }
570 
571  // Unroll small loops
574 
575  if (!DisableUnrollLoops) {
576  // LoopUnroll may generate some redundency to cleanup.
578 
579  // Runtime unrolling will introduce runtime check in loop prologue. If the
580  // unrolled loop is a inner loop, then the prologue will be inside the
581  // outer loop. LICM pass can help to promote the runtime check out if the
582  // checked value is loop invariant.
584  /*AllowSpeculation=*/true));
585  }
586 
588  }
589 
590  // After vectorization and unrolling, assume intrinsics may tell us more
591  // about pointer alignments.
593 
594  if (IsFullLTO)
596 }
597 
601 
602  if (!PGOSampleUse.empty()) {
603  MPM.add(createPruneEHPass());
604  // In ThinLTO mode, when flattened profile is used, all the available
605  // profile information will be annotated in PreLink phase so there is
606  // no need to load the profile again in PostLink.
609  }
610 
611  // Allow forcing function attributes as a debugging and tuning aid.
613 
614  // If all optimizations are disabled, just run the always-inline pass and,
615  // if enabled, the function merging pass.
616  if (OptLevel == 0) {
617  if (Inliner) {
618  MPM.add(Inliner);
619  Inliner = nullptr;
620  }
621 
622  // FIXME: The BarrierNoopPass is a HACK! The inliner pass above implicitly
623  // creates a CGSCC pass manager, but we don't want to add extensions into
624  // that pass manager. To prevent this we insert a no-op module pass to reset
625  // the pass manager to get the same behavior as EP_OptimizerLast in non-O0
626  // builds. The function merging pass is
627  if (MergeFunctions)
629  else if (GlobalExtensionsNotEmpty() || !Extensions.empty())
630  MPM.add(createBarrierNoopPass());
631 
632  if (PerformThinLTO) {
633  MPM.add(createLowerTypeTestsPass(nullptr, nullptr, true));
634  // Drop available_externally and unreferenced globals. This is necessary
635  // with ThinLTO in order to avoid leaving undefined references to dead
636  // globals in the object file.
638  MPM.add(createGlobalDCEPass());
639  }
640 
641  addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
642 
645  // Rename anon globals to be able to export them in the summary.
646  // This has to be done after we add the extensions to the pass manager
647  // as there could be passes (e.g. Adddress sanitizer) which introduce
648  // new unnamed globals.
650  }
651 
653  return;
654  }
655 
656  // Add LibraryInfo if we have some.
657  if (LibraryInfo)
659 
660  addInitialAliasAnalysisPasses(MPM);
661 
662  // For ThinLTO there are two passes of indirect call promotion. The
663  // first is during the compile phase when PerformThinLTO=false and
664  // intra-module indirect call targets are promoted. The second is during
665  // the ThinLTO backend when PerformThinLTO=true, when we promote imported
666  // inter-module indirect calls. For that we perform indirect call promotion
667  // earlier in the pass pipeline, here before globalopt. Otherwise imported
668  // available_externally functions look unreferenced and are removed.
669  if (PerformThinLTO) {
670  MPM.add(createLowerTypeTestsPass(nullptr, nullptr, true));
671  }
672 
673  // For SamplePGO in ThinLTO compile phase, we do not want to unroll loops
674  // as it will change the CFG too much to make the 2nd profile annotation
675  // in backend more difficult.
676  bool PrepareForThinLTOUsingPGOSampleProfile =
677  PrepareForThinLTO && !PGOSampleUse.empty();
678  if (PrepareForThinLTOUsingPGOSampleProfile)
679  DisableUnrollLoops = true;
680 
681  // Infer attributes about declarations if possible.
683 
684  // Infer attributes on declarations, call sites, arguments, etc.
687 
688  addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
689 
690  if (OptLevel > 2)
692 
693  // Propage constant function arguments by specializing the functions.
696 
697  MPM.add(createIPSCCPPass()); // IP SCCP
699 
700  MPM.add(createGlobalOptimizerPass()); // Optimize out global vars
701  // Promote any localized global vars.
703 
704  MPM.add(createDeadArgEliminationPass()); // Dead argument elimination
705 
706  MPM.add(createInstructionCombiningPass()); // Clean up after IPCP & DAE
707  addExtensionsToPM(EP_Peephole, MPM);
708  MPM.add(
709  createCFGSimplificationPass(SimplifyCFGOptions().convertSwitchRangeToICmp(
710  true))); // Clean up after IPCP & DAE
711 
712  // We add a module alias analysis pass here. In part due to bugs in the
713  // analysis infrastructure this "works" in that the analysis stays alive
714  // for the entire SCC pass run below.
716 
717  // Start of CallGraph SCC passes.
718  MPM.add(createPruneEHPass()); // Remove dead EH info
719  bool RunInliner = false;
720  if (Inliner) {
721  MPM.add(Inliner);
722  Inliner = nullptr;
723  RunInliner = true;
724  }
725 
726  // Infer attributes on declarations, call sites, arguments, etc. for an SCC.
729 
730  // Try to perform OpenMP specific optimizations. This is a (quick!) no-op if
731  // there are no OpenMP runtime calls present in the module.
732  if (OptLevel > 1)
734 
736  if (OptLevel > 2)
737  MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args
738 
739  addExtensionsToPM(EP_CGSCCOptimizerLate, MPM);
740  addFunctionSimplificationPasses(MPM);
741 
742  // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
743  // pass manager that we are specifically trying to avoid. To prevent this
744  // we must insert a no-op module pass to reset the pass manager.
745  MPM.add(createBarrierNoopPass());
746 
747  if (RunPartialInlining)
749 
750  if (OptLevel > 1 && !PrepareForLTO && !PrepareForThinLTO)
751  // Remove avail extern fns and globals definitions if we aren't
752  // compiling an object file for later LTO. For LTO we want to preserve
753  // these so they are eligible for inlining at link-time. Note if they
754  // are unreferenced they will be removed by GlobalDCE later, so
755  // this only impacts referenced available externally globals.
756  // Eventually they will be suppressed during codegen, but eliminating
757  // here enables more opportunity for GlobalDCE as it may make
758  // globals referenced by available external functions dead
759  // and saves running remaining passes on the eliminated functions.
761 
764 
766 
767  // The inliner performs some kind of dead code elimination as it goes,
768  // but there are cases that are not really caught by it. We might
769  // at some point consider teaching the inliner about them, but it
770  // is OK for now to run GlobalOpt + GlobalDCE in tandem as their
771  // benefits generally outweight the cost, making the whole pipeline
772  // faster.
773  if (RunInliner) {
775  MPM.add(createGlobalDCEPass());
776  }
777 
778  // If we are planning to perform ThinLTO later, let's not bloat the code with
779  // unrolling/vectorization/... now. We'll first run the inliner + CGSCC passes
780  // during ThinLTO and perform the rest of the optimizations afterward.
781  if (PrepareForThinLTO) {
782  // Ensure we perform any last passes, but do so before renaming anonymous
783  // globals in case the passes add any.
784  addExtensionsToPM(EP_OptimizerLast, MPM);
786  // Rename anon globals to be able to export them in the summary.
788  return;
789  }
790 
791  if (PerformThinLTO)
792  // Optimize globals now when performing ThinLTO, this enables more
793  // optimizations later.
795 
796  // Scheduling LoopVersioningLICM when inlining is over, because after that
797  // we may see more accurate aliasing. Reason to run this late is that too
798  // early versioning may prevent further inlining due to increase of code
799  // size. By placing it just after inlining other optimizations which runs
800  // later might get benefit of no-alias assumption in clone loop.
801  if (UseLoopVersioningLICM) {
802  MPM.add(createLoopVersioningLICMPass()); // Do LoopVersioningLICM
804  /*AllowSpeculation=*/true));
805  }
806 
807  // We add a fresh GlobalsModRef run at this point. This is particularly
808  // useful as the above will have inlined, DCE'ed, and function-attr
809  // propagated everything. We should at this point have a reasonably minimal
810  // and richly annotated call graph. By computing aliasing and mod/ref
811  // information for all local globals here, the late loop passes and notably
812  // the vectorizer will be able to use them to help recognize vectorizable
813  // memory operations.
814  //
815  // Note that this relies on a bug in the pass manager which preserves
816  // a module analysis into a function pass pipeline (and throughout it) so
817  // long as the first function pass doesn't invalidate the module analysis.
818  // Thus both Float2Int and LoopRotate have to preserve AliasAnalysis for
819  // this to work. Fortunately, it is trivial to preserve AliasAnalysis
820  // (doing nothing preserves it as it is required to be conservatively
821  // correct in the face of IR changes).
823 
824  MPM.add(createFloat2IntPass());
826 
827  if (EnableMatrix) {
829  // CSE the pointer arithmetic of the column vectors. This allows alias
830  // analysis to establish no-aliasing between loads and stores of different
831  // columns of the same matrix.
832  MPM.add(createEarlyCSEPass(false));
833  }
834 
835  addExtensionsToPM(EP_VectorizerStart, MPM);
836 
837  // Re-rotate loops in all our loop nests. These may have fallout out of
838  // rotated form due to GVN or other transformations, and the vectorizer relies
839  // on the rotated form. Disable header duplication at -Oz.
840  MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1, PrepareForLTO));
841 
842  // Distribute loops to allow partial vectorization. I.e. isolate dependences
843  // into separate loop that would otherwise inhibit vectorization. This is
844  // currently only performed for loops marked with the metadata
845  // llvm.loop.distribute=true or when -enable-loop-distribute is specified.
847 
848  addVectorPasses(MPM, /* IsFullLTO */ false);
849 
850  // FIXME: We shouldn't bother with this anymore.
851  MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
852 
853  // GlobalOpt already deletes dead functions and globals, at -O2 try a
854  // late pass of GlobalDCE. It is capable of deleting dead cycles.
855  if (OptLevel > 1) {
856  MPM.add(createGlobalDCEPass()); // Remove dead fns and globals.
857  MPM.add(createConstantMergePass()); // Merge dup global constants
858  }
859 
860  // See comment in the new PM for justification of scheduling splitting at
861  // this stage (\ref buildModuleSimplificationPipeline).
864 
865  if (EnableIROutliner)
866  MPM.add(createIROutlinerPass());
867 
868  if (MergeFunctions)
870 
871  // Add Module flag "CG Profile" based on Branch Frequency Information.
872  if (CallGraphProfile)
874 
875  // LoopSink pass sinks instructions hoisted by LICM, which serves as a
876  // canonicalization pass that enables other optimizations. As a result,
877  // LoopSink pass needs to be a very late IR pass to avoid undoing LICM
878  // result too early.
879  MPM.add(createLoopSinkPass());
880  // Get rid of LCSSA nodes.
882 
883  // This hoists/decomposes div/rem ops. It should run after other sink/hoist
884  // passes to avoid re-sinking, but before SimplifyCFG because it can allow
885  // flattening of blocks.
886  MPM.add(createDivRemPairsPass());
887 
888  // LoopSink (and other loop passes since the last simplifyCFG) might have
889  // resulted in single-entry-single-exit or empty blocks. Clean up the CFG.
891  SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
892 
893  addExtensionsToPM(EP_OptimizerLast, MPM);
894 
895  if (PrepareForLTO) {
897  // Rename anon globals to be able to handle them in the summary
899  }
900 
902 }
903 
904 void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) {
905  // Load sample profile before running the LTO optimization pipeline.
906  if (!PGOSampleUse.empty()) {
907  PM.add(createPruneEHPass());
909  }
910 
911  // Remove unused virtual tables to improve the quality of code generated by
912  // whole-program devirtualization and bitset lowering.
913  PM.add(createGlobalDCEPass());
914 
915  // Provide AliasAnalysis services for optimizations.
916  addInitialAliasAnalysisPasses(PM);
917 
918  // Allow forcing function attributes as a debugging and tuning aid.
920 
921  // Infer attributes about declarations if possible.
923 
924  if (OptLevel > 1) {
925  // Split call-site with more constrained arguments.
927 
928  // Propage constant function arguments by specializing the functions.
931 
932  // Propagate constants at call sites into the functions they call. This
933  // opens opportunities for globalopt (and inlining) by substituting function
934  // pointers passed as arguments to direct uses of functions.
935  PM.add(createIPSCCPPass());
936 
937  // Attach metadata to indirect call sites indicating the set of functions
938  // they may target at run-time. This should follow IPSCCP.
940 
941  // Infer attributes on declarations, call sites, arguments, etc.
944  }
945 
946  // Infer attributes about definitions. The readnone attribute in particular is
947  // required for virtual constant propagation.
950 
951  // Split globals using inrange annotations on GEP indices. This can help
952  // improve the quality of generated code when virtual constant propagation or
953  // control flow integrity are enabled.
955 
956  // Apply whole-program devirtualization and virtual constant propagation.
958 
959  // That's all we need at opt level 1.
960  if (OptLevel == 1)
961  return;
962 
963  // Now that we internalized some globals, see if we can hack on them!
965  // Promote any localized global vars.
967 
968  // Linking modules together can lead to duplicated global constants, only
969  // keep one copy of each constant.
971 
972  // Remove unused arguments from functions.
974 
975  // Reduce the code after globalopt and ipsccp. Both can open up significant
976  // simplification opportunities, and both can propagate functions through
977  // function pointers. When this happens, we often have to resolve varargs
978  // calls, etc, so let instcombine do this.
979  if (OptLevel > 2)
982  addExtensionsToPM(EP_Peephole, PM);
983 
984  // Inline small functions
985  bool RunInliner = Inliner;
986  if (RunInliner) {
987  PM.add(Inliner);
988  Inliner = nullptr;
989  }
990 
991  PM.add(createPruneEHPass()); // Remove dead EH info.
992 
993  // Infer attributes on declarations, call sites, arguments, etc. for an SCC.
996 
997  // Try to perform OpenMP specific optimizations. This is a (quick!) no-op if
998  // there are no OpenMP runtime calls present in the module.
999  if (OptLevel > 1)
1001 
1002  // Optimize globals again if we ran the inliner.
1003  if (RunInliner)
1005  PM.add(createGlobalDCEPass()); // Remove dead functions.
1006 
1007  // If we didn't decide to inline a function, check to see if we can
1008  // transform it to pass arguments by value instead of by reference.
1010 
1011  // The IPO passes may leave cruft around. Clean up after them.
1013  addExtensionsToPM(EP_Peephole, PM);
1014  PM.add(createJumpThreadingPass(/*FreezeSelectCond*/ true));
1015 
1016  // Break up allocas
1017  PM.add(createSROAPass());
1018 
1019  // LTO provides additional opportunities for tailcall elimination due to
1020  // link-time inlining, and visibility of nocapture attribute.
1021  if (OptLevel > 1)
1023 
1024  // Infer attributes on declarations, call sites, arguments, etc.
1025  PM.add(createPostOrderFunctionAttrsLegacyPass()); // Add nocapture.
1026  // Run a few AA driven optimizations here and now, to cleanup the code.
1027  PM.add(createGlobalsAAWrapperPass()); // IP alias analysis.
1028 
1030  /*AllowSpeculation=*/true));
1031  PM.add(NewGVN ? createNewGVNPass()
1032  : createGVNPass(DisableGVNLoadPRE)); // Remove redundancies.
1033  PM.add(createMemCpyOptPass()); // Remove dead memcpys.
1034 
1035  // Nuke dead stores.
1037  PM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds.
1038 
1039  // More loops are countable; try to optimize them.
1040  if (EnableLoopFlatten)
1041  PM.add(createLoopFlattenPass());
1046 
1049 
1050  // Unroll small loops and perform peeling.
1054 
1055  addVectorPasses(PM, /* IsFullLTO */ true);
1056 
1057  addExtensionsToPM(EP_Peephole, PM);
1058 
1059  PM.add(createJumpThreadingPass(/*FreezeSelectCond*/ true));
1060 }
1061 
1062 void PassManagerBuilder::addLateLTOOptimizationPasses(
1064  // See comment in the new PM for justification of scheduling splitting at
1065  // this stage (\ref buildLTODefaultPipeline).
1066  if (EnableHotColdSplit)
1068 
1069  // Delete basic blocks, which optimization passes may have killed.
1070  PM.add(
1071  createCFGSimplificationPass(SimplifyCFGOptions().hoistCommonInsts(true)));
1072 
1073  // Drop bodies of available externally objects to improve GlobalDCE.
1075 
1076  // Now that we have optimized the program, discard unreachable functions.
1077  PM.add(createGlobalDCEPass());
1078 
1079  // FIXME: this is profitable (for compiler time) to do at -O0 too, but
1080  // currently it damages debug info.
1081  if (MergeFunctions)
1083 }
1084 
1087  return wrap(PMB);
1088 }
1089 
1092  delete Builder;
1093 }
1094 
1095 void
1097  unsigned OptLevel) {
1099  Builder->OptLevel = OptLevel;
1100 }
1101 
1102 void
1104  unsigned SizeLevel) {
1106  Builder->SizeLevel = SizeLevel;
1107 }
1108 
1109 void
1111  LLVMBool Value) {
1112  // NOTE: The DisableUnitAtATime switch has been removed.
1113 }
1114 
1115 void
1117  LLVMBool Value) {
1119  Builder->DisableUnrollLoops = Value;
1120 }
1121 
1122 void
1124  LLVMBool Value) {
1125  // NOTE: The simplify-libcalls pass has been removed.
1126 }
1127 
1128 void
1130  unsigned Threshold) {
1132  Builder->Inliner = createFunctionInliningPass(Threshold);
1133 }
1134 
1135 void
1137  LLVMPassManagerRef PM) {
1139  legacy::FunctionPassManager *FPM = unwrap<legacy::FunctionPassManager>(PM);
1140  Builder->populateFunctionPassManager(*FPM);
1141 }
1142 
1143 void
1145  LLVMPassManagerRef PM) {
1148  Builder->populateModulePassManager(*MPM);
1149 }
llvm::PassManagerBuilder::LicmMssaOptCap
unsigned LicmMssaOptCap
Definition: PassManagerBuilder.h:171
i
i
Definition: README.txt:29
llvm::createLoopLoadEliminationPass
FunctionPass * createLoopLoadEliminationPass()
Definition: LoopLoadElimination.cpp:703
llvm::PassManagerBuilder::EP_OptimizerLast
@ EP_OptimizerLast
EP_OptimizerLast – This extension point allows adding passes that run after everything else.
Definition: PassManagerBuilder.h:87
llvm::createAssumeSimplifyPass
FunctionPass * createAssumeSimplifyPass()
Definition: AssumeBundleBuilder.cpp:606
TypeBasedAliasAnalysis.h
Instrumentation.h
llvm::createMergedLoadStoreMotionPass
FunctionPass * createMergedLoadStoreMotionPass(bool SplitFooterBB=false)
createMergedLoadStoreMotionPass - The public interface to this file.
Definition: MergedLoadStoreMotion.cpp:397
llvm::createSimpleLoopUnswitchLegacyPass
Pass * createSimpleLoopUnswitchLegacyPass(bool NonTrivial=false)
Create the legacy pass object for the simple loop unswitcher.
Definition: SimpleLoopUnswitch.cpp:3282
llvm::RunNewGVN
cl::opt< bool > RunNewGVN
llvm::createGVNSinkPass
FunctionPass * createGVNSinkPass()
Definition: GVNSink.cpp:934
llvm::PassManagerBuilder::PGOSampleUse
std::string PGOSampleUse
Path of the sample Profile data file.
Definition: PassManagerBuilder.h:185
LLVMPassManagerBuilderPopulateFunctionPassManager
void LLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM)
See llvm::PassManagerBuilder::populateFunctionPassManager.
Definition: PassManagerBuilder.cpp:1136
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::createTailCallEliminationPass
FunctionPass * createTailCallEliminationPass()
Definition: TailRecursionElimination.cpp:915
llvm::PassManagerBuilder::PassManagerBuilder
PassManagerBuilder()
Definition: PassManagerBuilder.cpp:178
llvm::createCFLAndersAAWrapperPass
ImmutablePass * createCFLAndersAAWrapperPass()
llvm::EnableHotColdSplit
cl::opt< bool > EnableHotColdSplit
Scalar.h
llvm::createLowerTypeTestsPass
ModulePass * createLowerTypeTestsPass(ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary, bool DropTypeTests=false)
This pass lowers type metadata and the llvm.type.test intrinsic to bitsets.
llvm::PassManagerBuilder::VerifyOutput
bool VerifyOutput
Definition: PassManagerBuilder.h:165
llvm::ExtraVectorizerPasses
cl::opt< bool > ExtraVectorizerPasses
llvm::EnableConstraintElimination
cl::opt< bool > EnableConstraintElimination
llvm::ALL
@ ALL
Definition: Attributor.h:5007
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:1185
llvm::createLoopSimplifyCFGPass
Pass * createLoopSimplifyCFGPass()
Definition: LoopSimplifyCFG.cpp:763
llvm::createPruneEHPass
Pass * createPruneEHPass()
createPruneEHPass - Return a new pass object which transforms invoke instructions into calls,...
Definition: PruneEH.cpp:60
llvm::RunPartialInlining
cl::opt< bool > RunPartialInlining
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:1759
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:139
llvm::createSampleProfileLoaderPass
ModulePass * createSampleProfileLoaderPass()
Definition: SampleProfile.cpp:2062
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:162
LLVMPassManagerBuilderSetDisableSimplifyLibCalls
void LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB, LLVMBool Value)
See llvm::PassManagerBuilder::DisableSimplifyLibCalls.
Definition: PassManagerBuilder.cpp:1123
llvm::createVectorCombinePass
Pass * createVectorCombinePass()
Definition: VectorCombine.cpp:1550
llvm::createCFLSteensAAWrapperPass
ImmutablePass * createCFLSteensAAWrapperPass()
llvm::createLoopIdiomPass
Pass * createLoopIdiomPass()
Definition: LoopIdiomRecognize.cpp:345
llvm::PassManagerBuilder::PerformThinLTO
bool PerformThinLTO
Definition: PassManagerBuilder.h:169
llvm::CFLAAType::Andersen
@ Andersen
llvm::createDeadStoreEliminationPass
FunctionPass * createDeadStoreEliminationPass()
Definition: DeadStoreElimination.cpp:2218
llvm::PassManagerBuilder::ExtensionPointTy
ExtensionPointTy
Definition: PassManagerBuilder.h:66
llvm::PassManagerBuilder::ForgetAllSCEVInLoopUnroll
bool ForgetAllSCEVInLoopUnroll
Definition: PassManagerBuilder.h:163
LLVMPassManagerBuilderDispose
void LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB)
Definition: PassManagerBuilder.cpp:1090
llvm::UseCFLAA
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")))
llvm::EnableKnowledgeRetention
cl::opt< bool > EnableKnowledgeRetention
enable preservation of attributes in assume like: call void @llvm.assume(i1 true) [ "nonnull"(i32* PT...
Definition: InstCombineCalls.cpp:94
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:294
llvm::createMergeFunctionsPass
ModulePass * createMergeFunctionsPass()
createMergeFunctionsPass - This pass discovers identical functions and collapses them.
llvm::PassManagerBuilder::ExportSummary
ModuleSummaryIndex * ExportSummary
The module summary index to use for exporting information from the regular LTO phase,...
Definition: PassManagerBuilder.h:148
llvm::EnableOrderFileInstrumentation
cl::opt< bool > EnableOrderFileInstrumentation
llvm::CFLAAType::Both
@ Both
llvm::createGVNPass
FunctionPass * createGVNPass(bool NoMemDepAnalysis=false)
Create a legacy GVN pass.
Definition: GVN.cpp:3250
llvm::EnableMatrix
cl::opt< bool > EnableMatrix
llvm::createAttributorLegacyPass
Pass * createAttributorLegacyPass()
Definition: Attributor.cpp:3437
STLExtras.h
llvm::createCGProfileLegacyPass
ModulePass * createCGProfileLegacyPass()
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::createNameAnonGlobalPass
ModulePass * createNameAnonGlobalPass()
===------------------------------------------------------------------—===//
Definition: NameAnonGlobals.cpp:118
llvm::createControlHeightReductionLegacyPass
FunctionPass * createControlHeightReductionLegacyPass()
Definition: ControlHeightReduction.cpp:142
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::createAttributorCGSCCLegacyPass
Pass * createAttributorCGSCCLegacyPass()
Definition: Attributor.cpp:3438
llvm::createFloat2IntPass
FunctionPass * createFloat2IntPass()
Definition: Float2Int.cpp:532
llvm::createDivRemPairsPass
FunctionPass * createDivRemPairsPass()
Definition: DivRemPairs.cpp:429
llvm::createSLPVectorizerPass
Pass * createSLPVectorizerPass()
Definition: SLPVectorizer.cpp:11840
CommandLine.h
llvm::PassManagerBuilder::PGOInstrGen
std::string PGOInstrGen
Profile data file name that the instrumentation will be written to.
Definition: PassManagerBuilder.h:181
llvm::MODULE
@ MODULE
Definition: Attributor.h:5005
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:220
llvm::createForceFunctionAttrsLegacyPass
Pass * createForceFunctionAttrsLegacyPass()
Create a legacy pass manager instance of a pass to force function attrs.
llvm::createDFAJumpThreadingPass
FunctionPass * createDFAJumpThreadingPass()
Definition: DFAJumpThreading.cpp:207
llvm::FlattenedProfileUsed
cl::opt< bool > FlattenedProfileUsed
llvm::PassManagerBuilder::NewGVN
bool NewGVN
Definition: PassManagerBuilder.h:161
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:231
llvm::createLoopInterchangePass
Pass * createLoopInterchangePass()
Definition: LoopInterchange.cpp:1729
llvm::createCanonicalizeAliasesPass
ModulePass * createCanonicalizeAliasesPass()
Definition: CanonicalizeAliases.cpp:101
llvm::PassManagerBuilder::LibraryInfo
TargetLibraryInfoImpl * LibraryInfo
LibraryInfo - Specifies information about the runtime library for the optimizer.
Definition: PassManagerBuilder.h:139
llvm::createWholeProgramDevirtPass
ModulePass * createWholeProgramDevirtPass(ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary)
This pass implements whole-program devirtualization using type metadata.
Definition: WholeProgramDevirt.cpp:820
llvm::createLowerMatrixIntrinsicsPass
Pass * createLowerMatrixIntrinsicsPass()
Definition: LowerMatrixIntrinsics.cpp:2325
llvm::CSKYAttrs::NONE
@ NONE
Definition: CSKYAttributes.h:76
llvm::createLoopVersioningLICMPass
Pass * createLoopVersioningLICMPass()
Definition: LoopVersioningLICM.cpp:658
llvm::createGlobalSplitPass
ModulePass * createGlobalSplitPass()
This pass splits globals into pieces for the benefit of whole-program devirtualization and control-fl...
Definition: GlobalSplit.cpp:185
llvm::createNewGVNPass
FunctionPass * createNewGVNPass()
Definition: NewGVN.cpp:4260
llvm::ManagedStatic
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
Definition: ManagedStatic.h:83
TargetLibraryInfo.h
llvm::DisableLibCallsShrinkWrap
static cl::opt< bool > DisableLibCallsShrinkWrap("disable-libcalls-shrinkwrap", cl::init(false), cl::Hidden, cl::desc("Disable shrink-wrap library calls"))
GlobalExtensionsCounter
static PassManagerBuilder::GlobalExtensionID GlobalExtensionsCounter
Definition: PassManagerBuilder.cpp:221
llvm::DisablePreInliner
cl::opt< bool > DisablePreInliner
llvm::createLibCallsShrinkWrapPass
FunctionPass * createLibCallsShrinkWrapPass()
Definition: LibCallsShrinkWrap.cpp:545
llvm::unwrap
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:264
llvm::PassManagerBuilder::PrepareForThinLTO
bool PrepareForThinLTO
Definition: PassManagerBuilder.h:168
llvm::PassManagerBuilder::Inliner
Pass * Inliner
Inliner - Specifies the inliner to use.
Definition: PassManagerBuilder.h:143
llvm::PassManagerBuilder::MergeFunctions
bool MergeFunctions
Definition: PassManagerBuilder.h:166
llvm::createIndVarSimplifyPass
Pass * createIndVarSimplifyPass()
Definition: IndVarSimplify.cpp:2118
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:2558
llvm::createLoopDistributePass
FunctionPass * createLoopDistributePass()
llvm::PreInlineThreshold
cl::opt< int > PreInlineThreshold
llvm::PassManagerBuilder::LicmMssaNoAccForPromotionCap
unsigned LicmMssaNoAccForPromotionCap
Definition: PassManagerBuilder.h:172
CFLAndersAliasAnalysis.h
Utils.h
ScopedNoAliasAA.h
llvm::EnableDFAJumpThreading
cl::opt< bool > EnableDFAJumpThreading
llvm::PassManagerBuilder::LoopsInterleaved
bool LoopsInterleaved
Definition: PassManagerBuilder.h:159
llvm::createHotColdSplittingPass
ModulePass * createHotColdSplittingPass()
createHotColdSplittingPass - This pass outlines cold blocks into a separate function(s).
Definition: HotColdSplitting.cpp:780
llvm::createSimpleLoopUnrollPass
Pass * createSimpleLoopUnrollPass(int OptLevel=2, bool OnlyWhenForced=false, bool ForgetAllSCEV=false)
Definition: LoopUnrollPass.cpp:1455
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.
llvm::EnablePrepareForThinLTO
static cl::opt< bool > EnablePrepareForThinLTO("prepare-for-thinlto", cl::init(false), cl::Hidden, cl::desc("Enable preparation for ThinLTO."))
LLVMPassManagerBuilderUseInlinerWithThreshold
void LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB, unsigned Threshold)
See llvm::PassManagerBuilder::Inliner.
Definition: PassManagerBuilder.cpp:1129
llvm::PassManagerBuilder
PassManagerBuilder - This class is used to set up a standard optimization sequence for languages like...
Definition: PassManagerBuilder.h:57
llvm::cl::ZeroOrMore
@ ZeroOrMore
Definition: CommandLine.h:116
llvm::createGlobalsAAWrapperPass
ModulePass * createGlobalsAAWrapperPass()
Definition: GlobalsModRef.cpp:1051
llvm::createIPSCCPPass
ModulePass * createIPSCCPPass()
createIPSCCPPass - This pass propagates constants from call sites into the bodies of functions,...
Definition: SCCP.cpp:107
llvm::PassManagerBuilder::~PassManagerBuilder
~PassManagerBuilder()
Definition: PassManagerBuilder.cpp:209
ForceFunctionAttrs.h
llvm::cl::opt< bool >
Attributor.h
llvm::UseGVNAfterVectorization
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"))
llvm::createLoopRerollPass
Pass * createLoopRerollPass()
Definition: LoopRerollPass.cpp:501
llvm::CFLAAType::None
@ None
llvm::MipsISD::Ext
@ Ext
Definition: MipsISelLowering.h:159
llvm::cl::values
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:685
llvm::createGVNHoistPass
FunctionPass * createGVNHoistPass()
Definition: GVNHoist.cpp:1267
llvm::RunLoopRerolling
static cl::opt< bool > RunLoopRerolling("reroll-loops", cl::Hidden, cl::desc("Run the loop rerolling pass"))
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:468
llvm::createReversePostOrderFunctionAttrsPass
Pass * createReversePostOrderFunctionAttrsPass()
createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call graph in RPO to deduce and...
Definition: FunctionAttrs.cpp:1995
llvm::createAggressiveInstCombinerPass
FunctionPass * createAggressiveInstCombinerPass()
Definition: AggressiveInstCombine.cpp:463
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::numbers::e
constexpr double e
Definition: MathExtras.h:57
llvm::createLowerExpectIntrinsicPass
FunctionPass * createLowerExpectIntrinsicPass()
LLVMPassManagerBuilderRef
struct LLVMOpaquePassManagerBuilder * LLVMPassManagerBuilderRef
Definition: PassManagerBuilder.h:20
AggressiveInstCombine.h
llvm::PassManagerBuilder::RerollLoops
bool RerollLoops
Definition: PassManagerBuilder.h:160
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:432
llvm::EnableGVNSink
cl::opt< bool > EnableGVNSink
llvm::PassManagerBuilder::OptLevel
unsigned OptLevel
The Optimization Level - Specify the basic optimization level.
Definition: PassManagerBuilder.h:130
llvm::createCorrelatedValuePropagationPass
Pass * createCorrelatedValuePropagationPass()
Definition: CorrelatedValuePropagation.cpp:131
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:1943
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::PassManagerBuilder::PGOInstrUse
std::string PGOInstrUse
Path of the profile data file.
Definition: PassManagerBuilder.h:183
llvm::PassManagerBuilder::GlobalExtensionID
int GlobalExtensionID
Definition: PassManagerBuilder.h:64
llvm::PassManagerBuilder::VerifyInput
bool VerifyInput
Definition: PassManagerBuilder.h:164
llvm::createTypeBasedAAWrapperPass
ImmutablePass * createTypeBasedAAWrapperPass()
llvm::EnableIROutliner
cl::opt< bool > EnableIROutliner
llvm::legacy::FunctionPassManager::add
void add(Pass *P) override
Add a pass to the queue of passes to run.
Definition: LegacyPassManager.cpp:1335
llvm::createArgumentPromotionPass
Pass * createArgumentPromotionPass(unsigned maxElements=3)
createArgumentPromotionPass - This pass promotes "by reference" arguments to be passed by value if th...
Definition: ArgumentPromotion.cpp:1019
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:651
llvm::createSCCPPass
FunctionPass * createSCCPPass()
Definition: SCCP.cpp:285
LLVMPassManagerRef
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition: Types.h:127
llvm::CFLAAType::Steensgaard
@ Steensgaard
llvm::wrap
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:259
llvm::PassManagerBuilder::CallGraphProfile
bool CallGraphProfile
Definition: PassManagerBuilder.h:156
llvm::CGSCC
@ CGSCC
Definition: Attributor.h:5006
llvm::PassManagerBuilder::SLPVectorize
bool SLPVectorize
Definition: PassManagerBuilder.h:157
llvm::createIROutlinerPass
ModulePass * createIROutlinerPass()
createIROutlinerPass - This pass finds similar code regions and factors those regions out into functi...
Definition: IROutliner.cpp:3086
llvm::EnableLoopFlatten
cl::opt< bool > EnableLoopFlatten
clEnumValN
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:660
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::PassManagerBuilder::PrepareForLTO
bool PrepareForLTO
Definition: PassManagerBuilder.h:167
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:1632
LLVMPassManagerBuilderSetOptLevel
void LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB, unsigned OptLevel)
See llvm::PassManagerBuilder::OptLevel.
Definition: PassManagerBuilder.cpp:1096
llvm::ForgetSCEVInLoopUnroll
cl::opt< bool > ForgetSCEVInLoopUnroll
llvm::createAggressiveDCEPass
FunctionPass * createAggressiveDCEPass()
Definition: ADCE.cpp:754
llvm::PassManagerBuilder::removeGlobalExtension
static void removeGlobalExtension(GlobalExtensionID ExtensionID)
Removes an extension that was previously added using addGlobalExtension.
Definition: PassManagerBuilder.cpp:238
LLVMPassManagerBuilderSetSizeLevel
void LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB, unsigned SizeLevel)
See llvm::PassManagerBuilder::SizeLevel.
Definition: PassManagerBuilder.cpp:1103
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
llvm::EnableCHR
cl::opt< bool > EnableCHR
LoopUnrollPass.h
llvm::PassManagerBuilder::EnablePGOInstrGen
bool EnablePGOInstrGen
Enable profile instrumentation pass.
Definition: PassManagerBuilder.h:175
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:1110
llvm::PassManagerBuilder::populateModulePassManager
void populateModulePassManager(legacy::PassManagerBase &MPM)
populateModulePassManager - This sets up the primary pass manager.
Definition: PassManagerBuilder.cpp:598
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:151
LLVMPassManagerBuilderSetDisableUnrollLoops
void LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB, LLVMBool Value)
See llvm::PassManagerBuilder::DisableUnrollLoops.
Definition: PassManagerBuilder.cpp:1116
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::UseLoopVersioningLICM
static cl::opt< bool > UseLoopVersioningLICM("enable-loop-versioning-licm", cl::init(false), cl::Hidden, cl::desc("Enable the experimental Loop Versioning LICM pass"))
llvm::EnablePerformThinLTO
static cl::opt< bool > EnablePerformThinLTO("perform-thinlto", cl::init(false), cl::Hidden, cl::desc("Enable performing ThinLTO."))
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
llvm::PassManagerBuilder::EnablePGOCSInstrGen
bool EnablePGOCSInstrGen
Enable profile context sensitive instrumentation pass.
Definition: PassManagerBuilder.h:177
LLVMPassManagerBuilderCreate
LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate()
See llvm::PassManagerBuilder.
Definition: PassManagerBuilder.cpp:1085
llvm::createPromoteMemoryToRegisterPass
FunctionPass * createPromoteMemoryToRegisterPass()
Definition: Mem2Reg.cpp:114
llvm::PassManagerBuilder::EnablePGOCSInstrUse
bool EnablePGOCSInstrUse
Enable profile context sensitive profile use pass.
Definition: PassManagerBuilder.h:179
llvm::createInstructionCombiningPass
FunctionPass * createInstructionCombiningPass()
Definition: InstructionCombining.cpp:4610
LLVMPassManagerBuilderPopulateModulePassManager
void LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM)
See llvm::PassManagerBuilder::populateModulePassManager.
Definition: PassManagerBuilder.cpp:1144
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:296
llvm::SimplifyCFGOptions
Definition: SimplifyCFGOptions.h:23
llvm::createLICMPass
Pass * createLICMPass()
Definition: LICM.cpp:345
llvm::PassManagerBuilder::DisableUnrollLoops
bool DisableUnrollLoops
Definition: PassManagerBuilder.h:155
llvm::createConstraintEliminationPass
FunctionPass * createConstraintEliminationPass()
Definition: ConstraintElimination.cpp:809
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::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::createLoopFlattenPass
FunctionPass * createLoopFlattenPass()
Definition: LoopFlatten.cpp:969
llvm::createInstrOrderFilePass
ModulePass * createInstrOrderFilePass()
Definition: InstrOrderFile.cpp:202
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
llvm::EnableLoopInterchange
cl::opt< bool > EnableLoopInterchange
Vectorize.h
llvm::EnableUnrollAndJam
cl::opt< bool > EnableUnrollAndJam
llvm::createPartialInliningPass
ModulePass * createPartialInliningPass()
createPartialInliningPass - This pass inlines parts of functions.
Definition: PartialInlining.cpp:1525
llvm::createWarnMissedTransformationsPass
Pass * createWarnMissedTransformationsPass()
Definition: WarnMissedTransforms.cpp:148
llvm::AttributorRun
cl::opt< AttributorRunOption > AttributorRun
llvm::PassManagerBuilder::addExtension
void addExtension(ExtensionPointTy Ty, ExtensionFn Fn)
Definition: PassManagerBuilder.cpp:255
InstCombine.h
llvm::createSpeculativeExecutionIfHasBranchDivergencePass
FunctionPass * createSpeculativeExecutionIfHasBranchDivergencePass()
Definition: SpeculativeExecution.cpp:329
llvm::cl::desc
Definition: CommandLine.h:405
llvm::createLowerMatrixIntrinsicsMinimalPass
Pass * createLowerMatrixIntrinsicsMinimalPass()
Definition: LowerMatrixIntrinsics.cpp:2367
llvm::PassManagerBuilder::DivergentTarget
bool DivergentTarget
Definition: PassManagerBuilder.h:170
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::createFunctionSpecializationPass
ModulePass * createFunctionSpecializationPass()
createFunctionSpecializationPass - This pass propagates constants from call sites to the specialized ...
Definition: SCCP.cpp:196
llvm::SetLicmMssaOptCap
cl::opt< unsigned > SetLicmMssaOptCap
llvm::createLoopDeletionPass
Pass * createLoopDeletionPass()
Definition: LoopDeletion.cpp:569
llvm::createSROAPass
FunctionPass * createSROAPass()
Definition: SROA.cpp:4809
MPM
ModulePassManager MPM
Definition: PassBuilderBindings.cpp:70
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
FunctionAttrs.h
llvm::EnableFunctionSpecialization
cl::opt< bool > EnableFunctionSpecialization
CFLSteensAliasAnalysis.h
llvm::createLoopUnrollAndJamPass
Pass * createLoopUnrollAndJamPass(int OptLevel=2)
Definition: LoopUnrollAndJamPass.cpp:522
llvm::createJumpThreadingPass
FunctionPass * createJumpThreadingPass(bool FreezeSelectCond=false, int Threshold=-1)
Definition: JumpThreading.cpp:176
llvm::createLoopVectorizePass
Pass * createLoopVectorizePass()
Definition: LoopVectorize.cpp:7355
GlobalExtensionsNotEmpty
static bool GlobalExtensionsNotEmpty()
Check if GlobalExtensions is constructed and not empty.
Definition: PassManagerBuilder.cpp:226
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:1438
llvm::createAnnotation2MetadataLegacyPass
ModulePass * createAnnotation2MetadataLegacyPass()
Definition: Annotation2Metadata.cpp:98
llvm::createOpenMPOptCGSCCLegacyPass
Pass * createOpenMPOptCGSCCLegacyPass()
createOpenMPOptLegacyPass - OpenMP specific optimizations.
Definition: OpenMPOpt.cpp:5232
llvm::EnableGVNHoist
cl::opt< bool > EnableGVNHoist