LLVM  3.7.0
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 
15 
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/Analysis/Passes.h"
20 #include "llvm/IR/DataLayout.h"
21 #include "llvm/IR/Verifier.h"
27 #include "llvm/Transforms/IPO.h"
28 #include "llvm/Transforms/Scalar.h"
30 
31 using namespace llvm;
32 
33 static cl::opt<bool>
34 RunLoopVectorization("vectorize-loops", cl::Hidden,
35  cl::desc("Run the Loop vectorization passes"));
36 
37 static cl::opt<bool>
38 RunSLPVectorization("vectorize-slp", cl::Hidden,
39  cl::desc("Run the SLP vectorization passes"));
40 
41 static cl::opt<bool>
42 RunBBVectorization("vectorize-slp-aggressive", cl::Hidden,
43  cl::desc("Run the BB vectorization passes"));
44 
45 static cl::opt<bool>
46 UseGVNAfterVectorization("use-gvn-after-vectorization",
47  cl::init(false), cl::Hidden,
48  cl::desc("Run GVN instead of Early CSE after vectorization passes"));
49 
51  "extra-vectorizer-passes", cl::init(false), cl::Hidden,
52  cl::desc("Run cleanup optimization passes after vectorization."));
53 
54 static cl::opt<bool> UseNewSROA("use-new-sroa",
55  cl::init(true), cl::Hidden,
56  cl::desc("Enable the new, experimental SROA pass"));
57 
58 static cl::opt<bool>
59 RunLoopRerolling("reroll-loops", cl::Hidden,
60  cl::desc("Run the loop rerolling pass"));
61 
62 static cl::opt<bool>
63 RunFloat2Int("float-to-int", cl::Hidden, cl::init(true),
64  cl::desc("Run the float2int (float demotion) pass"));
65 
66 static cl::opt<bool> RunLoadCombine("combine-loads", cl::init(false),
67  cl::Hidden,
68  cl::desc("Run the load combining pass"));
69 
70 static cl::opt<bool>
71 RunSLPAfterLoopVectorization("run-slp-after-loop-vectorization",
72  cl::init(true), cl::Hidden,
73  cl::desc("Run the SLP vectorizer (and BB vectorizer) after the Loop "
74  "vectorizer instead of before"));
75 
76 static cl::opt<bool> UseCFLAA("use-cfl-aa",
77  cl::init(false), cl::Hidden,
78  cl::desc("Enable the new, experimental CFL alias analysis"));
79 
80 static cl::opt<bool>
81 EnableMLSM("mlsm", cl::init(true), cl::Hidden,
82  cl::desc("Enable motion of merged load and store"));
83 
85  "enable-loopinterchange", cl::init(false), cl::Hidden,
86  cl::desc("Enable the new, experimental LoopInterchange Pass"));
87 
89  "enable-loop-distribute", cl::init(false), cl::Hidden,
90  cl::desc("Enable the new, experimental LoopDistribution Pass"));
91 
93  OptLevel = 2;
94  SizeLevel = 0;
95  LibraryInfo = nullptr;
96  Inliner = nullptr;
97  DisableUnitAtATime = false;
98  DisableUnrollLoops = false;
104  DisableGVNLoadPRE = false;
105  VerifyInput = false;
106  VerifyOutput = false;
107  MergeFunctions = false;
108  PrepareForLTO = false;
109 }
110 
112  delete LibraryInfo;
113  delete Inliner;
114 }
115 
116 /// Set of global extensions, automatically added as part of the standard set.
119 
123  GlobalExtensions->push_back(std::make_pair(Ty, Fn));
124 }
125 
127  Extensions.push_back(std::make_pair(Ty, Fn));
128 }
129 
130 void PassManagerBuilder::addExtensionsToPM(ExtensionPointTy ETy,
131  legacy::PassManagerBase &PM) const {
132  for (unsigned i = 0, e = GlobalExtensions->size(); i != e; ++i)
133  if ((*GlobalExtensions)[i].first == ETy)
134  (*GlobalExtensions)[i].second(*this, PM);
135  for (unsigned i = 0, e = Extensions.size(); i != e; ++i)
136  if (Extensions[i].first == ETy)
137  Extensions[i].second(*this, PM);
138 }
139 
140 void PassManagerBuilder::addInitialAliasAnalysisPasses(
141  legacy::PassManagerBase &PM) const {
142  // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that
143  // BasicAliasAnalysis wins if they disagree. This is intended to help
144  // support "obvious" type-punning idioms.
145  if (UseCFLAA)
150 }
151 
154  addExtensionsToPM(EP_EarlyAsPossible, FPM);
155 
156  // Add LibraryInfo if we have some.
157  if (LibraryInfo)
159 
160  if (OptLevel == 0) return;
161 
162  addInitialAliasAnalysisPasses(FPM);
163 
165  if (UseNewSROA)
166  FPM.add(createSROAPass());
167  else
169  FPM.add(createEarlyCSEPass());
171 }
172 
175  // If all optimizations are disabled, just run the always-inline pass and,
176  // if enabled, the function merging pass.
177  if (OptLevel == 0) {
178  if (Inliner) {
179  MPM.add(Inliner);
180  Inliner = nullptr;
181  }
182 
183  // FIXME: The BarrierNoopPass is a HACK! The inliner pass above implicitly
184  // creates a CGSCC pass manager, but we don't want to add extensions into
185  // that pass manager. To prevent this we insert a no-op module pass to reset
186  // the pass manager to get the same behavior as EP_OptimizerLast in non-O0
187  // builds. The function merging pass is
188  if (MergeFunctions)
190  else if (!GlobalExtensions->empty() || !Extensions.empty())
191  MPM.add(createBarrierNoopPass());
192 
193  addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
194  return;
195  }
196 
197  // Add LibraryInfo if we have some.
198  if (LibraryInfo)
200 
201  addInitialAliasAnalysisPasses(MPM);
202 
203  if (!DisableUnitAtATime) {
204  addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
205 
206  MPM.add(createIPSCCPPass()); // IP SCCP
207  MPM.add(createGlobalOptimizerPass()); // Optimize out global vars
208 
209  MPM.add(createDeadArgEliminationPass()); // Dead argument elimination
210 
211  MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE
212  addExtensionsToPM(EP_Peephole, MPM);
213  MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
214  }
215 
216  // Start of CallGraph SCC passes.
217  if (!DisableUnitAtATime)
218  MPM.add(createPruneEHPass()); // Remove dead EH info
219  if (Inliner) {
220  MPM.add(Inliner);
221  Inliner = nullptr;
222  }
223  if (!DisableUnitAtATime)
224  MPM.add(createFunctionAttrsPass()); // Set readonly/readnone attrs
225  if (OptLevel > 2)
226  MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args
227 
228  // Start of function pass.
229  // Break up aggregate allocas, using SSAUpdater.
230  if (UseNewSROA)
231  MPM.add(createSROAPass(/*RequiresDomTree*/ false));
232  else
233  MPM.add(createScalarReplAggregatesPass(-1, false));
234  MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
235  MPM.add(createJumpThreadingPass()); // Thread jumps.
236  MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals
237  MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
238  MPM.add(createInstructionCombiningPass()); // Combine silly seq's
239  addExtensionsToPM(EP_Peephole, MPM);
240 
241  MPM.add(createTailCallEliminationPass()); // Eliminate tail calls
242  MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
243  MPM.add(createReassociatePass()); // Reassociate expressions
244  // Rotate Loop - disable header duplication at -Oz
245  MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));
246  MPM.add(createLICMPass()); // Hoist loop invariants
249  MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
250  MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
251  MPM.add(createLoopDeletionPass()); // Delete dead loops
252  if (EnableLoopInterchange) {
253  MPM.add(createLoopInterchangePass()); // Interchange loops
255  }
256  if (!DisableUnrollLoops)
257  MPM.add(createSimpleLoopUnrollPass()); // Unroll small loops
258  addExtensionsToPM(EP_LoopOptimizerEnd, MPM);
259 
260  if (OptLevel > 1) {
261  if (EnableMLSM)
262  MPM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds
263  MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
264  }
265  MPM.add(createMemCpyOptPass()); // Remove memcpy / form memset
266  MPM.add(createSCCPPass()); // Constant prop with SCCP
267 
268  // Delete dead bit computations (instcombine runs after to fold away the dead
269  // computations, and then ADCE will run later to exploit any new DCE
270  // opportunities that creates).
271  MPM.add(createBitTrackingDCEPass()); // Delete dead bit computations
272 
273  // Run instcombine after redundancy elimination to exploit opportunities
274  // opened up by them.
276  addExtensionsToPM(EP_Peephole, MPM);
277  MPM.add(createJumpThreadingPass()); // Thread jumps
279  MPM.add(createDeadStoreEliminationPass()); // Delete dead stores
280  MPM.add(createLICMPass());
281 
282  addExtensionsToPM(EP_ScalarOptimizerLate, MPM);
283 
284  if (RerollLoops)
285  MPM.add(createLoopRerollPass());
287  if (SLPVectorize)
288  MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
289 
290  if (BBVectorize) {
291  MPM.add(createBBVectorizePass());
293  addExtensionsToPM(EP_Peephole, MPM);
295  MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
296  else
297  MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
298 
299  // BBVectorize may have significantly shortened a loop body; unroll again.
300  if (!DisableUnrollLoops)
301  MPM.add(createLoopUnrollPass());
302  }
303  }
304 
305  if (LoadCombine)
306  MPM.add(createLoadCombinePass());
307 
308  MPM.add(createAggressiveDCEPass()); // Delete dead instructions
309  MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
310  MPM.add(createInstructionCombiningPass()); // Clean up after everything.
311  addExtensionsToPM(EP_Peephole, MPM);
312 
313  // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
314  // pass manager that we are specifically trying to avoid. To prevent this
315  // we must insert a no-op module pass to reset the pass manager.
316  MPM.add(createBarrierNoopPass());
317 
318  if (RunFloat2Int)
319  MPM.add(createFloat2IntPass());
320 
321  // Re-rotate loops in all our loop nests. These may have fallout out of
322  // rotated form due to GVN or other transformations, and the vectorizer relies
323  // on the rotated form. Disable header duplication at -Oz.
324  MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));
325 
326  // Distribute loops to allow partial vectorization. I.e. isolate dependences
327  // into separate loop that would otherwise inhibit vectorization.
330 
332  // FIXME: Because of #pragma vectorize enable, the passes below are always
333  // inserted in the pipeline, even when the vectorizer doesn't run (ex. when
334  // on -O1 and no #pragma is found). Would be good to have these two passes
335  // as function calls, so that we can only pass them when the vectorizer
336  // changed the code.
338  if (OptLevel > 1 && ExtraVectorizerPasses) {
339  // At higher optimization levels, try to clean up any runtime overlap and
340  // alignment checks inserted by the vectorizer. We want to track correllated
341  // runtime checks for two inner loops in the same outer loop, fold any
342  // common computations, hoist loop-invariant aspects out of any outer loop,
343  // and unswitch the runtime checks if possible. Once hoisted, we may have
344  // dead (or speculatable) control flows or more combining opportunities.
345  MPM.add(createEarlyCSEPass());
348  MPM.add(createLICMPass());
352  }
353 
355  if (SLPVectorize) {
356  MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
357  if (OptLevel > 1 && ExtraVectorizerPasses) {
358  MPM.add(createEarlyCSEPass());
359  }
360  }
361 
362  if (BBVectorize) {
363  MPM.add(createBBVectorizePass());
365  addExtensionsToPM(EP_Peephole, MPM);
367  MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
368  else
369  MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
370 
371  // BBVectorize may have significantly shortened a loop body; unroll again.
372  if (!DisableUnrollLoops)
373  MPM.add(createLoopUnrollPass());
374  }
375  }
376 
377  addExtensionsToPM(EP_Peephole, MPM);
380 
381  if (!DisableUnrollLoops) {
382  MPM.add(createLoopUnrollPass()); // Unroll small loops
383 
384  // LoopUnroll may generate some redundency to cleanup.
386 
387  // Runtime unrolling will introduce runtime check in loop prologue. If the
388  // unrolled loop is a inner loop, then the prologue will be inside the
389  // outer loop. LICM pass can help to promote the runtime check out if the
390  // checked value is loop invariant.
391  MPM.add(createLICMPass());
392  }
393 
394  // After vectorization and unrolling, assume intrinsics may tell us more
395  // about pointer alignments.
397 
398  if (!DisableUnitAtATime) {
399  // FIXME: We shouldn't bother with this anymore.
400  MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
401 
402  // GlobalOpt already deletes dead functions and globals, at -O2 try a
403  // late pass of GlobalDCE. It is capable of deleting dead cycles.
404  if (OptLevel > 1) {
405  if (!PrepareForLTO) {
406  // Remove avail extern fns and globals definitions if we aren't
407  // compiling an object file for later LTO. For LTO we want to preserve
408  // these so they are eligible for inlining at link-time. Note if they
409  // are unreferenced they will be removed by GlobalDCE below, so
410  // this only impacts referenced available externally globals.
411  // Eventually they will be suppressed during codegen, but eliminating
412  // here enables more opportunity for GlobalDCE as it may make
413  // globals referenced by available external functions dead.
415  }
416  MPM.add(createGlobalDCEPass()); // Remove dead fns and globals.
417  MPM.add(createConstantMergePass()); // Merge dup global constants
418  }
419  }
420 
421  if (MergeFunctions)
423 
424  addExtensionsToPM(EP_OptimizerLast, MPM);
425 }
426 
427 void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) {
428  // Provide AliasAnalysis services for optimizations.
429  addInitialAliasAnalysisPasses(PM);
430 
431  // Propagate constants at call sites into the functions they call. This
432  // opens opportunities for globalopt (and inlining) by substituting function
433  // pointers passed as arguments to direct uses of functions.
434  PM.add(createIPSCCPPass());
435 
436  // Now that we internalized some globals, see if we can hack on them!
438 
439  // Linking modules together can lead to duplicated global constants, only
440  // keep one copy of each constant.
442 
443  // Remove unused arguments from functions.
445 
446  // Reduce the code after globalopt and ipsccp. Both can open up significant
447  // simplification opportunities, and both can propagate functions through
448  // function pointers. When this happens, we often have to resolve varargs
449  // calls, etc, so let instcombine do this.
451  addExtensionsToPM(EP_Peephole, PM);
452 
453  // Inline small functions
454  bool RunInliner = Inliner;
455  if (RunInliner) {
456  PM.add(Inliner);
457  Inliner = nullptr;
458  }
459 
460  PM.add(createPruneEHPass()); // Remove dead EH info.
461 
462  // Optimize globals again if we ran the inliner.
463  if (RunInliner)
465  PM.add(createGlobalDCEPass()); // Remove dead functions.
466 
467  // If we didn't decide to inline a function, check to see if we can
468  // transform it to pass arguments by value instead of by reference.
470 
471  // The IPO passes may leave cruft around. Clean up after them.
473  addExtensionsToPM(EP_Peephole, PM);
475 
476  // Break up allocas
477  if (UseNewSROA)
478  PM.add(createSROAPass());
479  else
481 
482  // Run a few AA driven optimizations here and now, to cleanup the code.
483  PM.add(createFunctionAttrsPass()); // Add nocapture.
484  PM.add(createGlobalsModRefPass()); // IP alias analysis.
485 
486  PM.add(createLICMPass()); // Hoist loop invariants.
487  if (EnableMLSM)
488  PM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds.
489  PM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies.
490  PM.add(createMemCpyOptPass()); // Remove dead memcpys.
491 
492  // Nuke dead stores.
494 
495  // More loops are countable; try to optimize them.
500 
502 
503  // More scalar chains could be vectorized due to more alias information
505  if (SLPVectorize)
506  PM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
507 
508  // After vectorization, assume intrinsics may tell us more about pointer
509  // alignments.
511 
512  if (LoadCombine)
514 
515  // Cleanup and simplify the code after the scalar optimizations.
517  addExtensionsToPM(EP_Peephole, PM);
518 
520 }
521 
522 void PassManagerBuilder::addLateLTOOptimizationPasses(
524  // Delete basic blocks, which optimization passes may have killed.
526 
527  // Now that we have optimized the program, discard unreachable functions.
528  PM.add(createGlobalDCEPass());
529 
530  // FIXME: this is profitable (for compiler time) to do at -O0 too, but
531  // currently it damages debug info.
532  if (MergeFunctions)
534 }
535 
537  if (LibraryInfo)
539 
540  if (VerifyInput)
541  PM.add(createVerifierPass());
542 
543  if (OptLevel > 1)
544  addLTOOptimizationPasses(PM);
545 
546  // Lower bit sets to globals. This pass supports Clang's control flow
547  // integrity mechanisms (-fsanitize=cfi*) and needs to run at link time if CFI
548  // is enabled. The pass does nothing if CFI is disabled.
550 
551  if (OptLevel != 0)
552  addLateLTOOptimizationPasses(PM);
553 
554  if (VerifyOutput)
555  PM.add(createVerifierPass());
556 }
557 
559  return reinterpret_cast<PassManagerBuilder*>(P);
560 }
561 
563  return reinterpret_cast<LLVMPassManagerBuilderRef>(P);
564 }
565 
568  return wrap(PMB);
569 }
570 
572  PassManagerBuilder *Builder = unwrap(PMB);
573  delete Builder;
574 }
575 
576 void
578  unsigned OptLevel) {
579  PassManagerBuilder *Builder = unwrap(PMB);
580  Builder->OptLevel = OptLevel;
581 }
582 
583 void
585  unsigned SizeLevel) {
586  PassManagerBuilder *Builder = unwrap(PMB);
587  Builder->SizeLevel = SizeLevel;
588 }
589 
590 void
592  LLVMBool Value) {
593  PassManagerBuilder *Builder = unwrap(PMB);
594  Builder->DisableUnitAtATime = Value;
595 }
596 
597 void
599  LLVMBool Value) {
600  PassManagerBuilder *Builder = unwrap(PMB);
601  Builder->DisableUnrollLoops = Value;
602 }
603 
604 void
606  LLVMBool Value) {
607  // NOTE: The simplify-libcalls pass has been removed.
608 }
609 
610 void
612  unsigned Threshold) {
613  PassManagerBuilder *Builder = unwrap(PMB);
614  Builder->Inliner = createFunctionInliningPass(Threshold);
615 }
616 
617 void
619  LLVMPassManagerRef PM) {
620  PassManagerBuilder *Builder = unwrap(PMB);
621  legacy::FunctionPassManager *FPM = unwrap<legacy::FunctionPassManager>(PM);
622  Builder->populateFunctionPassManager(*FPM);
623 }
624 
625 void
627  LLVMPassManagerRef PM) {
628  PassManagerBuilder *Builder = unwrap(PMB);
629  legacy::PassManagerBase *MPM = unwrap(PM);
630  Builder->populateModulePassManager(*MPM);
631 }
632 
635  LLVMBool Internalize,
636  LLVMBool RunInliner) {
637  PassManagerBuilder *Builder = unwrap(PMB);
638  legacy::PassManagerBase *LPM = unwrap(PM);
639 
640  // A small backwards compatibility hack. populateLTOPassManager used to take
641  // an RunInliner option.
642  if (RunInliner && !Builder->Inliner)
643  Builder->Inliner = createFunctionInliningPass();
644 
645  Builder->populateLTOPassManager(*LPM);
646 }
static cl::opt< bool > RunLoadCombine("combine-loads", cl::init(false), cl::Hidden, cl::desc("Run the load combining pass"))
FunctionPass * createGVNPass(bool NoLoads=false)
Definition: GVN.cpp:732
Pass * createLoopRerollPass()
void LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB, unsigned OptLevel)
See llvm::PassManagerBuilder::OptLevel.
PassManagerBuilder - This class is used to set up a standard optimization sequence for languages like...
static cl::opt< bool > RunBBVectorization("vectorize-slp-aggressive", cl::Hidden, cl::desc("Run the BB vectorization passes"))
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"))
FunctionPass * createScalarReplAggregatesPass(signed Threshold=-1, bool UseDomTree=true, signed StructMemberThreshold=-1, signed ArrayElementThreshold=-1, signed ScalarLoadThreshold=-1)
ModulePass * createMergeFunctionsPass()
createMergeFunctionsPass - This pass discovers identical functions and collapses them.
void LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB, LLVMBool Value)
See llvm::PassManagerBuilder::DisableSimplifyLibCalls.
EP_ScalarOptimizerLate - This extension point allows adding optimization passes after most of the mai...
FunctionPass * createVerifierPass(bool FatalErrors=true)
Create a verifier pass.
Definition: Verifier.cpp:3703
ModulePass * createIPSCCPPass()
createIPSCCPPass - This pass propagates constants from call sites into the bodies of functions...
Definition: SCCP.cpp:1661
FunctionPass * createFloat2IntPass()
Definition: Float2Int.cpp:537
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.
ModulePass * createEliminateAvailableExternallyPass()
This transform is designed to eliminate available external globals (functions or global variables) ...
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)
Pass * createFunctionAttrsPass()
createFunctionAttrsPass - This pass discovers functions that do not access memory, or only read memory, and gives them the readnone/readonly attribute.
static cl::opt< bool > RunLoopVectorization("vectorize-loops", cl::Hidden, cl::desc("Run the Loop vectorization passes"))
static cl::opt< bool > EnableLoopDistribute("enable-loop-distribute", cl::init(false), cl::Hidden, cl::desc("Enable the new, experimental LoopDistribution Pass"))
static void addGlobalExtension(ExtensionPointTy Ty, ExtensionFn Fn)
Adds an extension that will be used by all PassManagerBuilder instances.
void populateLTOPassManager(legacy::PassManagerBase &PM)
FunctionPass * createSROAPass(bool RequiresDomTree=true)
Definition: SROA.cpp:1275
static cl::opt< bool > ExtraVectorizerPasses("extra-vectorizer-passes", cl::init(false), cl::Hidden, cl::desc("Run cleanup optimization passes after vectorization."))
FunctionPass * createReassociatePass()
Pass * createArgumentPromotionPass(unsigned maxElements=3)
createArgumentPromotionPass - This pass promotes "by reference" arguments to be passed by value if th...
EP_ModuleOptimizerEarly - This extension point allows adding passes just before the main module-level...
LLVMTargetDataRef wrap(const DataLayout *P)
Definition: DataLayout.h:469
Pass * createGlobalsModRefPass()
EP_EnabledOnOptLevel0 - This extension point allows adding passes that should not be disabled by O0 o...
FunctionPass * createLoopDistributePass()
unsigned OptLevel
The Optimization Level - Specify the basic optimization level.
Pass * createLoopUnswitchPass(bool OptimizeForSize=false)
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.
void add(Pass *P) override
Add a pass to the queue of passes to run.
ImmutablePass * createBasicAliasAnalysisPass()
ImmutablePass * createScopedNoAliasAAPass()
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.
ImmutablePass * createCFLAliasAnalysisPass()
Pass * createLoopUnrollPass(int Threshold=-1, int Count=-1, int AllowPartial=-1, int Runtime=-1)
FunctionPass * createInstructionCombiningPass()
ModulePass * createGlobalDCEPass()
createGlobalDCEPass - This transform is designed to eliminate unreachable internal globals (functions...
static cl::opt< bool > UseNewSROA("use-new-sroa", cl::init(true), cl::Hidden, cl::desc("Enable the new, experimental SROA pass"))
Pass * createCorrelatedValuePropagationPass()
struct LLVMOpaquePassManagerBuilder * LLVMPassManagerBuilderRef
#define P(N)
Inliner - This class contains all of the helper code which is used to perform the inlining operations...
Definition: InlinerPass.h:32
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:325
DataLayout * unwrap(LLVMTargetDataRef P)
Definition: DataLayout.h:465
Pass * createLoopRotatePass(int MaxHeaderSize=-1)
ImmutablePass * createTypeBasedAliasAnalysisPass()
static cl::opt< bool > EnableMLSM("mlsm", cl::init(true), cl::Hidden, cl::desc("Enable motion of merged load and store"))
FunctionPass * createTailCallEliminationPass()
TargetLibraryInfoImpl * LibraryInfo
LibraryInfo - Specifies information about the runtime library for the optimizer.
ModulePass * createLowerBitSetsPass()
This pass lowers bitset metadata and the llvm.bitset.test intrinsic to bitsets.
ModulePass * createDeadArgEliminationPass()
createDeadArgEliminationPass - This pass removes arguments from functions which are not used by the b...
void LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB)
FunctionPass * createCFGSimplificationPass(int Threshold=-1, std::function< bool(const Function &)> Ftor=nullptr)
ModulePass * createBarrierNoopPass()
createBarrierNoopPass - This pass is purely a module pass barrier in a pass manager.
FunctionPass * createMemCpyOptPass()
FunctionPass * createBitTrackingDCEPass()
Definition: BDCE.cpp:407
ModulePass * createConstantMergePass()
createConstantMergePass - This function returns a new pass that merges duplicate global constants tog...
void(* ExtensionFn)(const PassManagerBuilder &Builder, legacy::PassManagerBase &PM)
Extensions are passed the builder itself (so they can see how it is configured) as well as the pass m...
FunctionPass * createEarlyCSEPass()
Definition: EarlyCSE.cpp:771
ModulePass * createGlobalOptimizerPass()
createGlobalOptimizerPass - This function returns a new pass that optimizes non-address taken interna...
Definition: GlobalOpt.cpp:101
void populateFunctionPassManager(legacy::FunctionPassManager &FPM)
populateFunctionPassManager - This fills in the function pass manager, which is expected to be run on...
FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
int LLVMBool
Definition: Support.h:29
EP_OptimizerLast – This extension point allows adding passes that run after everything else...
EP_EarlyAsPossible - This extension point allows adding passes before any other transformations, allowing them to see the code as it is coming out of the frontend.
static cl::opt< bool > EnableLoopInterchange("enable-loopinterchange", cl::init(false), cl::Hidden, cl::desc("Enable the new, experimental LoopInterchange Pass"))
static cl::opt< bool > RunFloat2Int("float-to-int", cl::Hidden, cl::init(true), cl::desc("Run the float2int (float demotion) pass"))
BasicBlockPass * createLoadCombinePass()
Pass * createLoopInterchangePass()
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
FunctionPass * createDeadStoreEliminationPass()
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:861
FunctionPass * createMergedLoadStoreMotionPass()
createMergedLoadStoreMotionPass - The public interface to this file.
Pass * createLoopDeletionPass()
Pass * createLICMPass()
Definition: LICM.cpp:172
BasicBlockPass * createBBVectorizePass(const VectorizeConfig &C=VectorizeConfig())
EP_Peephole - This extension point allows adding passes that perform peephole optimizations similar t...
Pass * createLoopIdiomPass()
static cl::opt< bool > UseCFLAA("use-cfl-aa", cl::init(false), cl::Hidden, cl::desc("Enable the new, experimental CFL alias analysis"))
LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate()
See llvm::PassManagerBuilder.
FunctionPass * createSCCPPass()
FunctionPass * createAggressiveDCEPass()
Definition: ADCE.cpp:97
void LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM)
See llvm::PassManagerBuilder::populateModulePassManager.
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition: Core.h:116
unsigned SizeLevel
SizeLevel - How much we're optimizing for size.
Pass * createSLPVectorizerPass()
static int const Threshold
TODO: Write a new FunctionPass AliasAnalysis so that it can keep a cache.
void LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB, LLVMBool Value)
See llvm::PassManagerBuilder::DisableUnitAtATime.
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:62
LLVM Value Representation.
Definition: Value.h:69
Pass * createSimpleLoopUnrollPass()
ModulePass * createStripDeadPrototypesPass()
createStripDeadPrototypesPass - This pass removes any function declarations (prototypes) that are not...
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
Definition: ManagedStatic.h:61
void LLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM)
See llvm::PassManagerBuilder::populateFunctionPassManager.
void addExtension(ExtensionPointTy Ty, ExtensionFn Fn)
Pass * createIndVarSimplifyPass()
FunctionPass * createLowerExpectIntrinsicPass()
EP_LoopOptimizerEnd - This extension point allows adding loop passes to the end of the loop optimizer...
static cl::opt< bool > RunLoopRerolling("reroll-loops", cl::Hidden, cl::desc("Run the loop rerolling pass"))
void LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB, unsigned Threshold)
See llvm::PassManagerBuilder::Inliner.