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/TargetLibraryInfo.h"
26 #include "llvm/Target/TargetMachine.h"
27 #include "llvm/Transforms/IPO.h"
28 #include "llvm/Transforms/Scalar.h"
29 #include "llvm/Transforms/Vectorize.h"
34 RunLoopVectorization("vectorize-loops", cl::Hidden,
35 cl::desc("Run the Loop vectorization passes"));
38 RunSLPVectorization("vectorize-slp", cl::Hidden,
39 cl::desc("Run the SLP vectorization passes"));
42 RunBBVectorization("vectorize-slp-aggressive", cl::Hidden,
43 cl::desc("Run the BB vectorization passes"));
46 UseGVNAfterVectorization("use-gvn-after-vectorization",
47 cl::init(false), cl::Hidden,
48 cl::desc("Run GVN instead of Early CSE after vectorization passes"));
50 static cl::opt<bool> ExtraVectorizerPasses(
51 "extra-vectorizer-passes", cl::init(false), cl::Hidden,
52 cl::desc("Run cleanup optimization passes after vectorization."));
54 static cl::opt<bool> UseNewSROA("use-new-sroa",
55 cl::init(true), cl::Hidden,
56 cl::desc("Enable the new, experimental SROA pass"));
59 RunLoopRerolling("reroll-loops", cl::Hidden,
60 cl::desc("Run the loop rerolling pass"));
63 RunFloat2Int("float-to-int", cl::Hidden, cl::init(true),
64 cl::desc("Run the float2int (float demotion) pass"));
66 static cl::opt<bool> RunLoadCombine("combine-loads", cl::init(false),
68 cl::desc("Run the load combining pass"));
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"));
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"));
81 EnableMLSM("mlsm", cl::init(true), cl::Hidden,
82 cl::desc("Enable motion of merged load and store"));
84 static cl::opt<bool> EnableLoopInterchange(
85 "enable-loopinterchange", cl::init(false), cl::Hidden,
86 cl::desc("Enable the new, experimental LoopInterchange Pass"));
88 static cl::opt<bool> EnableLoopDistribute(
89 "enable-loop-distribute", cl::init(false), cl::Hidden,
90 cl::desc("Enable the new, experimental LoopDistribution Pass"));
92 static cl::opt<bool> EnableNonLTOGlobalsModRef(
93 "enable-non-lto-gmr", cl::init(false), cl::Hidden,
95 "Enable the GlobalsModRef AliasAnalysis outside of the LTO pipeline."));
97 PassManagerBuilder::PassManagerBuilder() {
100 LibraryInfo = nullptr;
102 DisableUnitAtATime = false;
103 DisableUnrollLoops = false;
104 BBVectorize = RunBBVectorization;
105 SLPVectorize = RunSLPVectorization;
106 LoopVectorize = RunLoopVectorization;
107 RerollLoops = RunLoopRerolling;
108 LoadCombine = RunLoadCombine;
109 DisableGVNLoadPRE = false;
111 VerifyOutput = false;
112 MergeFunctions = false;
113 PrepareForLTO = false;
116 PassManagerBuilder::~PassManagerBuilder() {
121 /// Set of global extensions, automatically added as part of the standard set.
122 static ManagedStatic<SmallVector<std::pair<PassManagerBuilder::ExtensionPointTy,
123 PassManagerBuilder::ExtensionFn>, 8> > GlobalExtensions;
125 void PassManagerBuilder::addGlobalExtension(
126 PassManagerBuilder::ExtensionPointTy Ty,
127 PassManagerBuilder::ExtensionFn Fn) {
128 GlobalExtensions->push_back(std::make_pair(Ty, Fn));
131 void PassManagerBuilder::addExtension(ExtensionPointTy Ty, ExtensionFn Fn) {
132 Extensions.push_back(std::make_pair(Ty, Fn));
135 void PassManagerBuilder::addExtensionsToPM(ExtensionPointTy ETy,
136 legacy::PassManagerBase &PM) const {
137 for (unsigned i = 0, e = GlobalExtensions->size(); i != e; ++i)
138 if ((*GlobalExtensions)[i].first == ETy)
139 (*GlobalExtensions)[i].second(*this, PM);
140 for (unsigned i = 0, e = Extensions.size(); i != e; ++i)
141 if (Extensions[i].first == ETy)
142 Extensions[i].second(*this, PM);
145 void PassManagerBuilder::addInitialAliasAnalysisPasses(
146 legacy::PassManagerBase &PM) const {
147 // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that
148 // BasicAliasAnalysis wins if they disagree. This is intended to help
149 // support "obvious" type-punning idioms.
151 PM.add(createCFLAliasAnalysisPass());
152 PM.add(createTypeBasedAliasAnalysisPass());
153 PM.add(createScopedNoAliasAAPass());
154 PM.add(createBasicAliasAnalysisPass());
157 void PassManagerBuilder::populateFunctionPassManager(
158 legacy::FunctionPassManager &FPM) {
159 addExtensionsToPM(EP_EarlyAsPossible, FPM);
161 // Add LibraryInfo if we have some.
163 FPM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
165 if (OptLevel == 0) return;
167 addInitialAliasAnalysisPasses(FPM);
169 FPM.add(createCFGSimplificationPass());
171 FPM.add(createSROAPass());
173 FPM.add(createScalarReplAggregatesPass());
174 FPM.add(createEarlyCSEPass());
175 FPM.add(createLowerExpectIntrinsicPass());
178 void PassManagerBuilder::populateModulePassManager(
179 legacy::PassManagerBase &MPM) {
180 // If all optimizations are disabled, just run the always-inline pass and,
181 // if enabled, the function merging pass.
188 // FIXME: The BarrierNoopPass is a HACK! The inliner pass above implicitly
189 // creates a CGSCC pass manager, but we don't want to add extensions into
190 // that pass manager. To prevent this we insert a no-op module pass to reset
191 // the pass manager to get the same behavior as EP_OptimizerLast in non-O0
192 // builds. The function merging pass is
194 MPM.add(createMergeFunctionsPass());
195 else if (!GlobalExtensions->empty() || !Extensions.empty())
196 MPM.add(createBarrierNoopPass());
198 addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
202 // Add LibraryInfo if we have some.
204 MPM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
206 addInitialAliasAnalysisPasses(MPM);
208 if (!DisableUnitAtATime) {
209 addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
211 MPM.add(createIPSCCPPass()); // IP SCCP
212 MPM.add(createGlobalOptimizerPass()); // Optimize out global vars
214 MPM.add(createDeadArgEliminationPass()); // Dead argument elimination
216 MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE
217 addExtensionsToPM(EP_Peephole, MPM);
218 MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
221 if (EnableNonLTOGlobalsModRef)
222 // We add a module alias analysis pass here. In part due to bugs in the
223 // analysis infrastructure this "works" in that the analysis stays alive
224 // for the entire SCC pass run below.
225 MPM.add(createGlobalsModRefPass());
227 // Start of CallGraph SCC passes.
228 if (!DisableUnitAtATime)
229 MPM.add(createPruneEHPass()); // Remove dead EH info
234 if (!DisableUnitAtATime)
235 MPM.add(createFunctionAttrsPass()); // Set readonly/readnone attrs
237 MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args
239 // Start of function pass.
240 // Break up aggregate allocas, using SSAUpdater.
242 MPM.add(createSROAPass(/*RequiresDomTree*/ false));
244 MPM.add(createScalarReplAggregatesPass(-1, false));
245 MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
246 MPM.add(createJumpThreadingPass()); // Thread jumps.
247 MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals
248 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
249 MPM.add(createInstructionCombiningPass()); // Combine silly seq's
250 addExtensionsToPM(EP_Peephole, MPM);
252 MPM.add(createTailCallEliminationPass()); // Eliminate tail calls
253 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
254 MPM.add(createReassociatePass()); // Reassociate expressions
255 // Rotate Loop - disable header duplication at -Oz
256 MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));
257 MPM.add(createLICMPass()); // Hoist loop invariants
258 MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3));
259 MPM.add(createInstructionCombiningPass());
260 MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
261 MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
262 MPM.add(createLoopDeletionPass()); // Delete dead loops
263 if (EnableLoopInterchange) {
264 MPM.add(createLoopInterchangePass()); // Interchange loops
265 MPM.add(createCFGSimplificationPass());
267 if (!DisableUnrollLoops)
268 MPM.add(createSimpleLoopUnrollPass()); // Unroll small loops
269 addExtensionsToPM(EP_LoopOptimizerEnd, MPM);
273 MPM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds
274 MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
276 MPM.add(createMemCpyOptPass()); // Remove memcpy / form memset
277 MPM.add(createSCCPPass()); // Constant prop with SCCP
279 // Delete dead bit computations (instcombine runs after to fold away the dead
280 // computations, and then ADCE will run later to exploit any new DCE
281 // opportunities that creates).
282 MPM.add(createBitTrackingDCEPass()); // Delete dead bit computations
284 // Run instcombine after redundancy elimination to exploit opportunities
285 // opened up by them.
286 MPM.add(createInstructionCombiningPass());
287 addExtensionsToPM(EP_Peephole, MPM);
288 MPM.add(createJumpThreadingPass()); // Thread jumps
289 MPM.add(createCorrelatedValuePropagationPass());
290 MPM.add(createDeadStoreEliminationPass()); // Delete dead stores
291 MPM.add(createLICMPass());
293 addExtensionsToPM(EP_ScalarOptimizerLate, MPM);
296 MPM.add(createLoopRerollPass());
297 if (!RunSLPAfterLoopVectorization) {
299 MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
302 MPM.add(createBBVectorizePass());
303 MPM.add(createInstructionCombiningPass());
304 addExtensionsToPM(EP_Peephole, MPM);
305 if (OptLevel > 1 && UseGVNAfterVectorization)
306 MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
308 MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
310 // BBVectorize may have significantly shortened a loop body; unroll again.
311 if (!DisableUnrollLoops)
312 MPM.add(createLoopUnrollPass());
317 MPM.add(createLoadCombinePass());
319 MPM.add(createAggressiveDCEPass()); // Delete dead instructions
320 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
321 MPM.add(createInstructionCombiningPass()); // Clean up after everything.
322 addExtensionsToPM(EP_Peephole, MPM);
324 // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
325 // pass manager that we are specifically trying to avoid. To prevent this
326 // we must insert a no-op module pass to reset the pass manager.
327 MPM.add(createBarrierNoopPass());
329 if (EnableNonLTOGlobalsModRef)
330 // We add a fresh GlobalsModRef run at this point. This is particularly
331 // useful as the above will have inlined, DCE'ed, and function-attr
332 // propagated everything. We should at this point have a reasonably minimal
333 // and richly annotated call graph. By computing aliasing and mod/ref
334 // information for all local globals here, the late loop passes and notably
335 // the vectorizer will be able to use them to help recognize vectorizable
336 // memory operations.
338 // Note that this relies on a bug in the pass manager which preserves
339 // a module analysis into a function pass pipeline (and throughout it) so
340 // long as the first function pass doesn't invalidate the module analysis.
341 // Thus both Float2Int and LoopRotate have to preserve AliasAnalysis for
342 // this to work. Fortunately, it is trivial to preserve AliasAnalysis
343 // (doing nothing preserves it as it is required to be conservatively
344 // correct in the face of IR changes).
345 MPM.add(createGlobalsModRefPass());
348 MPM.add(createFloat2IntPass());
350 addExtensionsToPM(EP_VectorizerStart, MPM);
352 // Re-rotate loops in all our loop nests. These may have fallout out of
353 // rotated form due to GVN or other transformations, and the vectorizer relies
354 // on the rotated form. Disable header duplication at -Oz.
355 MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));
357 // Distribute loops to allow partial vectorization. I.e. isolate dependences
358 // into separate loop that would otherwise inhibit vectorization.
359 if (EnableLoopDistribute)
360 MPM.add(createLoopDistributePass());
362 MPM.add(createLoopVectorizePass(DisableUnrollLoops, LoopVectorize));
363 // FIXME: Because of #pragma vectorize enable, the passes below are always
364 // inserted in the pipeline, even when the vectorizer doesn't run (ex. when
365 // on -O1 and no #pragma is found). Would be good to have these two passes
366 // as function calls, so that we can only pass them when the vectorizer
368 MPM.add(createInstructionCombiningPass());
369 if (OptLevel > 1 && ExtraVectorizerPasses) {
370 // At higher optimization levels, try to clean up any runtime overlap and
371 // alignment checks inserted by the vectorizer. We want to track correllated
372 // runtime checks for two inner loops in the same outer loop, fold any
373 // common computations, hoist loop-invariant aspects out of any outer loop,
374 // and unswitch the runtime checks if possible. Once hoisted, we may have
375 // dead (or speculatable) control flows or more combining opportunities.
376 MPM.add(createEarlyCSEPass());
377 MPM.add(createCorrelatedValuePropagationPass());
378 MPM.add(createInstructionCombiningPass());
379 MPM.add(createLICMPass());
380 MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3));
381 MPM.add(createCFGSimplificationPass());
382 MPM.add(createInstructionCombiningPass());
385 if (RunSLPAfterLoopVectorization) {
387 MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
388 if (OptLevel > 1 && ExtraVectorizerPasses) {
389 MPM.add(createEarlyCSEPass());
394 MPM.add(createBBVectorizePass());
395 MPM.add(createInstructionCombiningPass());
396 addExtensionsToPM(EP_Peephole, MPM);
397 if (OptLevel > 1 && UseGVNAfterVectorization)
398 MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
400 MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
402 // BBVectorize may have significantly shortened a loop body; unroll again.
403 if (!DisableUnrollLoops)
404 MPM.add(createLoopUnrollPass());
408 addExtensionsToPM(EP_Peephole, MPM);
409 MPM.add(createCFGSimplificationPass());
410 MPM.add(createInstructionCombiningPass());
412 if (!DisableUnrollLoops) {
413 MPM.add(createLoopUnrollPass()); // Unroll small loops
415 // LoopUnroll may generate some redundency to cleanup.
416 MPM.add(createInstructionCombiningPass());
418 // Runtime unrolling will introduce runtime check in loop prologue. If the
419 // unrolled loop is a inner loop, then the prologue will be inside the
420 // outer loop. LICM pass can help to promote the runtime check out if the
421 // checked value is loop invariant.
422 MPM.add(createLICMPass());
425 // After vectorization and unrolling, assume intrinsics may tell us more
426 // about pointer alignments.
427 MPM.add(createAlignmentFromAssumptionsPass());
429 if (!DisableUnitAtATime) {
430 // FIXME: We shouldn't bother with this anymore.
431 MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
433 // GlobalOpt already deletes dead functions and globals, at -O2 try a
434 // late pass of GlobalDCE. It is capable of deleting dead cycles.
436 if (!PrepareForLTO) {
437 // Remove avail extern fns and globals definitions if we aren't
438 // compiling an object file for later LTO. For LTO we want to preserve
439 // these so they are eligible for inlining at link-time. Note if they
440 // are unreferenced they will be removed by GlobalDCE below, so
441 // this only impacts referenced available externally globals.
442 // Eventually they will be suppressed during codegen, but eliminating
443 // here enables more opportunity for GlobalDCE as it may make
444 // globals referenced by available external functions dead.
445 MPM.add(createEliminateAvailableExternallyPass());
447 MPM.add(createGlobalDCEPass()); // Remove dead fns and globals.
448 MPM.add(createConstantMergePass()); // Merge dup global constants
453 MPM.add(createMergeFunctionsPass());
455 addExtensionsToPM(EP_OptimizerLast, MPM);
458 void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) {
459 // Provide AliasAnalysis services for optimizations.
460 addInitialAliasAnalysisPasses(PM);
462 // Propagate constants at call sites into the functions they call. This
463 // opens opportunities for globalopt (and inlining) by substituting function
464 // pointers passed as arguments to direct uses of functions.
465 PM.add(createIPSCCPPass());
467 // Now that we internalized some globals, see if we can hack on them!
468 PM.add(createGlobalOptimizerPass());
470 // Linking modules together can lead to duplicated global constants, only
471 // keep one copy of each constant.
472 PM.add(createConstantMergePass());
474 // Remove unused arguments from functions.
475 PM.add(createDeadArgEliminationPass());
477 // Reduce the code after globalopt and ipsccp. Both can open up significant
478 // simplification opportunities, and both can propagate functions through
479 // function pointers. When this happens, we often have to resolve varargs
480 // calls, etc, so let instcombine do this.
481 PM.add(createInstructionCombiningPass());
482 addExtensionsToPM(EP_Peephole, PM);
484 // Inline small functions
485 bool RunInliner = Inliner;
491 PM.add(createPruneEHPass()); // Remove dead EH info.
493 // Optimize globals again if we ran the inliner.
495 PM.add(createGlobalOptimizerPass());
496 PM.add(createGlobalDCEPass()); // Remove dead functions.
498 // If we didn't decide to inline a function, check to see if we can
499 // transform it to pass arguments by value instead of by reference.
500 PM.add(createArgumentPromotionPass());
502 // The IPO passes may leave cruft around. Clean up after them.
503 PM.add(createInstructionCombiningPass());
504 addExtensionsToPM(EP_Peephole, PM);
505 PM.add(createJumpThreadingPass());
509 PM.add(createSROAPass());
511 PM.add(createScalarReplAggregatesPass());
513 // Run a few AA driven optimizations here and now, to cleanup the code.
514 PM.add(createFunctionAttrsPass()); // Add nocapture.
515 PM.add(createGlobalsModRefPass()); // IP alias analysis.
517 PM.add(createLICMPass()); // Hoist loop invariants.
519 PM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds.
520 PM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies.
521 PM.add(createMemCpyOptPass()); // Remove dead memcpys.
524 PM.add(createDeadStoreEliminationPass());
526 // More loops are countable; try to optimize them.
527 PM.add(createIndVarSimplifyPass());
528 PM.add(createLoopDeletionPass());
529 if (EnableLoopInterchange)
530 PM.add(createLoopInterchangePass());
532 PM.add(createLoopVectorizePass(true, LoopVectorize));
534 // More scalar chains could be vectorized due to more alias information
535 if (RunSLPAfterLoopVectorization)
537 PM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
539 // After vectorization, assume intrinsics may tell us more about pointer
541 PM.add(createAlignmentFromAssumptionsPass());
544 PM.add(createLoadCombinePass());
546 // Cleanup and simplify the code after the scalar optimizations.
547 PM.add(createInstructionCombiningPass());
548 addExtensionsToPM(EP_Peephole, PM);
550 PM.add(createJumpThreadingPass());
553 void PassManagerBuilder::addLateLTOOptimizationPasses(
554 legacy::PassManagerBase &PM) {
555 // Delete basic blocks, which optimization passes may have killed.
556 PM.add(createCFGSimplificationPass());
558 // Now that we have optimized the program, discard unreachable functions.
559 PM.add(createGlobalDCEPass());
561 // FIXME: this is profitable (for compiler time) to do at -O0 too, but
562 // currently it damages debug info.
564 PM.add(createMergeFunctionsPass());
567 void PassManagerBuilder::populateLTOPassManager(legacy::PassManagerBase &PM) {
569 PM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
572 PM.add(createVerifierPass());
575 addLTOOptimizationPasses(PM);
577 // Lower bit sets to globals. This pass supports Clang's control flow
578 // integrity mechanisms (-fsanitize=cfi*) and needs to run at link time if CFI
579 // is enabled. The pass does nothing if CFI is disabled.
580 PM.add(createLowerBitSetsPass());
583 addLateLTOOptimizationPasses(PM);
586 PM.add(createVerifierPass());
589 inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {
590 return reinterpret_cast<PassManagerBuilder*>(P);
593 inline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) {
594 return reinterpret_cast<LLVMPassManagerBuilderRef>(P);
597 LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate() {
598 PassManagerBuilder *PMB = new PassManagerBuilder();
602 void LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB) {
603 PassManagerBuilder *Builder = unwrap(PMB);
608 LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB,
610 PassManagerBuilder *Builder = unwrap(PMB);
611 Builder->OptLevel = OptLevel;
615 LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB,
616 unsigned SizeLevel) {
617 PassManagerBuilder *Builder = unwrap(PMB);
618 Builder->SizeLevel = SizeLevel;
622 LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB,
624 PassManagerBuilder *Builder = unwrap(PMB);
625 Builder->DisableUnitAtATime = Value;
629 LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB,
631 PassManagerBuilder *Builder = unwrap(PMB);
632 Builder->DisableUnrollLoops = Value;
636 LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB,
638 // NOTE: The simplify-libcalls pass has been removed.
642 LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB,
643 unsigned Threshold) {
644 PassManagerBuilder *Builder = unwrap(PMB);
645 Builder->Inliner = createFunctionInliningPass(Threshold);
649 LLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB,
650 LLVMPassManagerRef PM) {
651 PassManagerBuilder *Builder = unwrap(PMB);
652 legacy::FunctionPassManager *FPM = unwrap<legacy::FunctionPassManager>(PM);
653 Builder->populateFunctionPassManager(*FPM);
657 LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB,
658 LLVMPassManagerRef PM) {
659 PassManagerBuilder *Builder = unwrap(PMB);
660 legacy::PassManagerBase *MPM = unwrap(PM);
661 Builder->populateModulePassManager(*MPM);
664 void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB,
665 LLVMPassManagerRef PM,
666 LLVMBool Internalize,
667 LLVMBool RunInliner) {
668 PassManagerBuilder *Builder = unwrap(PMB);
669 legacy::PassManagerBase *LPM = unwrap(PM);
671 // A small backwards compatibility hack. populateLTOPassManager used to take
672 // an RunInliner option.
673 if (RunInliner && !Builder->Inliner)
674 Builder->Inliner = createFunctionInliningPass();
676 Builder->populateLTOPassManager(*LPM);