LLVM  8.0.0svn
PassManagerBuilder.cpp
Go to the documentation of this file.
1 //===- PassManagerBuilder.cpp - Build Standard Pass -----------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the PassManagerBuilder class, which is used to set up a
11 // "standard" optimization sequence suitable for languages like C and C++.
12 //
13 //===----------------------------------------------------------------------===//
14 
17 #include "llvm/ADT/SmallVector.h"
23 #include "llvm/Analysis/Passes.h"
27 #include "llvm/IR/DataLayout.h"
29 #include "llvm/IR/Verifier.h"
33 #include "llvm/Transforms/IPO.h"
39 #include "llvm/Transforms/Scalar.h"
43 #include "llvm/Transforms/Utils.h"
45 
46 using namespace llvm;
47 
48 static cl::opt<bool>
49  RunPartialInlining("enable-partial-inlining", cl::init(false), cl::Hidden,
50  cl::ZeroOrMore, cl::desc("Run Partial inlinining pass"));
51 
52 static cl::opt<bool>
53  RunLoopVectorization("vectorize-loops", cl::Hidden,
54  cl::desc("Run the Loop vectorization passes"));
55 
56 static cl::opt<bool>
57 RunSLPVectorization("vectorize-slp", cl::Hidden,
58  cl::desc("Run the SLP vectorization passes"));
59 
60 static cl::opt<bool>
61 UseGVNAfterVectorization("use-gvn-after-vectorization",
62  cl::init(false), cl::Hidden,
63  cl::desc("Run GVN instead of Early CSE after vectorization passes"));
64 
66  "extra-vectorizer-passes", cl::init(false), cl::Hidden,
67  cl::desc("Run cleanup optimization passes after vectorization."));
68 
69 static cl::opt<bool>
70 RunLoopRerolling("reroll-loops", cl::Hidden,
71  cl::desc("Run the loop rerolling pass"));
72 
73 static cl::opt<bool> RunNewGVN("enable-newgvn", cl::init(false), cl::Hidden,
74  cl::desc("Run the NewGVN pass"));
75 
76 static cl::opt<bool>
77 RunSLPAfterLoopVectorization("run-slp-after-loop-vectorization",
78  cl::init(true), cl::Hidden,
79  cl::desc("Run the SLP vectorizer (and BB vectorizer) after the Loop "
80  "vectorizer instead of before"));
81 
82 // Experimental option to use CFL-AA
84 static cl::opt<CFLAAType>
86  cl::desc("Enable the new, experimental CFL alias analysis"),
87  cl::values(clEnumValN(CFLAAType::None, "none", "Disable CFL-AA"),
89  "Enable unification-based CFL-AA"),
91  "Enable inclusion-based CFL-AA"),
93  "Enable both variants of CFL-AA")));
94 
96  "enable-loopinterchange", cl::init(false), cl::Hidden,
97  cl::desc("Enable the new, experimental LoopInterchange Pass"));
98 
99 static cl::opt<bool> EnableUnrollAndJam("enable-unroll-and-jam",
100  cl::init(false), cl::Hidden,
101  cl::desc("Enable Unroll And Jam Pass"));
102 
103 static cl::opt<bool>
104  EnablePrepareForThinLTO("prepare-for-thinlto", cl::init(false), cl::Hidden,
105  cl::desc("Enable preparation for ThinLTO."));
106 
107 cl::opt<bool> EnableHotColdSplit("hot-cold-split", cl::init(false), cl::Hidden,
108  cl::desc("Enable hot-cold splitting pass"));
109 
110 
112  "profile-generate", cl::init(false), cl::Hidden,
113  cl::desc("Enable PGO instrumentation."));
114 
116  PGOOutputFile("profile-generate-file", cl::init(""), cl::Hidden,
117  cl::desc("Specify the path of profile data file."));
118 
120  "profile-use", cl::init(""), cl::Hidden, cl::value_desc("filename"),
121  cl::desc("Enable use phase of PGO instrumentation and specify the path "
122  "of profile data file"));
123 
125  "enable-loop-versioning-licm", cl::init(false), cl::Hidden,
126  cl::desc("Enable the experimental Loop Versioning LICM pass"));
127 
128 static cl::opt<bool>
129  DisablePreInliner("disable-preinline", cl::init(false), cl::Hidden,
130  cl::desc("Disable pre-instrumentation inliner"));
131 
133  "preinline-threshold", cl::Hidden, cl::init(75), cl::ZeroOrMore,
134  cl::desc("Control the amount of inlining in pre-instrumentation inliner "
135  "(default = 75)"));
136 
138  "enable-earlycse-memssa", cl::init(true), cl::Hidden,
139  cl::desc("Enable the EarlyCSE w/ MemorySSA pass (default = on)"));
140 
142  "enable-gvn-hoist", cl::init(false), cl::Hidden,
143  cl::desc("Enable the GVN hoisting pass (default = off)"));
144 
145 static cl::opt<bool>
146  DisableLibCallsShrinkWrap("disable-libcalls-shrinkwrap", cl::init(false),
147  cl::Hidden,
148  cl::desc("Disable shrink-wrap library calls"));
149 
151  "enable-simple-loop-unswitch", cl::init(false), cl::Hidden,
152  cl::desc("Enable the simple loop unswitch pass. Also enables independent "
153  "cleanup passes integrated into the loop pass manager pipeline."));
154 
156  "enable-gvn-sink", cl::init(false), cl::Hidden,
157  cl::desc("Enable the GVN sinking pass (default = off)"));
158 
159 static cl::opt<bool>
160  EnableCHR("enable-chr", cl::init(true), cl::Hidden,
161  cl::desc("Enable control height reduction optimization (CHR)"));
162 
164  OptLevel = 2;
165  SizeLevel = 0;
166  LibraryInfo = nullptr;
167  Inliner = nullptr;
168  DisableUnrollLoops = false;
169  SLPVectorize = RunSLPVectorization;
170  LoopVectorize = RunLoopVectorization;
171  RerollLoops = RunLoopRerolling;
172  NewGVN = RunNewGVN;
173  DisableGVNLoadPRE = false;
174  VerifyInput = false;
175  VerifyOutput = false;
176  MergeFunctions = false;
177  PrepareForLTO = false;
178  EnablePGOInstrGen = RunPGOInstrGen;
179  PGOInstrGen = PGOOutputFile;
180  PGOInstrUse = RunPGOInstrUse;
181  PrepareForThinLTO = EnablePrepareForThinLTO;
182  PerformThinLTO = false;
183  DivergentTarget = false;
184 }
185 
187  delete LibraryInfo;
188  delete Inliner;
189 }
190 
191 /// Set of global extensions, automatically added as part of the standard set.
194 
195 /// Check if GlobalExtensions is constructed and not empty.
196 /// Since GlobalExtensions is a managed static, calling 'empty()' will trigger
197 /// the construction of the object.
199  return GlobalExtensions.isConstructed() && !GlobalExtensions->empty();
200 }
201 
203  PassManagerBuilder::ExtensionPointTy Ty,
205  GlobalExtensions->push_back(std::make_pair(Ty, std::move(Fn)));
206 }
207 
209  Extensions.push_back(std::make_pair(Ty, std::move(Fn)));
210 }
211 
212 void PassManagerBuilder::addExtensionsToPM(ExtensionPointTy ETy,
213  legacy::PassManagerBase &PM) const {
214  if (GlobalExtensionsNotEmpty()) {
215  for (auto &Ext : *GlobalExtensions) {
216  if (Ext.first == ETy)
217  Ext.second(*this, PM);
218  }
219  }
220  for (unsigned i = 0, e = Extensions.size(); i != e; ++i)
221  if (Extensions[i].first == ETy)
222  Extensions[i].second(*this, PM);
223 }
224 
225 void PassManagerBuilder::addInitialAliasAnalysisPasses(
226  legacy::PassManagerBase &PM) const {
227  switch (UseCFLAA) {
230  break;
231  case CFLAAType::Andersen:
233  break;
234  case CFLAAType::Both:
237  break;
238  default:
239  break;
240  }
241 
242  // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that
243  // BasicAliasAnalysis wins if they disagree. This is intended to help
244  // support "obvious" type-punning idioms.
247 }
248 
249 void PassManagerBuilder::addInstructionCombiningPass(
250  legacy::PassManagerBase &PM) const {
251  bool ExpensiveCombines = OptLevel > 2;
252  PM.add(createInstructionCombiningPass(ExpensiveCombines));
253 }
254 
257  addExtensionsToPM(EP_EarlyAsPossible, FPM);
259 
260  // Add LibraryInfo if we have some.
261  if (LibraryInfo)
262  FPM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
263 
264  if (OptLevel == 0) return;
265 
266  addInitialAliasAnalysisPasses(FPM);
267 
269  FPM.add(createSROAPass());
270  FPM.add(createEarlyCSEPass());
272 }
273 
274 // Do PGO instrumentation generation or use pass as the option specified.
275 void PassManagerBuilder::addPGOInstrPasses(legacy::PassManagerBase &MPM) {
276  if (!EnablePGOInstrGen && PGOInstrUse.empty() && PGOSampleUse.empty())
277  return;
278  // Perform the preinline and cleanup passes for O1 and above.
279  // And avoid doing them if optimizing for size.
280  if (OptLevel > 0 && SizeLevel == 0 && !DisablePreInliner &&
281  PGOSampleUse.empty()) {
282  // Create preinline pass. We construct an InlineParams object and specify
283  // the threshold here to avoid the command line options of the regular
284  // inliner to influence pre-inlining. The only fields of InlineParams we
285  // care about are DefaultThreshold and HintThreshold.
286  InlineParams IP;
288  // FIXME: The hint threshold has the same value used by the regular inliner.
289  // This should probably be lowered after performance testing.
290  IP.HintThreshold = 325;
291 
293  MPM.add(createSROAPass());
294  MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
295  MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
296  MPM.add(createInstructionCombiningPass()); // Combine silly seq's
297  addExtensionsToPM(EP_Peephole, MPM);
298  }
299  if (EnablePGOInstrGen) {
301  // Add the profile lowering pass.
302  InstrProfOptions Options;
303  if (!PGOInstrGen.empty())
304  Options.InstrProfileOutput = PGOInstrGen;
305  Options.DoCounterPromotion = true;
306  MPM.add(createLoopRotatePass());
307  MPM.add(createInstrProfilingLegacyPass(Options));
308  }
309  if (!PGOInstrUse.empty())
310  MPM.add(createPGOInstrumentationUseLegacyPass(PGOInstrUse));
311  // Indirect call promotion that promotes intra-module targets only.
312  // For ThinLTO this is done earlier due to interactions with globalopt
313  // for imported functions. We don't run this at -O0.
314  if (OptLevel > 0)
315  MPM.add(
316  createPGOIndirectCallPromotionLegacyPass(false, !PGOSampleUse.empty()));
317 }
318 void PassManagerBuilder::addFunctionSimplificationPasses(
320  // Start of function pass.
321  // Break up aggregate allocas, using SSAUpdater.
322  MPM.add(createSROAPass());
323  MPM.add(createEarlyCSEPass(EnableEarlyCSEMemSSA)); // Catch trivial redundancies
324  if (EnableGVNHoist)
325  MPM.add(createGVNHoistPass());
326  if (EnableGVNSink) {
327  MPM.add(createGVNSinkPass());
329  }
330 
331  // Speculative execution if the target has divergent branches; otherwise nop.
333  MPM.add(createJumpThreadingPass()); // Thread jumps.
334  MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals
335  MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
336  // Combine silly seq's
337  if (OptLevel > 2)
339  addInstructionCombiningPass(MPM);
340  if (SizeLevel == 0 && !DisableLibCallsShrinkWrap)
342  addExtensionsToPM(EP_Peephole, MPM);
343 
344  // Optimize memory intrinsic calls based on the profiled size information.
345  if (SizeLevel == 0)
347 
348  MPM.add(createTailCallEliminationPass()); // Eliminate tail calls
349  MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
350  MPM.add(createReassociatePass()); // Reassociate expressions
351 
352  // Begin the loop pass pipeline.
353  if (EnableSimpleLoopUnswitch) {
354  // The simple loop unswitch pass relies on separate cleanup passes. Schedule
355  // them first so when we re-process a loop they run before other loop
356  // passes.
359  }
360  // Rotate Loop - disable header duplication at -Oz
361  MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));
362  MPM.add(createLICMPass()); // Hoist loop invariants
363  if (EnableSimpleLoopUnswitch)
365  else
366  MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3, DivergentTarget));
367  // FIXME: We break the loop pass pipeline here in order to do full
368  // simplify-cfg. Eventually loop-simplifycfg should be enhanced to replace the
369  // need for this.
371  addInstructionCombiningPass(MPM);
372  // We resume loop passes creating a second loop pipeline here.
373  MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
374  MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
375  addExtensionsToPM(EP_LateLoopOptimizations, MPM);
376  MPM.add(createLoopDeletionPass()); // Delete dead loops
377 
378  if (EnableLoopInterchange)
379  MPM.add(createLoopInterchangePass()); // Interchange loops
380 
381  if (!DisableUnrollLoops)
382  MPM.add(createSimpleLoopUnrollPass(OptLevel)); // Unroll small loops
383  addExtensionsToPM(EP_LoopOptimizerEnd, MPM);
384  // This ends the loop pass pipelines.
385 
386  if (OptLevel > 1) {
387  MPM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds
388  MPM.add(NewGVN ? createNewGVNPass()
389  : createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
390  }
391  MPM.add(createMemCpyOptPass()); // Remove memcpy / form memset
392  MPM.add(createSCCPPass()); // Constant prop with SCCP
393 
394  // Delete dead bit computations (instcombine runs after to fold away the dead
395  // computations, and then ADCE will run later to exploit any new DCE
396  // opportunities that creates).
397  MPM.add(createBitTrackingDCEPass()); // Delete dead bit computations
398 
399  // Run instcombine after redundancy elimination to exploit opportunities
400  // opened up by them.
401  addInstructionCombiningPass(MPM);
402  addExtensionsToPM(EP_Peephole, MPM);
403  MPM.add(createJumpThreadingPass()); // Thread jumps
405  MPM.add(createDeadStoreEliminationPass()); // Delete dead stores
406  MPM.add(createLICMPass());
407 
408  addExtensionsToPM(EP_ScalarOptimizerLate, MPM);
409 
410  if (RerollLoops)
411  MPM.add(createLoopRerollPass());
412  if (!RunSLPAfterLoopVectorization && SLPVectorize)
413  MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
414 
415  MPM.add(createAggressiveDCEPass()); // Delete dead instructions
416  MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
417  // Clean up after everything.
418  addInstructionCombiningPass(MPM);
419  addExtensionsToPM(EP_Peephole, MPM);
420 
421  if (EnableCHR && OptLevel >= 3 &&
422  (!PGOInstrUse.empty() || !PGOSampleUse.empty()))
424 }
425 
428  if (!PGOSampleUse.empty()) {
429  MPM.add(createPruneEHPass());
430  MPM.add(createSampleProfileLoaderPass(PGOSampleUse));
431  }
432 
433  // Allow forcing function attributes as a debugging and tuning aid.
435 
436  // If all optimizations are disabled, just run the always-inline pass and,
437  // if enabled, the function merging pass.
438  if (OptLevel == 0) {
439  addPGOInstrPasses(MPM);
440  if (Inliner) {
441  MPM.add(Inliner);
442  Inliner = nullptr;
443  }
444 
445  // FIXME: The BarrierNoopPass is a HACK! The inliner pass above implicitly
446  // creates a CGSCC pass manager, but we don't want to add extensions into
447  // that pass manager. To prevent this we insert a no-op module pass to reset
448  // the pass manager to get the same behavior as EP_OptimizerLast in non-O0
449  // builds. The function merging pass is
450  if (MergeFunctions)
452  else if (GlobalExtensionsNotEmpty() || !Extensions.empty())
453  MPM.add(createBarrierNoopPass());
454 
455  if (PerformThinLTO) {
456  // Drop available_externally and unreferenced globals. This is necessary
457  // with ThinLTO in order to avoid leaving undefined references to dead
458  // globals in the object file.
460  MPM.add(createGlobalDCEPass());
461  }
462 
463  addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
464 
465  // Rename anon globals to be able to export them in the summary.
466  // This has to be done after we add the extensions to the pass manager
467  // as there could be passes (e.g. Adddress sanitizer) which introduce
468  // new unnamed globals.
469  if (PrepareForLTO || PrepareForThinLTO)
471  return;
472  }
473 
474  // Add LibraryInfo if we have some.
475  if (LibraryInfo)
476  MPM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
477 
478  addInitialAliasAnalysisPasses(MPM);
479 
480  // For ThinLTO there are two passes of indirect call promotion. The
481  // first is during the compile phase when PerformThinLTO=false and
482  // intra-module indirect call targets are promoted. The second is during
483  // the ThinLTO backend when PerformThinLTO=true, when we promote imported
484  // inter-module indirect calls. For that we perform indirect call promotion
485  // earlier in the pass pipeline, here before globalopt. Otherwise imported
486  // available_externally functions look unreferenced and are removed.
487  if (PerformThinLTO)
488  MPM.add(createPGOIndirectCallPromotionLegacyPass(/*InLTO = */ true,
489  !PGOSampleUse.empty()));
490 
491  // For SamplePGO in ThinLTO compile phase, we do not want to unroll loops
492  // as it will change the CFG too much to make the 2nd profile annotation
493  // in backend more difficult.
494  bool PrepareForThinLTOUsingPGOSampleProfile =
495  PrepareForThinLTO && !PGOSampleUse.empty();
496  if (PrepareForThinLTOUsingPGOSampleProfile)
497  DisableUnrollLoops = true;
498 
499  // Infer attributes about declarations if possible.
501 
502  addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
503 
504  if (OptLevel > 2)
506 
507  MPM.add(createIPSCCPPass()); // IP SCCP
509  MPM.add(createGlobalOptimizerPass()); // Optimize out global vars
510  // Promote any localized global vars.
512 
513  MPM.add(createDeadArgEliminationPass()); // Dead argument elimination
514 
515  addInstructionCombiningPass(MPM); // Clean up after IPCP & DAE
516  addExtensionsToPM(EP_Peephole, MPM);
517  MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
518 
519  // For SamplePGO in ThinLTO compile phase, we do not want to do indirect
520  // call promotion as it will change the CFG too much to make the 2nd
521  // profile annotation in backend more difficult.
522  // PGO instrumentation is added during the compile phase for ThinLTO, do
523  // not run it a second time
524  if (!PerformThinLTO && !PrepareForThinLTOUsingPGOSampleProfile)
525  addPGOInstrPasses(MPM);
526 
527  // We add a module alias analysis pass here. In part due to bugs in the
528  // analysis infrastructure this "works" in that the analysis stays alive
529  // for the entire SCC pass run below.
531 
532  // Start of CallGraph SCC passes.
533  MPM.add(createPruneEHPass()); // Remove dead EH info
534  bool RunInliner = false;
535  if (Inliner) {
536  MPM.add(Inliner);
537  Inliner = nullptr;
538  RunInliner = true;
539  }
540 
542  if (OptLevel > 2)
543  MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args
544 
545  addExtensionsToPM(EP_CGSCCOptimizerLate, MPM);
546  addFunctionSimplificationPasses(MPM);
547 
548  // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
549  // pass manager that we are specifically trying to avoid. To prevent this
550  // we must insert a no-op module pass to reset the pass manager.
551  MPM.add(createBarrierNoopPass());
552 
553  if (RunPartialInlining)
555 
556  if (OptLevel > 1 && !PrepareForLTO && !PrepareForThinLTO)
557  // Remove avail extern fns and globals definitions if we aren't
558  // compiling an object file for later LTO. For LTO we want to preserve
559  // these so they are eligible for inlining at link-time. Note if they
560  // are unreferenced they will be removed by GlobalDCE later, so
561  // this only impacts referenced available externally globals.
562  // Eventually they will be suppressed during codegen, but eliminating
563  // here enables more opportunity for GlobalDCE as it may make
564  // globals referenced by available external functions dead
565  // and saves running remaining passes on the eliminated functions.
567 
569 
570  // The inliner performs some kind of dead code elimination as it goes,
571  // but there are cases that are not really caught by it. We might
572  // at some point consider teaching the inliner about them, but it
573  // is OK for now to run GlobalOpt + GlobalDCE in tandem as their
574  // benefits generally outweight the cost, making the whole pipeline
575  // faster.
576  if (RunInliner) {
578  MPM.add(createGlobalDCEPass());
579  }
580 
581  // If we are planning to perform ThinLTO later, let's not bloat the code with
582  // unrolling/vectorization/... now. We'll first run the inliner + CGSCC passes
583  // during ThinLTO and perform the rest of the optimizations afterward.
584  if (PrepareForThinLTO) {
585  // Ensure we perform any last passes, but do so before renaming anonymous
586  // globals in case the passes add any.
587  addExtensionsToPM(EP_OptimizerLast, MPM);
588  // Rename anon globals to be able to export them in the summary.
590  return;
591  }
592 
593  if (PerformThinLTO)
594  // Optimize globals now when performing ThinLTO, this enables more
595  // optimizations later.
597 
598  // Scheduling LoopVersioningLICM when inlining is over, because after that
599  // we may see more accurate aliasing. Reason to run this late is that too
600  // early versioning may prevent further inlining due to increase of code
601  // size. By placing it just after inlining other optimizations which runs
602  // later might get benefit of no-alias assumption in clone loop.
603  if (UseLoopVersioningLICM) {
604  MPM.add(createLoopVersioningLICMPass()); // Do LoopVersioningLICM
605  MPM.add(createLICMPass()); // Hoist loop invariants
606  }
607 
608  // We add a fresh GlobalsModRef run at this point. This is particularly
609  // useful as the above will have inlined, DCE'ed, and function-attr
610  // propagated everything. We should at this point have a reasonably minimal
611  // and richly annotated call graph. By computing aliasing and mod/ref
612  // information for all local globals here, the late loop passes and notably
613  // the vectorizer will be able to use them to help recognize vectorizable
614  // memory operations.
615  //
616  // Note that this relies on a bug in the pass manager which preserves
617  // a module analysis into a function pass pipeline (and throughout it) so
618  // long as the first function pass doesn't invalidate the module analysis.
619  // Thus both Float2Int and LoopRotate have to preserve AliasAnalysis for
620  // this to work. Fortunately, it is trivial to preserve AliasAnalysis
621  // (doing nothing preserves it as it is required to be conservatively
622  // correct in the face of IR changes).
624 
625  MPM.add(createFloat2IntPass());
626 
627  addExtensionsToPM(EP_VectorizerStart, MPM);
628 
629  // Re-rotate loops in all our loop nests. These may have fallout out of
630  // rotated form due to GVN or other transformations, and the vectorizer relies
631  // on the rotated form. Disable header duplication at -Oz.
632  MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));
633 
634  // Distribute loops to allow partial vectorization. I.e. isolate dependences
635  // into separate loop that would otherwise inhibit vectorization. This is
636  // currently only performed for loops marked with the metadata
637  // llvm.loop.distribute=true or when -enable-loop-distribute is specified.
639 
640  MPM.add(createLoopVectorizePass(DisableUnrollLoops, LoopVectorize));
641 
642  // Eliminate loads by forwarding stores from the previous iteration to loads
643  // of the current iteration.
645 
646  // FIXME: Because of #pragma vectorize enable, the passes below are always
647  // inserted in the pipeline, even when the vectorizer doesn't run (ex. when
648  // on -O1 and no #pragma is found). Would be good to have these two passes
649  // as function calls, so that we can only pass them when the vectorizer
650  // changed the code.
651  addInstructionCombiningPass(MPM);
652  if (OptLevel > 1 && ExtraVectorizerPasses) {
653  // At higher optimization levels, try to clean up any runtime overlap and
654  // alignment checks inserted by the vectorizer. We want to track correllated
655  // runtime checks for two inner loops in the same outer loop, fold any
656  // common computations, hoist loop-invariant aspects out of any outer loop,
657  // and unswitch the runtime checks if possible. Once hoisted, we may have
658  // dead (or speculatable) control flows or more combining opportunities.
659  MPM.add(createEarlyCSEPass());
661  addInstructionCombiningPass(MPM);
662  MPM.add(createLICMPass());
663  MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3, DivergentTarget));
665  addInstructionCombiningPass(MPM);
666  }
667 
668  // Cleanup after loop vectorization, etc. Simplification passes like CVP and
669  // GVN, loop transforms, and others have already run, so it's now better to
670  // convert to more optimized IR using more aggressive simplify CFG options.
671  // The extra sinking transform can create larger basic blocks, so do this
672  // before SLP vectorization.
673  MPM.add(createCFGSimplificationPass(1, true, true, false, true));
674 
675  if (RunSLPAfterLoopVectorization && SLPVectorize) {
676  MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
677  if (OptLevel > 1 && ExtraVectorizerPasses) {
678  MPM.add(createEarlyCSEPass());
679  }
680  }
681 
682  addExtensionsToPM(EP_Peephole, MPM);
683  addInstructionCombiningPass(MPM);
684 
685  if (!DisableUnrollLoops) {
686  if (EnableUnrollAndJam) {
687  // Unroll and Jam. We do this before unroll but need to be in a separate
688  // loop pass manager in order for the outer loop to be processed by
689  // unroll and jam before the inner loop is unrolled.
690  MPM.add(createLoopUnrollAndJamPass(OptLevel));
691  }
692 
693  MPM.add(createLoopUnrollPass(OptLevel)); // Unroll small loops
694 
695  // LoopUnroll may generate some redundency to cleanup.
696  addInstructionCombiningPass(MPM);
697 
698  // Runtime unrolling will introduce runtime check in loop prologue. If the
699  // unrolled loop is a inner loop, then the prologue will be inside the
700  // outer loop. LICM pass can help to promote the runtime check out if the
701  // checked value is loop invariant.
702  MPM.add(createLICMPass());
703  }
704 
706 
707  // After vectorization and unrolling, assume intrinsics may tell us more
708  // about pointer alignments.
710 
711  // FIXME: We shouldn't bother with this anymore.
712  MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
713 
714  // GlobalOpt already deletes dead functions and globals, at -O2 try a
715  // late pass of GlobalDCE. It is capable of deleting dead cycles.
716  if (OptLevel > 1) {
717  MPM.add(createGlobalDCEPass()); // Remove dead fns and globals.
718  MPM.add(createConstantMergePass()); // Merge dup global constants
719  }
720 
721  if (MergeFunctions)
723 
724  // LoopSink pass sinks instructions hoisted by LICM, which serves as a
725  // canonicalization pass that enables other optimizations. As a result,
726  // LoopSink pass needs to be a very late IR pass to avoid undoing LICM
727  // result too early.
728  MPM.add(createLoopSinkPass());
729  // Get rid of LCSSA nodes.
731 
732  // This hoists/decomposes div/rem ops. It should run after other sink/hoist
733  // passes to avoid re-sinking, but before SimplifyCFG because it can allow
734  // flattening of blocks.
735  MPM.add(createDivRemPairsPass());
736 
737  if (EnableHotColdSplit)
739 
740  // LoopSink (and other loop passes since the last simplifyCFG) might have
741  // resulted in single-entry-single-exit or empty blocks. Clean up the CFG.
743 
744  addExtensionsToPM(EP_OptimizerLast, MPM);
745 
746  // Rename anon globals to be able to handle them in the summary
747  if (PrepareForLTO)
749 }
750 
751 void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) {
752  // Load sample profile before running the LTO optimization pipeline.
753  if (!PGOSampleUse.empty()) {
754  PM.add(createPruneEHPass());
755  PM.add(createSampleProfileLoaderPass(PGOSampleUse));
756  }
757 
758  // Remove unused virtual tables to improve the quality of code generated by
759  // whole-program devirtualization and bitset lowering.
760  PM.add(createGlobalDCEPass());
761 
762  // Provide AliasAnalysis services for optimizations.
763  addInitialAliasAnalysisPasses(PM);
764 
765  // Allow forcing function attributes as a debugging and tuning aid.
767 
768  // Infer attributes about declarations if possible.
770 
771  if (OptLevel > 1) {
772  // Split call-site with more constrained arguments.
774 
775  // Indirect call promotion. This should promote all the targets that are
776  // left by the earlier promotion pass that promotes intra-module targets.
777  // This two-step promotion is to save the compile time. For LTO, it should
778  // produce the same result as if we only do promotion here.
779  PM.add(
780  createPGOIndirectCallPromotionLegacyPass(true, !PGOSampleUse.empty()));
781 
782  // Propagate constants at call sites into the functions they call. This
783  // opens opportunities for globalopt (and inlining) by substituting function
784  // pointers passed as arguments to direct uses of functions.
785  PM.add(createIPSCCPPass());
786 
787  // Attach metadata to indirect call sites indicating the set of functions
788  // they may target at run-time. This should follow IPSCCP.
790  }
791 
792  // Infer attributes about definitions. The readnone attribute in particular is
793  // required for virtual constant propagation.
796 
797  // Split globals using inrange annotations on GEP indices. This can help
798  // improve the quality of generated code when virtual constant propagation or
799  // control flow integrity are enabled.
801 
802  // Apply whole-program devirtualization and virtual constant propagation.
803  PM.add(createWholeProgramDevirtPass(ExportSummary, nullptr));
804 
805  // That's all we need at opt level 1.
806  if (OptLevel == 1)
807  return;
808 
809  // Now that we internalized some globals, see if we can hack on them!
811  // Promote any localized global vars.
813 
814  // Linking modules together can lead to duplicated global constants, only
815  // keep one copy of each constant.
817 
818  // Remove unused arguments from functions.
820 
821  // Reduce the code after globalopt and ipsccp. Both can open up significant
822  // simplification opportunities, and both can propagate functions through
823  // function pointers. When this happens, we often have to resolve varargs
824  // calls, etc, so let instcombine do this.
825  if (OptLevel > 2)
827  addInstructionCombiningPass(PM);
828  addExtensionsToPM(EP_Peephole, PM);
829 
830  // Inline small functions
831  bool RunInliner = Inliner;
832  if (RunInliner) {
833  PM.add(Inliner);
834  Inliner = nullptr;
835  }
836 
837  PM.add(createPruneEHPass()); // Remove dead EH info.
838 
839  // Optimize globals again if we ran the inliner.
840  if (RunInliner)
842  PM.add(createGlobalDCEPass()); // Remove dead functions.
843 
844  // If we didn't decide to inline a function, check to see if we can
845  // transform it to pass arguments by value instead of by reference.
847 
848  // The IPO passes may leave cruft around. Clean up after them.
849  addInstructionCombiningPass(PM);
850  addExtensionsToPM(EP_Peephole, PM);
852 
853  // Break up allocas
854  PM.add(createSROAPass());
855 
856  // Run a few AA driven optimizations here and now, to cleanup the code.
857  PM.add(createPostOrderFunctionAttrsLegacyPass()); // Add nocapture.
858  PM.add(createGlobalsAAWrapperPass()); // IP alias analysis.
859 
860  PM.add(createLICMPass()); // Hoist loop invariants.
861  PM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds.
862  PM.add(NewGVN ? createNewGVNPass()
863  : createGVNPass(DisableGVNLoadPRE)); // Remove redundancies.
864  PM.add(createMemCpyOptPass()); // Remove dead memcpys.
865 
866  // Nuke dead stores.
868 
869  // More loops are countable; try to optimize them.
872  if (EnableLoopInterchange)
874 
875  if (!DisableUnrollLoops)
876  PM.add(createSimpleLoopUnrollPass(OptLevel)); // Unroll small loops
877  PM.add(createLoopVectorizePass(true, LoopVectorize));
878  // The vectorizer may have significantly shortened a loop body; unroll again.
879  if (!DisableUnrollLoops)
880  PM.add(createLoopUnrollPass(OptLevel));
881 
883 
884  // Now that we've optimized loops (in particular loop induction variables),
885  // we may have exposed more scalar opportunities. Run parts of the scalar
886  // optimizer again at this point.
887  addInstructionCombiningPass(PM); // Initial cleanup
888  PM.add(createCFGSimplificationPass()); // if-convert
889  PM.add(createSCCPPass()); // Propagate exposed constants
890  addInstructionCombiningPass(PM); // Clean up again
892 
893  // More scalar chains could be vectorized due to more alias information
895  if (SLPVectorize)
896  PM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
897 
898  // After vectorization, assume intrinsics may tell us more about pointer
899  // alignments.
901 
902  // Cleanup and simplify the code after the scalar optimizations.
903  addInstructionCombiningPass(PM);
904  addExtensionsToPM(EP_Peephole, PM);
905 
907 }
908 
909 void PassManagerBuilder::addLateLTOOptimizationPasses(
911  // Delete basic blocks, which optimization passes may have killed.
913 
914  // Drop bodies of available externally objects to improve GlobalDCE.
916 
917  // Now that we have optimized the program, discard unreachable functions.
918  PM.add(createGlobalDCEPass());
919 
920  // FIXME: this is profitable (for compiler time) to do at -O0 too, but
921  // currently it damages debug info.
922  if (MergeFunctions)
924 }
925 
928  PerformThinLTO = true;
929  if (LibraryInfo)
930  PM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
931 
932  if (VerifyInput)
933  PM.add(createVerifierPass());
934 
935  if (ImportSummary) {
936  // These passes import type identifier resolutions for whole-program
937  // devirtualization and CFI. They must run early because other passes may
938  // disturb the specific instruction patterns that these passes look for,
939  // creating dependencies on resolutions that may not appear in the summary.
940  //
941  // For example, GVN may transform the pattern assume(type.test) appearing in
942  // two basic blocks into assume(phi(type.test, type.test)), which would
943  // transform a dependency on a WPD resolution into a dependency on a type
944  // identifier resolution for CFI.
945  //
946  // Also, WPD has access to more precise information than ICP and can
947  // devirtualize more effectively, so it should operate on the IR first.
948  PM.add(createWholeProgramDevirtPass(nullptr, ImportSummary));
949  PM.add(createLowerTypeTestsPass(nullptr, ImportSummary));
950  }
951 
952  populateModulePassManager(PM);
953 
954  if (VerifyOutput)
955  PM.add(createVerifierPass());
956  PerformThinLTO = false;
957 }
958 
960  if (LibraryInfo)
961  PM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
962 
963  if (VerifyInput)
964  PM.add(createVerifierPass());
965 
966  if (OptLevel != 0)
967  addLTOOptimizationPasses(PM);
968  else {
969  // The whole-program-devirt pass needs to run at -O0 because only it knows
970  // about the llvm.type.checked.load intrinsic: it needs to both lower the
971  // intrinsic itself and handle it in the summary.
972  PM.add(createWholeProgramDevirtPass(ExportSummary, nullptr));
973  }
974 
975  // Create a function that performs CFI checks for cross-DSO calls with targets
976  // in the current module.
978 
979  // Lower type metadata and the type.test intrinsic. This pass supports Clang's
980  // control flow integrity mechanisms (-fsanitize=cfi*) and needs to run at
981  // link time if CFI is enabled. The pass does nothing if CFI is disabled.
982  PM.add(createLowerTypeTestsPass(ExportSummary, nullptr));
983 
984  if (OptLevel != 0)
985  addLateLTOOptimizationPasses(PM);
986 
987  if (VerifyOutput)
988  PM.add(createVerifierPass());
989 }
990 
992  return reinterpret_cast<PassManagerBuilder*>(P);
993 }
994 
996  return reinterpret_cast<LLVMPassManagerBuilderRef>(P);
997 }
998 
1001  return wrap(PMB);
1002 }
1003 
1005  PassManagerBuilder *Builder = unwrap(PMB);
1006  delete Builder;
1007 }
1008 
1009 void
1011  unsigned OptLevel) {
1012  PassManagerBuilder *Builder = unwrap(PMB);
1013  Builder->OptLevel = OptLevel;
1014 }
1015 
1016 void
1018  unsigned SizeLevel) {
1019  PassManagerBuilder *Builder = unwrap(PMB);
1020  Builder->SizeLevel = SizeLevel;
1021 }
1022 
1023 void
1025  LLVMBool Value) {
1026  // NOTE: The DisableUnitAtATime switch has been removed.
1027 }
1028 
1029 void
1031  LLVMBool Value) {
1032  PassManagerBuilder *Builder = unwrap(PMB);
1033  Builder->DisableUnrollLoops = Value;
1034 }
1035 
1036 void
1038  LLVMBool Value) {
1039  // NOTE: The simplify-libcalls pass has been removed.
1040 }
1041 
1042 void
1044  unsigned Threshold) {
1045  PassManagerBuilder *Builder = unwrap(PMB);
1046  Builder->Inliner = createFunctionInliningPass(Threshold);
1047 }
1048 
1049 void
1051  LLVMPassManagerRef PM) {
1052  PassManagerBuilder *Builder = unwrap(PMB);
1053  legacy::FunctionPassManager *FPM = unwrap<legacy::FunctionPassManager>(PM);
1054  Builder->populateFunctionPassManager(*FPM);
1055 }
1056 
1057 void
1059  LLVMPassManagerRef PM) {
1060  PassManagerBuilder *Builder = unwrap(PMB);
1061  legacy::PassManagerBase *MPM = unwrap(PM);
1062  Builder->populateModulePassManager(*MPM);
1063 }
1064 
1066  LLVMPassManagerRef PM,
1067  LLVMBool Internalize,
1068  LLVMBool RunInliner) {
1069  PassManagerBuilder *Builder = unwrap(PMB);
1070  legacy::PassManagerBase *LPM = unwrap(PM);
1071 
1072  // A small backwards compatibility hack. populateLTOPassManager used to take
1073  // an RunInliner option.
1074  if (RunInliner && !Builder->Inliner)
1075  Builder->Inliner = createFunctionInliningPass();
1076 
1077  Builder->populateLTOPassManager(*LPM);
1078 }
Super simple passes to force specific function attrs from the commandline into the IR for debugging p...
Defines passes for running instruction simplification across chunks of IR.
ModulePass * createNameAnonGlobalPass()
===------------------------------------------------------------------—===//
FunctionPass * createGVNPass(bool NoLoads=false)
Create a legacy GVN pass.
Definition: GVN.cpp:2589
Pass * createLoopRerollPass()
Thresholds to tune inline cost analysis.
Definition: InlineCost.h:154
void LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB, unsigned OptLevel)
See llvm::PassManagerBuilder::OptLevel.
ModulePass * createStripDeadPrototypesPass()
createStripDeadPrototypesPass - This pass removes any function declarations (prototypes) that are not...
ModulePass * createPGOInstrumentationGenLegacyPass()
static cl::opt< bool > UseLoopVersioningLICM("enable-loop-versioning-licm", cl::init(false), cl::Hidden, cl::desc("Enable the experimental Loop Versioning LICM pass"))
PassManagerBuilder - This class is used to set up a standard optimization sequence for languages like...
partial Partial Inliner
This is the interface for LLVM&#39;s inclusion-based alias analysis implemented with CFL graph reachabili...
This class represents lattice values for constants.
Definition: AllocatorList.h:24
This is the interface for a simple mod/ref and alias analysis over globals.
static cl::opt< bool > EnableEarlyCSEMemSSA("enable-earlycse-memssa", cl::init(true), cl::Hidden, cl::desc("Enable the EarlyCSE w/ MemorySSA pass (default = on)"))
FunctionPass * createPGOMemOPSizeOptLegacyPass()
ModulePass * createMergeFunctionsPass()
createMergeFunctionsPass - This pass discovers identical functions and collapses them.
Pass * createLoopUnrollPass(int OptLevel=2, int Threshold=-1, int Count=-1, int AllowPartial=-1, int Runtime=-1, int UpperBound=-1, int AllowPeeling=-1)
void populateThinLTOPassManager(legacy::PassManagerBase &PM)
static cl::opt< bool > EnableGVNHoist("enable-gvn-hoist", cl::init(false), cl::Hidden, cl::desc("Enable the GVN hoisting pass (default = off)"))
void LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB, LLVMBool Value)
See llvm::PassManagerBuilder::DisableSimplifyLibCalls.
static const struct @394 Extensions[]
This is the interface for a metadata-based scoped no-alias analysis.
static cl::opt< std::string > RunPGOInstrUse("profile-use", cl::init(""), cl::Hidden, cl::value_desc("filename"), cl::desc("Enable use phase of PGO instrumentation and specify the path " "of profile data file"))
FunctionPass * createVerifierPass(bool FatalErrors=true)
Definition: Verifier.cpp:5214
ModulePass * createIPSCCPPass()
createIPSCCPPass - This pass propagates constants from call sites into the bodies of functions...
Definition: SCCP.cpp:89
FunctionPass * createFloat2IntPass()
Definition: Float2Int.cpp:515
virtual void add(Pass *P)=0
Add a pass to the queue of passes to run.
void LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB, LLVMBool Value)
See llvm::PassManagerBuilder::DisableUnrollLoops.
static cl::opt< std::string > PGOOutputFile("profile-generate-file", cl::init(""), cl::Hidden, cl::desc("Specify the path of profile data file."))
ModulePass * createEliminateAvailableExternallyPass()
This transform is designed to eliminate available external globals (functions or global variables) ...
FunctionPass * createGVNHoistPass()
Definition: GVNHoist.cpp:1207
static cl::opt< bool > RunPGOInstrGen("profile-generate", cl::init(false), cl::Hidden, cl::desc("Enable PGO instrumentation."))
ModulePass * createInstrProfilingLegacyPass(const InstrProfOptions &Options=InstrProfOptions())
Insert frontend instrumentation based profiling.
ImmutablePass * createScopedNoAliasAAWrapperPass()
FunctionPass * createAlignmentFromAssumptionsPass()
void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM, LLVMBool Internalize, LLVMBool RunInliner)
See llvm::PassManagerBuilder::populateLTOPassManager.
Pass * Inliner
Inliner - Specifies the inliner to use.
FunctionPass * createJumpThreadingPass(int Threshold=-1)
FunctionPass * createCFGSimplificationPass(unsigned Threshold=1, bool ForwardSwitchCond=false, bool ConvertSwitch=false, bool KeepLoops=true, bool SinkCommon=false, std::function< bool(const Function &)> Ftor=nullptr)
static cl::opt< bool > RunLoopVectorization("vectorize-loops", cl::Hidden, cl::desc("Run the Loop vectorization passes"))
ModulePass * createPartialInliningPass()
createPartialInliningPass - This pass inlines parts of functions.
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:195
static void addGlobalExtension(ExtensionPointTy Ty, ExtensionFn Fn)
Adds an extension that will be used by all PassManagerBuilder instances.
Optional< int > HintThreshold
Threshold to use for callees with inline hint.
Definition: InlineCost.h:159
void populateLTOPassManager(legacy::PassManagerBase &PM)
ModulePass * createCrossDSOCFIPass()
This pass export CFI checks for use by external modules.
static cl::opt< bool > ExtraVectorizerPasses("extra-vectorizer-passes", cl::init(false), cl::Hidden, cl::desc("Run cleanup optimization passes after vectorization."))
FunctionPass * createReassociatePass()
Pass * createSimpleLoopUnrollPass(int OptLevel=2)
Pass * createArgumentPromotionPass(unsigned maxElements=3)
createArgumentPromotionPass - This pass promotes "by reference" arguments to be passed by value if th...
FunctionPass * createAggressiveInstCombinerPass()
static cl::opt< bool > EnablePrepareForThinLTO("prepare-for-thinlto", cl::init(false), cl::Hidden, cl::desc("Enable preparation for ThinLTO."))
FunctionPass * createSCCPPass()
Definition: SCCP.cpp:1870
std::function< void(const PassManagerBuilder &Builder, legacy::PassManagerBase &PM)> ExtensionFn
Extensions are passed the builder itself (so they can see how it is configured) as well as the pass m...
unsigned OptLevel
The Optimization Level - Specify the basic optimization level.
static cl::opt< bool > UseGVNAfterVectorization("use-gvn-after-vectorization", cl::init(false), cl::Hidden, cl::desc("Run GVN instead of Early CSE after vectorization passes"))
Pass * createLoopVectorizePass(bool NoUnrolling=false, bool AlwaysVectorize=true)
void populateModulePassManager(legacy::PassManagerBase &MPM)
populateModulePassManager - This sets up the primary pass manager.
static cl::opt< bool > DisablePreInliner("disable-preinline", cl::init(false), cl::Hidden, cl::desc("Disable pre-instrumentation inliner"))
ModulePass * createCalledValuePropagationPass()
createCalledValuePropagationPass - Attach metadata to indirct call sites indicating the set of functi...
void add(Pass *P) override
Add a pass to the queue of passes to run.
FunctionPass * createInstSimplifyLegacyPass()
Create a legacy pass that does instruction simplification on each instruction in a function...
Pass * createLoopInstSimplifyPass()
static ManagedStatic< SmallVector< std::pair< PassManagerBuilder::ExtensionPointTy, PassManagerBuilder::ExtensionFn >, 8 > > GlobalExtensions
Set of global extensions, automatically added as part of the standard set.
static cl::opt< bool > RunSLPVectorization("vectorize-slp", cl::Hidden, cl::desc("Run the SLP vectorization passes"))
void LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB, unsigned SizeLevel)
See llvm::PassManagerBuilder::SizeLevel.
ModulePass * createSampleProfileLoaderPass()
FunctionPass * createInstructionCombiningPass(bool ExpensiveCombines=true)
ModulePass * createGlobalDCEPass()
createGlobalDCEPass - This transform is designed to eliminate unreachable internal globals (functions...
static cl::opt< bool > EnableUnrollAndJam("enable-unroll-and-jam", cl::init(false), cl::Hidden, cl::desc("Enable Unroll And Jam Pass"))
Pass * createLoopUnrollAndJamPass(int OptLevel=2)
Pass * createCorrelatedValuePropagationPass()
struct LLVMOpaquePassManagerBuilder * LLVMPassManagerBuilderRef
#define P(N)
This is the interface for LLVM&#39;s unification-based alias analysis implemented with CFL graph reachabi...
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:419
This is the interface for a metadata-based TBAA.
FunctionPass * createTailCallEliminationPass()
This file provides the interface for LLVM&#39;s Global Value Numbering pass which eliminates fully redund...
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:639
FunctionPass * createPromoteMemoryToRegisterPass()
Definition: Mem2Reg.cpp:114
This file provides the primary interface to the instcombine pass.
ModulePass * createDeadArgEliminationPass()
createDeadArgEliminationPass - This pass removes arguments from functions which are not used by the b...
void LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB)
Pass * createLICMPass()
Definition: LICM.cpp:262
FunctionPass * createDivRemPairsPass()
FunctionPass * createDeadStoreEliminationPass()
ModulePass * createLowerTypeTestsPass(ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary)
This pass lowers type metadata and the llvm.type.test intrinsic to bitsets.
ModulePass * createPGOInstrumentationUseLegacyPass(StringRef Filename=StringRef(""))
ModulePass * createBarrierNoopPass()
createBarrierNoopPass - This pass is purely a module pass barrier in a pass manager.
FunctionPass * createMemCpyOptPass()
The public interface to this file...
FunctionPass * createBitTrackingDCEPass()
Definition: BDCE.cpp:173
ModulePass * createConstantMergePass()
createConstantMergePass - This function returns a new pass that merges duplicate global constants tog...
Pass * createLoopSinkPass()
ModulePass * createGlobalOptimizerPass()
createGlobalOptimizerPass - This function returns a new pass that optimizes non-address taken interna...
Definition: GlobalOpt.cpp:3028
Pass * createReversePostOrderFunctionAttrsPass()
createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call graph in RPO to deduce and...
void populateFunctionPassManager(legacy::FunctionPassManager &FPM)
populateFunctionPassManager - This fills in the function pass manager, which is expected to be run on...
Pass * createWarnMissedTransformationsPass()
FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
int LLVMBool
Definition: Types.h:29
Pass * createPostOrderFunctionAttrsLegacyPass()
Create a legacy pass manager instance of a pass to compute function attrs in post-order.
std::string InstrProfileOutput
Pass * createLoopVersioningLICMPass()
ModulePass * createGlobalSplitPass()
This pass splits globals into pieces for the benefit of whole-program devirtualization and control-fl...
static cl::opt< bool > EnableLoopInterchange("enable-loopinterchange", cl::init(false), cl::Hidden, cl::desc("Enable the new, experimental LoopInterchange Pass"))
unsigned first
This file provides the primary interface to the aggressive instcombine pass.
cl::opt< bool > EnableHotColdSplit("hot-cold-split", cl::init(false), cl::Hidden, cl::desc("Enable hot-cold splitting pass"))
Pass * createLoopInterchangePass()
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:847
FunctionPass * createLoopLoadEliminationPass()
static cl::opt< bool > RunSLPAfterLoopVectorization("run-slp-after-loop-vectorization", cl::init(true), cl::Hidden, cl::desc("Run the SLP vectorizer (and BB vectorizer) after the Loop " "vectorizer instead of before"))
Pass * createSimpleLoopUnswitchLegacyPass(bool NonTrivial=false)
Create the legacy pass object for the simple loop unswitcher.
static cl::opt< CFLAAType > UseCFLAA("use-cfl-aa", cl::init(CFLAAType::None), cl::Hidden, cl::desc("Enable the new, experimental CFL alias analysis"), cl::values(clEnumValN(CFLAAType::None, "none", "Disable CFL-AA"), clEnumValN(CFLAAType::Steensgaard, "steens", "Enable unification-based CFL-AA"), clEnumValN(CFLAAType::Andersen, "anders", "Enable inclusion-based CFL-AA"), clEnumValN(CFLAAType::Both, "both", "Enable both variants of CFL-AA")))
Pass * createLoopSimplifyCFGPass()
FunctionPass * createSpeculativeExecutionIfHasBranchDivergencePass()
FunctionPass * createMergedLoadStoreMotionPass()
createMergedLoadStoreMotionPass - The public interface to this file.
FunctionPass * createLibCallsShrinkWrapPass()
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition: Types.h:128
Pass * createLoopDeletionPass()
Pass * createLoopUnswitchPass(bool OptimizeForSize=false, bool hasBranchDivergence=false)
Options for the frontend instrumentation based profiling pass.
static cl::opt< unsigned > Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"), cl::init(100), cl::Hidden)
static cl::opt< bool > EnableGVNSink("enable-gvn-sink", cl::init(false), cl::Hidden, cl::desc("Enable the GVN sinking pass (default = off)"))
Pass * createLoopIdiomPass()
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:614
ModulePass * createWholeProgramDevirtPass(ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary)
This pass implements whole-program devirtualization using type metadata.
Interfaces for passes which infer implicit function attributes from the name and signature of functio...
LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate()
See llvm::PassManagerBuilder.
void LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM)
See llvm::PassManagerBuilder::populateModulePassManager.
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:190
ModulePass * createHotColdSplittingPass()
createHotColdSplittingPass - This pass outlines cold blocks into a separate function(s).
unsigned SizeLevel
SizeLevel - How much we&#39;re optimizing for size.
static cl::opt< bool > DisableLibCallsShrinkWrap("disable-libcalls-shrinkwrap", cl::init(false), cl::Hidden, cl::desc("Disable shrink-wrap library calls"))
FunctionPass * createGVNSinkPass()
Definition: GVNSink.cpp:923
ModulePass * createGlobalsAAWrapperPass()
FunctionPass * createSROAPass()
Definition: SROA.cpp:4555
Pass * createInferFunctionAttrsLegacyPass()
Create a legacy pass manager instance of a pass to infer function attributes.
static bool GlobalExtensionsNotEmpty()
Check if GlobalExtensions is constructed and not empty.
Provides passes for computing function attributes based on interprocedural analyses.
ImmutablePass * createCFLSteensAAWrapperPass()
ImmutablePass * createTypeBasedAAWrapperPass()
Pass * createSLPVectorizerPass()
void LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB, LLVMBool Value)
See llvm::PassManagerBuilder::DisableUnitAtATime.
static cl::opt< bool > EnableCHR("enable-chr", cl::init(true), cl::Hidden, cl::desc("Enable control height reduction optimization (CHR)"))
Pass * createFunctionInliningPass()
createFunctionInliningPass - Return a new pass object that uses a heuristic to inline direct function...
Pass * createPruneEHPass()
createPruneEHPass - Return a new pass object which transforms invoke instructions into calls...
Definition: PruneEH.cpp:61
LLVM Value Representation.
Definition: Value.h:73
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
Definition: EarlyCSE.cpp:1319
static cl::opt< int > PreInlineThreshold("preinline-threshold", cl::Hidden, cl::init(75), cl::ZeroOrMore, cl::desc("Control the amount of inlining in pre-instrumentation inliner " "(default = 75)"))
FunctionPass * createNewGVNPass()
Definition: NewGVN.cpp:4246
This is the interface for LLVM&#39;s primary stateless and local alias analysis.
static cl::opt< bool > RunPartialInlining("enable-partial-inlining", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Run Partial inlinining pass"))
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
Definition: ManagedStatic.h:61
FunctionPass * createControlHeightReductionLegacyPass()
static cl::opt< bool > EnableSimpleLoopUnswitch("enable-simple-loop-unswitch", cl::init(false), cl::Hidden, cl::desc("Enable the simple loop unswitch pass. Also enables independent " "cleanup passes integrated into the loop pass manager pipeline."))
void LLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM)
See llvm::PassManagerBuilder::populateFunctionPassManager.
ImmutablePass * createCFLAndersAAWrapperPass()
void addExtension(ExtensionPointTy Ty, ExtensionFn Fn)
FunctionPass * createEntryExitInstrumenterPass()
ModulePass * createPGOIndirectCallPromotionLegacyPass(bool InLTO=false, bool SamplePGO=false)
Pass * createForceFunctionAttrsLegacyPass()
Create a legacy pass manager instance of a pass to force function attrs.
Pass * createLoopRotatePass(int MaxHeaderSize=-1)
Pass * createIndVarSimplifyPass()
FunctionPass * createAggressiveDCEPass()
Definition: ADCE.cpp:734
int DefaultThreshold
The default threshold to start with for a callee.
Definition: InlineCost.h:156
FunctionPass * createLoopDistributePass()
FunctionPass * createLowerExpectIntrinsicPass()
static cl::opt< bool > RunLoopRerolling("reroll-loops", cl::Hidden, cl::desc("Run the loop rerolling pass"))
static cl::opt< bool > RunNewGVN("enable-newgvn", cl::init(false), cl::Hidden, cl::desc("Run the NewGVN pass"))
void LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB, unsigned Threshold)
See llvm::PassManagerBuilder::Inliner.
FunctionPass * createCallSiteSplittingPass()