1 //===- PassManagerBuilder.cpp - Build Standard Pass -----------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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++.
13 //===----------------------------------------------------------------------===//
16 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
17 #include "llvm-c/Transforms/PassManagerBuilder.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/Analysis/Passes.h"
20 #include "llvm/IR/DataLayout.h"
21 #include "llvm/IR/Verifier.h"
22 #include "llvm/IR/LegacyPassManager.h"
23 #include "llvm/Support/CommandLine.h"
24 #include "llvm/Support/ManagedStatic.h"
25 #include "llvm/Analysis/BasicAliasAnalysis.h"
26 #include "llvm/Analysis/TargetLibraryInfo.h"
27 #include "llvm/Target/TargetMachine.h"
28 #include "llvm/Transforms/IPO.h"
29 #include "llvm/Transforms/Scalar.h"
30 #include "llvm/Transforms/Vectorize.h"
35 RunLoopVectorization("vectorize-loops", cl::Hidden,
36 cl::desc("Run the Loop vectorization passes"));
39 RunSLPVectorization("vectorize-slp", cl::Hidden,
40 cl::desc("Run the SLP vectorization passes"));
43 RunBBVectorization("vectorize-slp-aggressive", cl::Hidden,
44 cl::desc("Run the BB vectorization passes"));
47 UseGVNAfterVectorization("use-gvn-after-vectorization",
48 cl::init(false), cl::Hidden,
49 cl::desc("Run GVN instead of Early CSE after vectorization passes"));
51 static cl::opt<bool> ExtraVectorizerPasses(
52 "extra-vectorizer-passes", cl::init(false), cl::Hidden,
53 cl::desc("Run cleanup optimization passes after vectorization."));
55 static cl::opt<bool> UseNewSROA("use-new-sroa",
56 cl::init(true), cl::Hidden,
57 cl::desc("Enable the new, experimental SROA pass"));
60 RunLoopRerolling("reroll-loops", cl::Hidden,
61 cl::desc("Run the loop rerolling pass"));
64 RunFloat2Int("float-to-int", cl::Hidden, cl::init(true),
65 cl::desc("Run the float2int (float demotion) pass"));
67 static cl::opt<bool> RunLoadCombine("combine-loads", cl::init(false),
69 cl::desc("Run the load combining pass"));
72 RunSLPAfterLoopVectorization("run-slp-after-loop-vectorization",
73 cl::init(true), cl::Hidden,
74 cl::desc("Run the SLP vectorizer (and BB vectorizer) after the Loop "
75 "vectorizer instead of before"));
77 static cl::opt<bool> UseCFLAA("use-cfl-aa",
78 cl::init(false), cl::Hidden,
79 cl::desc("Enable the new, experimental CFL alias analysis"));
82 EnableMLSM("mlsm", cl::init(true), cl::Hidden,
83 cl::desc("Enable motion of merged load and store"));
85 static cl::opt<bool> EnableLoopInterchange(
86 "enable-loopinterchange", cl::init(false), cl::Hidden,
87 cl::desc("Enable the new, experimental LoopInterchange Pass"));
89 static cl::opt<bool> EnableLoopDistribute(
90 "enable-loop-distribute", cl::init(false), cl::Hidden,
91 cl::desc("Enable the new, experimental LoopDistribution Pass"));
93 static cl::opt<bool> EnableNonLTOGlobalsModRef(
94 "enable-non-lto-gmr", cl::init(false), cl::Hidden,
96 "Enable the GlobalsModRef AliasAnalysis outside of the LTO pipeline."));
98 PassManagerBuilder::PassManagerBuilder() {
101 LibraryInfo = nullptr;
103 DisableUnitAtATime = false;
104 DisableUnrollLoops = false;
105 BBVectorize = RunBBVectorization;
106 SLPVectorize = RunSLPVectorization;
107 LoopVectorize = RunLoopVectorization;
108 RerollLoops = RunLoopRerolling;
109 LoadCombine = RunLoadCombine;
110 DisableGVNLoadPRE = false;
112 VerifyOutput = false;
113 MergeFunctions = false;
114 PrepareForLTO = false;
117 PassManagerBuilder::~PassManagerBuilder() {
122 /// Set of global extensions, automatically added as part of the standard set.
123 static ManagedStatic<SmallVector<std::pair<PassManagerBuilder::ExtensionPointTy,
124 PassManagerBuilder::ExtensionFn>, 8> > GlobalExtensions;
126 void PassManagerBuilder::addGlobalExtension(
127 PassManagerBuilder::ExtensionPointTy Ty,
128 PassManagerBuilder::ExtensionFn Fn) {
129 GlobalExtensions->push_back(std::make_pair(Ty, Fn));
132 void PassManagerBuilder::addExtension(ExtensionPointTy Ty, ExtensionFn Fn) {
133 Extensions.push_back(std::make_pair(Ty, Fn));
136 void PassManagerBuilder::addExtensionsToPM(ExtensionPointTy ETy,
137 legacy::PassManagerBase &PM) const {
138 for (unsigned i = 0, e = GlobalExtensions->size(); i != e; ++i)
139 if ((*GlobalExtensions)[i].first == ETy)
140 (*GlobalExtensions)[i].second(*this, PM);
141 for (unsigned i = 0, e = Extensions.size(); i != e; ++i)
142 if (Extensions[i].first == ETy)
143 Extensions[i].second(*this, PM);
146 void PassManagerBuilder::addInitialAliasAnalysisPasses(
147 legacy::PassManagerBase &PM) const {
148 // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that
149 // BasicAliasAnalysis wins if they disagree. This is intended to help
150 // support "obvious" type-punning idioms.
152 PM.add(createCFLAliasAnalysisPass());
153 PM.add(createTypeBasedAliasAnalysisPass());
154 PM.add(createScopedNoAliasAAPass());
155 PM.add(createBasicAliasAnalysisPass());
158 void PassManagerBuilder::populateFunctionPassManager(
159 legacy::FunctionPassManager &FPM) {
160 addExtensionsToPM(EP_EarlyAsPossible, FPM);
162 // Add LibraryInfo if we have some.
164 FPM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
166 if (OptLevel == 0) return;
168 addInitialAliasAnalysisPasses(FPM);
170 FPM.add(createCFGSimplificationPass());
172 FPM.add(createSROAPass());
174 FPM.add(createScalarReplAggregatesPass());
175 FPM.add(createEarlyCSEPass());
176 FPM.add(createLowerExpectIntrinsicPass());
179 void PassManagerBuilder::populateModulePassManager(
180 legacy::PassManagerBase &MPM) {
181 // If all optimizations are disabled, just run the always-inline pass and,
182 // if enabled, the function merging pass.
189 // FIXME: The BarrierNoopPass is a HACK! The inliner pass above implicitly
190 // creates a CGSCC pass manager, but we don't want to add extensions into
191 // that pass manager. To prevent this we insert a no-op module pass to reset
192 // the pass manager to get the same behavior as EP_OptimizerLast in non-O0
193 // builds. The function merging pass is
195 MPM.add(createMergeFunctionsPass());
196 else if (!GlobalExtensions->empty() || !Extensions.empty())
197 MPM.add(createBarrierNoopPass());
199 addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
203 // Add LibraryInfo if we have some.
205 MPM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
207 addInitialAliasAnalysisPasses(MPM);
209 if (!DisableUnitAtATime) {
210 addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
212 MPM.add(createIPSCCPPass()); // IP SCCP
213 MPM.add(createGlobalOptimizerPass()); // Optimize out global vars
215 MPM.add(createDeadArgEliminationPass()); // Dead argument elimination
217 MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE
218 addExtensionsToPM(EP_Peephole, MPM);
219 MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
222 if (EnableNonLTOGlobalsModRef)
223 // We add a module alias analysis pass here. In part due to bugs in the
224 // analysis infrastructure this "works" in that the analysis stays alive
225 // for the entire SCC pass run below.
226 MPM.add(createGlobalsModRefPass());
228 // Start of CallGraph SCC passes.
229 if (!DisableUnitAtATime)
230 MPM.add(createPruneEHPass()); // Remove dead EH info
235 if (!DisableUnitAtATime)
236 MPM.add(createFunctionAttrsPass()); // Set readonly/readnone attrs
238 MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args
240 // Start of function pass.
241 // Break up aggregate allocas, using SSAUpdater.
243 MPM.add(createSROAPass(/*RequiresDomTree*/ false));
245 MPM.add(createScalarReplAggregatesPass(-1, false));
246 MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
247 MPM.add(createJumpThreadingPass()); // Thread jumps.
248 MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals
249 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
250 MPM.add(createInstructionCombiningPass()); // Combine silly seq's
251 addExtensionsToPM(EP_Peephole, MPM);
253 MPM.add(createTailCallEliminationPass()); // Eliminate tail calls
254 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
255 MPM.add(createReassociatePass()); // Reassociate expressions
256 // Rotate Loop - disable header duplication at -Oz
257 MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));
258 MPM.add(createLICMPass()); // Hoist loop invariants
259 MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3));
260 MPM.add(createInstructionCombiningPass());
261 MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
262 MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
263 MPM.add(createLoopDeletionPass()); // Delete dead loops
264 if (EnableLoopInterchange) {
265 MPM.add(createLoopInterchangePass()); // Interchange loops
266 MPM.add(createCFGSimplificationPass());
268 if (!DisableUnrollLoops)
269 MPM.add(createSimpleLoopUnrollPass()); // Unroll small loops
270 addExtensionsToPM(EP_LoopOptimizerEnd, MPM);
274 MPM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds
275 MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
277 MPM.add(createMemCpyOptPass()); // Remove memcpy / form memset
278 MPM.add(createSCCPPass()); // Constant prop with SCCP
280 // Delete dead bit computations (instcombine runs after to fold away the dead
281 // computations, and then ADCE will run later to exploit any new DCE
282 // opportunities that creates).
283 MPM.add(createBitTrackingDCEPass()); // Delete dead bit computations
285 // Run instcombine after redundancy elimination to exploit opportunities
286 // opened up by them.
287 MPM.add(createInstructionCombiningPass());
288 addExtensionsToPM(EP_Peephole, MPM);
289 MPM.add(createJumpThreadingPass()); // Thread jumps
290 MPM.add(createCorrelatedValuePropagationPass());
291 MPM.add(createDeadStoreEliminationPass()); // Delete dead stores
292 MPM.add(createLICMPass());
294 addExtensionsToPM(EP_ScalarOptimizerLate, MPM);
297 MPM.add(createLoopRerollPass());
298 if (!RunSLPAfterLoopVectorization) {
300 MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
303 MPM.add(createBBVectorizePass());
304 MPM.add(createInstructionCombiningPass());
305 addExtensionsToPM(EP_Peephole, MPM);
306 if (OptLevel > 1 && UseGVNAfterVectorization)
307 MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
309 MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
311 // BBVectorize may have significantly shortened a loop body; unroll again.
312 if (!DisableUnrollLoops)
313 MPM.add(createLoopUnrollPass());
318 MPM.add(createLoadCombinePass());
320 MPM.add(createAggressiveDCEPass()); // Delete dead instructions
321 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
322 MPM.add(createInstructionCombiningPass()); // Clean up after everything.
323 addExtensionsToPM(EP_Peephole, MPM);
325 // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
326 // pass manager that we are specifically trying to avoid. To prevent this
327 // we must insert a no-op module pass to reset the pass manager.
328 MPM.add(createBarrierNoopPass());
330 if (EnableNonLTOGlobalsModRef)
331 // We add a fresh GlobalsModRef run at this point. This is particularly
332 // useful as the above will have inlined, DCE'ed, and function-attr
333 // propagated everything. We should at this point have a reasonably minimal
334 // and richly annotated call graph. By computing aliasing and mod/ref
335 // information for all local globals here, the late loop passes and notably
336 // the vectorizer will be able to use them to help recognize vectorizable
337 // memory operations.
339 // Note that this relies on a bug in the pass manager which preserves
340 // a module analysis into a function pass pipeline (and throughout it) so
341 // long as the first function pass doesn't invalidate the module analysis.
342 // Thus both Float2Int and LoopRotate have to preserve AliasAnalysis for
343 // this to work. Fortunately, it is trivial to preserve AliasAnalysis
344 // (doing nothing preserves it as it is required to be conservatively
345 // correct in the face of IR changes).
346 MPM.add(createGlobalsModRefPass());
349 MPM.add(createFloat2IntPass());
351 addExtensionsToPM(EP_VectorizerStart, MPM);
353 // Re-rotate loops in all our loop nests. These may have fallout out of
354 // rotated form due to GVN or other transformations, and the vectorizer relies
355 // on the rotated form. Disable header duplication at -Oz.
356 MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));
358 // Distribute loops to allow partial vectorization. I.e. isolate dependences
359 // into separate loop that would otherwise inhibit vectorization.
360 if (EnableLoopDistribute)
361 MPM.add(createLoopDistributePass());
363 MPM.add(createLoopVectorizePass(DisableUnrollLoops, LoopVectorize));
364 // FIXME: Because of #pragma vectorize enable, the passes below are always
365 // inserted in the pipeline, even when the vectorizer doesn't run (ex. when
366 // on -O1 and no #pragma is found). Would be good to have these two passes
367 // as function calls, so that we can only pass them when the vectorizer
369 MPM.add(createInstructionCombiningPass());
370 if (OptLevel > 1 && ExtraVectorizerPasses) {
371 // At higher optimization levels, try to clean up any runtime overlap and
372 // alignment checks inserted by the vectorizer. We want to track correllated
373 // runtime checks for two inner loops in the same outer loop, fold any
374 // common computations, hoist loop-invariant aspects out of any outer loop,
375 // and unswitch the runtime checks if possible. Once hoisted, we may have
376 // dead (or speculatable) control flows or more combining opportunities.
377 MPM.add(createEarlyCSEPass());
378 MPM.add(createCorrelatedValuePropagationPass());
379 MPM.add(createInstructionCombiningPass());
380 MPM.add(createLICMPass());
381 MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3));
382 MPM.add(createCFGSimplificationPass());
383 MPM.add(createInstructionCombiningPass());
386 if (RunSLPAfterLoopVectorization) {
388 MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
389 if (OptLevel > 1 && ExtraVectorizerPasses) {
390 MPM.add(createEarlyCSEPass());
395 MPM.add(createBBVectorizePass());
396 MPM.add(createInstructionCombiningPass());
397 addExtensionsToPM(EP_Peephole, MPM);
398 if (OptLevel > 1 && UseGVNAfterVectorization)
399 MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
401 MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
403 // BBVectorize may have significantly shortened a loop body; unroll again.
404 if (!DisableUnrollLoops)
405 MPM.add(createLoopUnrollPass());
409 addExtensionsToPM(EP_Peephole, MPM);
410 MPM.add(createCFGSimplificationPass());
411 MPM.add(createInstructionCombiningPass());
413 if (!DisableUnrollLoops) {
414 MPM.add(createLoopUnrollPass()); // Unroll small loops
416 // LoopUnroll may generate some redundency to cleanup.
417 MPM.add(createInstructionCombiningPass());
419 // Runtime unrolling will introduce runtime check in loop prologue. If the
420 // unrolled loop is a inner loop, then the prologue will be inside the
421 // outer loop. LICM pass can help to promote the runtime check out if the
422 // checked value is loop invariant.
423 MPM.add(createLICMPass());
426 // After vectorization and unrolling, assume intrinsics may tell us more
427 // about pointer alignments.
428 MPM.add(createAlignmentFromAssumptionsPass());
430 if (!DisableUnitAtATime) {
431 // FIXME: We shouldn't bother with this anymore.
432 MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
434 // GlobalOpt already deletes dead functions and globals, at -O2 try a
435 // late pass of GlobalDCE. It is capable of deleting dead cycles.
437 if (!PrepareForLTO) {
438 // Remove avail extern fns and globals definitions if we aren't
439 // compiling an object file for later LTO. For LTO we want to preserve
440 // these so they are eligible for inlining at link-time. Note if they
441 // are unreferenced they will be removed by GlobalDCE below, so
442 // this only impacts referenced available externally globals.
443 // Eventually they will be suppressed during codegen, but eliminating
444 // here enables more opportunity for GlobalDCE as it may make
445 // globals referenced by available external functions dead.
446 MPM.add(createEliminateAvailableExternallyPass());
448 MPM.add(createGlobalDCEPass()); // Remove dead fns and globals.
449 MPM.add(createConstantMergePass()); // Merge dup global constants
454 MPM.add(createMergeFunctionsPass());
456 addExtensionsToPM(EP_OptimizerLast, MPM);
459 void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) {
460 // Provide AliasAnalysis services for optimizations.
461 addInitialAliasAnalysisPasses(PM);
463 // Propagate constants at call sites into the functions they call. This
464 // opens opportunities for globalopt (and inlining) by substituting function
465 // pointers passed as arguments to direct uses of functions.
466 PM.add(createIPSCCPPass());
468 // Now that we internalized some globals, see if we can hack on them!
469 PM.add(createGlobalOptimizerPass());
471 // Linking modules together can lead to duplicated global constants, only
472 // keep one copy of each constant.
473 PM.add(createConstantMergePass());
475 // Remove unused arguments from functions.
476 PM.add(createDeadArgEliminationPass());
478 // Reduce the code after globalopt and ipsccp. Both can open up significant
479 // simplification opportunities, and both can propagate functions through
480 // function pointers. When this happens, we often have to resolve varargs
481 // calls, etc, so let instcombine do this.
482 PM.add(createInstructionCombiningPass());
483 addExtensionsToPM(EP_Peephole, PM);
485 // Inline small functions
486 bool RunInliner = Inliner;
492 PM.add(createPruneEHPass()); // Remove dead EH info.
494 // Optimize globals again if we ran the inliner.
496 PM.add(createGlobalOptimizerPass());
497 PM.add(createGlobalDCEPass()); // Remove dead functions.
499 // If we didn't decide to inline a function, check to see if we can
500 // transform it to pass arguments by value instead of by reference.
501 PM.add(createArgumentPromotionPass());
503 // The IPO passes may leave cruft around. Clean up after them.
504 PM.add(createInstructionCombiningPass());
505 addExtensionsToPM(EP_Peephole, PM);
506 PM.add(createJumpThreadingPass());
510 PM.add(createSROAPass());
512 PM.add(createScalarReplAggregatesPass());
514 // Run a few AA driven optimizations here and now, to cleanup the code.
515 PM.add(createFunctionAttrsPass()); // Add nocapture.
516 PM.add(createGlobalsModRefPass()); // IP alias analysis.
518 PM.add(createLICMPass()); // Hoist loop invariants.
520 PM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds.
521 PM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies.
522 PM.add(createMemCpyOptPass()); // Remove dead memcpys.
525 PM.add(createDeadStoreEliminationPass());
527 // More loops are countable; try to optimize them.
528 PM.add(createIndVarSimplifyPass());
529 PM.add(createLoopDeletionPass());
530 if (EnableLoopInterchange)
531 PM.add(createLoopInterchangePass());
533 PM.add(createLoopVectorizePass(true, LoopVectorize));
535 // More scalar chains could be vectorized due to more alias information
536 if (RunSLPAfterLoopVectorization)
538 PM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
540 // After vectorization, assume intrinsics may tell us more about pointer
542 PM.add(createAlignmentFromAssumptionsPass());
545 PM.add(createLoadCombinePass());
547 // Cleanup and simplify the code after the scalar optimizations.
548 PM.add(createInstructionCombiningPass());
549 addExtensionsToPM(EP_Peephole, PM);
551 PM.add(createJumpThreadingPass());
554 void PassManagerBuilder::addLateLTOOptimizationPasses(
555 legacy::PassManagerBase &PM) {
556 // Delete basic blocks, which optimization passes may have killed.
557 PM.add(createCFGSimplificationPass());
559 // Drop bodies of available externally objects to improve GlobalDCE.
560 PM.add(createEliminateAvailableExternallyPass());
562 // Now that we have optimized the program, discard unreachable functions.
563 PM.add(createGlobalDCEPass());
565 // FIXME: this is profitable (for compiler time) to do at -O0 too, but
566 // currently it damages debug info.
568 PM.add(createMergeFunctionsPass());
571 void PassManagerBuilder::populateLTOPassManager(legacy::PassManagerBase &PM) {
573 PM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
576 PM.add(createVerifierPass());
579 addLTOOptimizationPasses(PM);
581 // Lower bit sets to globals. This pass supports Clang's control flow
582 // integrity mechanisms (-fsanitize=cfi*) and needs to run at link time if CFI
583 // is enabled. The pass does nothing if CFI is disabled.
584 PM.add(createLowerBitSetsPass());
587 addLateLTOOptimizationPasses(PM);
590 PM.add(createVerifierPass());
593 inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {
594 return reinterpret_cast<PassManagerBuilder*>(P);
597 inline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) {
598 return reinterpret_cast<LLVMPassManagerBuilderRef>(P);
601 LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate() {
602 PassManagerBuilder *PMB = new PassManagerBuilder();
606 void LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB) {
607 PassManagerBuilder *Builder = unwrap(PMB);
612 LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB,
614 PassManagerBuilder *Builder = unwrap(PMB);
615 Builder->OptLevel = OptLevel;
619 LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB,
620 unsigned SizeLevel) {
621 PassManagerBuilder *Builder = unwrap(PMB);
622 Builder->SizeLevel = SizeLevel;
626 LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB,
628 PassManagerBuilder *Builder = unwrap(PMB);
629 Builder->DisableUnitAtATime = Value;
633 LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB,
635 PassManagerBuilder *Builder = unwrap(PMB);
636 Builder->DisableUnrollLoops = Value;
640 LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB,
642 // NOTE: The simplify-libcalls pass has been removed.
646 LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB,
647 unsigned Threshold) {
648 PassManagerBuilder *Builder = unwrap(PMB);
649 Builder->Inliner = createFunctionInliningPass(Threshold);
653 LLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB,
654 LLVMPassManagerRef PM) {
655 PassManagerBuilder *Builder = unwrap(PMB);
656 legacy::FunctionPassManager *FPM = unwrap<legacy::FunctionPassManager>(PM);
657 Builder->populateFunctionPassManager(*FPM);
661 LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB,
662 LLVMPassManagerRef PM) {
663 PassManagerBuilder *Builder = unwrap(PMB);
664 legacy::PassManagerBase *MPM = unwrap(PM);
665 Builder->populateModulePassManager(*MPM);
668 void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB,
669 LLVMPassManagerRef PM,
670 LLVMBool Internalize,
671 LLVMBool RunInliner) {
672 PassManagerBuilder *Builder = unwrap(PMB);
673 legacy::PassManagerBase *LPM = unwrap(PM);
675 // A small backwards compatibility hack. populateLTOPassManager used to take
676 // an RunInliner option.
677 if (RunInliner && !Builder->Inliner)
678 Builder->Inliner = createFunctionInliningPass();
680 Builder->populateLTOPassManager(*LPM);