LLVM API Documentation

PassManagerBuilder.cpp
Go to the documentation of this file.
00001 //===- PassManagerBuilder.cpp - Build Standard Pass -----------------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines the PassManagerBuilder class, which is used to set up a
00011 // "standard" optimization sequence suitable for languages like C and C++.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 
00016 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
00017 #include "llvm-c/Transforms/PassManagerBuilder.h"
00018 #include "llvm/ADT/SmallVector.h"
00019 #include "llvm/Analysis/Passes.h"
00020 #include "llvm/IR/DataLayout.h"
00021 #include "llvm/IR/Verifier.h"
00022 #include "llvm/PassManager.h"
00023 #include "llvm/Support/CommandLine.h"
00024 #include "llvm/Support/ManagedStatic.h"
00025 #include "llvm/Target/TargetLibraryInfo.h"
00026 #include "llvm/Target/TargetMachine.h"
00027 #include "llvm/Target/TargetSubtargetInfo.h"
00028 #include "llvm/Transforms/IPO.h"
00029 #include "llvm/Transforms/Scalar.h"
00030 #include "llvm/Transforms/Vectorize.h"
00031 
00032 using namespace llvm;
00033 
00034 static cl::opt<bool>
00035 RunLoopVectorization("vectorize-loops", cl::Hidden,
00036                      cl::desc("Run the Loop vectorization passes"));
00037 
00038 static cl::opt<bool>
00039 RunSLPVectorization("vectorize-slp", cl::Hidden,
00040                     cl::desc("Run the SLP vectorization passes"));
00041 
00042 static cl::opt<bool>
00043 RunBBVectorization("vectorize-slp-aggressive", cl::Hidden,
00044                     cl::desc("Run the BB vectorization passes"));
00045 
00046 static cl::opt<bool>
00047 UseGVNAfterVectorization("use-gvn-after-vectorization",
00048   cl::init(false), cl::Hidden,
00049   cl::desc("Run GVN instead of Early CSE after vectorization passes"));
00050 
00051 static cl::opt<bool> ExtraVectorizerPasses(
00052     "extra-vectorizer-passes", cl::init(false), cl::Hidden,
00053     cl::desc("Run cleanup optimization passes after vectorization."));
00054 
00055 static cl::opt<bool> UseNewSROA("use-new-sroa",
00056   cl::init(true), cl::Hidden,
00057   cl::desc("Enable the new, experimental SROA pass"));
00058 
00059 static cl::opt<bool>
00060 RunLoopRerolling("reroll-loops", cl::Hidden,
00061                  cl::desc("Run the loop rerolling pass"));
00062 
00063 static cl::opt<bool> RunLoadCombine("combine-loads", cl::init(false),
00064                                     cl::Hidden,
00065                                     cl::desc("Run the load combining pass"));
00066 
00067 static cl::opt<bool>
00068 RunSLPAfterLoopVectorization("run-slp-after-loop-vectorization",
00069   cl::init(true), cl::Hidden,
00070   cl::desc("Run the SLP vectorizer (and BB vectorizer) after the Loop "
00071            "vectorizer instead of before"));
00072 
00073 static cl::opt<bool> UseCFLAA("use-cfl-aa",
00074   cl::init(false), cl::Hidden,
00075   cl::desc("Enable the new, experimental CFL alias analysis"));
00076 
00077 static cl::opt<bool>
00078 EnableMLSM("mlsm", cl::init(true), cl::Hidden,
00079            cl::desc("Enable motion of merged load and store"));
00080 
00081 PassManagerBuilder::PassManagerBuilder() {
00082     OptLevel = 2;
00083     SizeLevel = 0;
00084     LibraryInfo = nullptr;
00085     Inliner = nullptr;
00086     DisableTailCalls = false;
00087     DisableUnitAtATime = false;
00088     DisableUnrollLoops = false;
00089     BBVectorize = RunBBVectorization;
00090     SLPVectorize = RunSLPVectorization;
00091     LoopVectorize = RunLoopVectorization;
00092     RerollLoops = RunLoopRerolling;
00093     LoadCombine = RunLoadCombine;
00094     DisableGVNLoadPRE = false;
00095     VerifyInput = false;
00096     VerifyOutput = false;
00097     StripDebug = false;
00098     MergeFunctions = false;
00099 }
00100 
00101 PassManagerBuilder::~PassManagerBuilder() {
00102   delete LibraryInfo;
00103   delete Inliner;
00104 }
00105 
00106 /// Set of global extensions, automatically added as part of the standard set.
00107 static ManagedStatic<SmallVector<std::pair<PassManagerBuilder::ExtensionPointTy,
00108    PassManagerBuilder::ExtensionFn>, 8> > GlobalExtensions;
00109 
00110 void PassManagerBuilder::addGlobalExtension(
00111     PassManagerBuilder::ExtensionPointTy Ty,
00112     PassManagerBuilder::ExtensionFn Fn) {
00113   GlobalExtensions->push_back(std::make_pair(Ty, Fn));
00114 }
00115 
00116 void PassManagerBuilder::addExtension(ExtensionPointTy Ty, ExtensionFn Fn) {
00117   Extensions.push_back(std::make_pair(Ty, Fn));
00118 }
00119 
00120 void PassManagerBuilder::addExtensionsToPM(ExtensionPointTy ETy,
00121                                            PassManagerBase &PM) const {
00122   for (unsigned i = 0, e = GlobalExtensions->size(); i != e; ++i)
00123     if ((*GlobalExtensions)[i].first == ETy)
00124       (*GlobalExtensions)[i].second(*this, PM);
00125   for (unsigned i = 0, e = Extensions.size(); i != e; ++i)
00126     if (Extensions[i].first == ETy)
00127       Extensions[i].second(*this, PM);
00128 }
00129 
00130 void
00131 PassManagerBuilder::addInitialAliasAnalysisPasses(PassManagerBase &PM) const {
00132   // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that
00133   // BasicAliasAnalysis wins if they disagree. This is intended to help
00134   // support "obvious" type-punning idioms.
00135   if (UseCFLAA)
00136     PM.add(createCFLAliasAnalysisPass());
00137   PM.add(createTypeBasedAliasAnalysisPass());
00138   PM.add(createScopedNoAliasAAPass());
00139   PM.add(createBasicAliasAnalysisPass());
00140 }
00141 
00142 void PassManagerBuilder::populateFunctionPassManager(FunctionPassManager &FPM) {
00143   addExtensionsToPM(EP_EarlyAsPossible, FPM);
00144 
00145   // Add LibraryInfo if we have some.
00146   if (LibraryInfo) FPM.add(new TargetLibraryInfo(*LibraryInfo));
00147 
00148   if (OptLevel == 0) return;
00149 
00150   addInitialAliasAnalysisPasses(FPM);
00151 
00152   FPM.add(createCFGSimplificationPass());
00153   if (UseNewSROA)
00154     FPM.add(createSROAPass());
00155   else
00156     FPM.add(createScalarReplAggregatesPass());
00157   FPM.add(createEarlyCSEPass());
00158   FPM.add(createLowerExpectIntrinsicPass());
00159 }
00160 
00161 void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
00162   // If all optimizations are disabled, just run the always-inline pass.
00163   if (OptLevel == 0) {
00164     if (Inliner) {
00165       MPM.add(Inliner);
00166       Inliner = nullptr;
00167     }
00168 
00169     // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
00170     // pass manager, but we don't want to add extensions into that pass manager.
00171     // To prevent this we must insert a no-op module pass to reset the pass
00172     // manager to get the same behavior as EP_OptimizerLast in non-O0 builds.
00173     if (!GlobalExtensions->empty() || !Extensions.empty())
00174       MPM.add(createBarrierNoopPass());
00175 
00176     addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
00177     return;
00178   }
00179 
00180   // Add LibraryInfo if we have some.
00181   if (LibraryInfo) MPM.add(new TargetLibraryInfo(*LibraryInfo));
00182 
00183   addInitialAliasAnalysisPasses(MPM);
00184 
00185   if (!DisableUnitAtATime) {
00186     addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
00187 
00188     MPM.add(createIPSCCPPass());              // IP SCCP
00189     MPM.add(createGlobalOptimizerPass());     // Optimize out global vars
00190 
00191     MPM.add(createDeadArgEliminationPass());  // Dead argument elimination
00192 
00193     MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE
00194     addExtensionsToPM(EP_Peephole, MPM);
00195     MPM.add(createCFGSimplificationPass());   // Clean up after IPCP & DAE
00196   }
00197 
00198   // Start of CallGraph SCC passes.
00199   if (!DisableUnitAtATime)
00200     MPM.add(createPruneEHPass());             // Remove dead EH info
00201   if (Inliner) {
00202     MPM.add(Inliner);
00203     Inliner = nullptr;
00204   }
00205   if (!DisableUnitAtATime)
00206     MPM.add(createFunctionAttrsPass());       // Set readonly/readnone attrs
00207   if (OptLevel > 2)
00208     MPM.add(createArgumentPromotionPass());   // Scalarize uninlined fn args
00209 
00210   // Start of function pass.
00211   // Break up aggregate allocas, using SSAUpdater.
00212   if (UseNewSROA)
00213     MPM.add(createSROAPass(/*RequiresDomTree*/ false));
00214   else
00215     MPM.add(createScalarReplAggregatesPass(-1, false));
00216   MPM.add(createEarlyCSEPass());              // Catch trivial redundancies
00217   MPM.add(createJumpThreadingPass());         // Thread jumps.
00218   MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals
00219   MPM.add(createCFGSimplificationPass());     // Merge & remove BBs
00220   MPM.add(createInstructionCombiningPass());  // Combine silly seq's
00221   addExtensionsToPM(EP_Peephole, MPM);
00222 
00223   if (!DisableTailCalls)
00224     MPM.add(createTailCallEliminationPass()); // Eliminate tail calls
00225   MPM.add(createCFGSimplificationPass());     // Merge & remove BBs
00226   MPM.add(createReassociatePass());           // Reassociate expressions
00227   MPM.add(createLoopRotatePass());            // Rotate Loop
00228   MPM.add(createLICMPass());                  // Hoist loop invariants
00229   MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3));
00230   MPM.add(createInstructionCombiningPass());
00231   MPM.add(createIndVarSimplifyPass());        // Canonicalize indvars
00232   MPM.add(createLoopIdiomPass());             // Recognize idioms like memset.
00233   MPM.add(createLoopDeletionPass());          // Delete dead loops
00234 
00235   if (!DisableUnrollLoops)
00236     MPM.add(createSimpleLoopUnrollPass());    // Unroll small loops
00237   addExtensionsToPM(EP_LoopOptimizerEnd, MPM);
00238 
00239   if (OptLevel > 1) {
00240     if (EnableMLSM)
00241       MPM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds
00242     MPM.add(createGVNPass(DisableGVNLoadPRE));  // Remove redundancies
00243   }
00244   MPM.add(createMemCpyOptPass());             // Remove memcpy / form memset
00245   MPM.add(createSCCPPass());                  // Constant prop with SCCP
00246 
00247   // Run instcombine after redundancy elimination to exploit opportunities
00248   // opened up by them.
00249   MPM.add(createInstructionCombiningPass());
00250   addExtensionsToPM(EP_Peephole, MPM);
00251   MPM.add(createJumpThreadingPass());         // Thread jumps
00252   MPM.add(createCorrelatedValuePropagationPass());
00253   MPM.add(createDeadStoreEliminationPass());  // Delete dead stores
00254 
00255   addExtensionsToPM(EP_ScalarOptimizerLate, MPM);
00256 
00257   if (RerollLoops)
00258     MPM.add(createLoopRerollPass());
00259   if (!RunSLPAfterLoopVectorization) {
00260     if (SLPVectorize)
00261       MPM.add(createSLPVectorizerPass());   // Vectorize parallel scalar chains.
00262 
00263     if (BBVectorize) {
00264       MPM.add(createBBVectorizePass());
00265       MPM.add(createInstructionCombiningPass());
00266       addExtensionsToPM(EP_Peephole, MPM);
00267       if (OptLevel > 1 && UseGVNAfterVectorization)
00268         MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
00269       else
00270         MPM.add(createEarlyCSEPass());      // Catch trivial redundancies
00271 
00272       // BBVectorize may have significantly shortened a loop body; unroll again.
00273       if (!DisableUnrollLoops)
00274         MPM.add(createLoopUnrollPass());
00275     }
00276   }
00277 
00278   if (LoadCombine)
00279     MPM.add(createLoadCombinePass());
00280 
00281   MPM.add(createAggressiveDCEPass());         // Delete dead instructions
00282   MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
00283   MPM.add(createInstructionCombiningPass());  // Clean up after everything.
00284   addExtensionsToPM(EP_Peephole, MPM);
00285 
00286   // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
00287   // pass manager that we are specifically trying to avoid. To prevent this
00288   // we must insert a no-op module pass to reset the pass manager.
00289   MPM.add(createBarrierNoopPass());
00290 
00291   // Re-rotate loops in all our loop nests. These may have fallout out of
00292   // rotated form due to GVN or other transformations, and the vectorizer relies
00293   // on the rotated form.
00294   if (ExtraVectorizerPasses)
00295     MPM.add(createLoopRotatePass());
00296 
00297   MPM.add(createLoopVectorizePass(DisableUnrollLoops, LoopVectorize));
00298   // FIXME: Because of #pragma vectorize enable, the passes below are always
00299   // inserted in the pipeline, even when the vectorizer doesn't run (ex. when
00300   // on -O1 and no #pragma is found). Would be good to have these two passes
00301   // as function calls, so that we can only pass them when the vectorizer
00302   // changed the code.
00303   MPM.add(createInstructionCombiningPass());
00304   if (OptLevel > 1 && ExtraVectorizerPasses) {
00305     // At higher optimization levels, try to clean up any runtime overlap and
00306     // alignment checks inserted by the vectorizer. We want to track correllated
00307     // runtime checks for two inner loops in the same outer loop, fold any
00308     // common computations, hoist loop-invariant aspects out of any outer loop,
00309     // and unswitch the runtime checks if possible. Once hoisted, we may have
00310     // dead (or speculatable) control flows or more combining opportunities.
00311     MPM.add(createEarlyCSEPass());
00312     MPM.add(createCorrelatedValuePropagationPass());
00313     MPM.add(createInstructionCombiningPass());
00314     MPM.add(createLICMPass());
00315     MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3));
00316     MPM.add(createCFGSimplificationPass());
00317     MPM.add(createInstructionCombiningPass());
00318   }
00319 
00320   if (RunSLPAfterLoopVectorization) {
00321     if (SLPVectorize) {
00322       MPM.add(createSLPVectorizerPass());   // Vectorize parallel scalar chains.
00323       if (OptLevel > 1 && ExtraVectorizerPasses) {
00324         MPM.add(createEarlyCSEPass());
00325       }
00326     }
00327 
00328     if (BBVectorize) {
00329       MPM.add(createBBVectorizePass());
00330       MPM.add(createInstructionCombiningPass());
00331       addExtensionsToPM(EP_Peephole, MPM);
00332       if (OptLevel > 1 && UseGVNAfterVectorization)
00333         MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
00334       else
00335         MPM.add(createEarlyCSEPass());      // Catch trivial redundancies
00336 
00337       // BBVectorize may have significantly shortened a loop body; unroll again.
00338       if (!DisableUnrollLoops)
00339         MPM.add(createLoopUnrollPass());
00340     }
00341   }
00342 
00343   addExtensionsToPM(EP_Peephole, MPM);
00344   MPM.add(createCFGSimplificationPass());
00345   MPM.add(createInstructionCombiningPass());
00346 
00347   if (!DisableUnrollLoops)
00348     MPM.add(createLoopUnrollPass());    // Unroll small loops
00349 
00350   // After vectorization and unrolling, assume intrinsics may tell us more
00351   // about pointer alignments.
00352   MPM.add(createAlignmentFromAssumptionsPass());
00353 
00354   if (!DisableUnitAtATime) {
00355     // FIXME: We shouldn't bother with this anymore.
00356     MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
00357 
00358     // GlobalOpt already deletes dead functions and globals, at -O2 try a
00359     // late pass of GlobalDCE.  It is capable of deleting dead cycles.
00360     if (OptLevel > 1) {
00361       MPM.add(createGlobalDCEPass());         // Remove dead fns and globals.
00362       MPM.add(createConstantMergePass());     // Merge dup global constants
00363     }
00364   }
00365 
00366   if (MergeFunctions)
00367     MPM.add(createMergeFunctionsPass());
00368 
00369   addExtensionsToPM(EP_OptimizerLast, MPM);
00370 }
00371 
00372 void PassManagerBuilder::addLTOOptimizationPasses(PassManagerBase &PM) {
00373   // Provide AliasAnalysis services for optimizations.
00374   addInitialAliasAnalysisPasses(PM);
00375 
00376   // Propagate constants at call sites into the functions they call.  This
00377   // opens opportunities for globalopt (and inlining) by substituting function
00378   // pointers passed as arguments to direct uses of functions.
00379   PM.add(createIPSCCPPass());
00380 
00381   // Now that we internalized some globals, see if we can hack on them!
00382   PM.add(createGlobalOptimizerPass());
00383 
00384   // Linking modules together can lead to duplicated global constants, only
00385   // keep one copy of each constant.
00386   PM.add(createConstantMergePass());
00387 
00388   // Remove unused arguments from functions.
00389   PM.add(createDeadArgEliminationPass());
00390 
00391   // Reduce the code after globalopt and ipsccp.  Both can open up significant
00392   // simplification opportunities, and both can propagate functions through
00393   // function pointers.  When this happens, we often have to resolve varargs
00394   // calls, etc, so let instcombine do this.
00395   PM.add(createInstructionCombiningPass());
00396   addExtensionsToPM(EP_Peephole, PM);
00397 
00398   // Inline small functions
00399   bool RunInliner = Inliner;
00400   if (RunInliner) {
00401     PM.add(Inliner);
00402     Inliner = nullptr;
00403   }
00404 
00405   PM.add(createPruneEHPass());   // Remove dead EH info.
00406 
00407   // Optimize globals again if we ran the inliner.
00408   if (RunInliner)
00409     PM.add(createGlobalOptimizerPass());
00410   PM.add(createGlobalDCEPass()); // Remove dead functions.
00411 
00412   // If we didn't decide to inline a function, check to see if we can
00413   // transform it to pass arguments by value instead of by reference.
00414   PM.add(createArgumentPromotionPass());
00415 
00416   // The IPO passes may leave cruft around.  Clean up after them.
00417   PM.add(createInstructionCombiningPass());
00418   addExtensionsToPM(EP_Peephole, PM);
00419   PM.add(createJumpThreadingPass());
00420 
00421   // Break up allocas
00422   if (UseNewSROA)
00423     PM.add(createSROAPass());
00424   else
00425     PM.add(createScalarReplAggregatesPass());
00426 
00427   // Run a few AA driven optimizations here and now, to cleanup the code.
00428   PM.add(createFunctionAttrsPass()); // Add nocapture.
00429   PM.add(createGlobalsModRefPass()); // IP alias analysis.
00430 
00431   PM.add(createLICMPass());                 // Hoist loop invariants.
00432   if (EnableMLSM)
00433     PM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds.
00434   PM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies.
00435   PM.add(createMemCpyOptPass());            // Remove dead memcpys.
00436 
00437   // Nuke dead stores.
00438   PM.add(createDeadStoreEliminationPass());
00439 
00440   // More loops are countable; try to optimize them.
00441   PM.add(createIndVarSimplifyPass());
00442   PM.add(createLoopDeletionPass());
00443   PM.add(createLoopVectorizePass(true, true));
00444 
00445   // More scalar chains could be vectorized due to more alias information
00446   PM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
00447 
00448   // After vectorization, assume intrinsics may tell us more about pointer
00449   // alignments.
00450   PM.add(createAlignmentFromAssumptionsPass());
00451 
00452   if (LoadCombine)
00453     PM.add(createLoadCombinePass());
00454 
00455   // Cleanup and simplify the code after the scalar optimizations.
00456   PM.add(createInstructionCombiningPass());
00457   addExtensionsToPM(EP_Peephole, PM);
00458 
00459   PM.add(createJumpThreadingPass());
00460 
00461   // Delete basic blocks, which optimization passes may have killed.
00462   PM.add(createCFGSimplificationPass());
00463 
00464   // Now that we have optimized the program, discard unreachable functions.
00465   PM.add(createGlobalDCEPass());
00466 
00467   // FIXME: this is profitable (for compiler time) to do at -O0 too, but
00468   // currently it damages debug info.
00469   if (MergeFunctions)
00470     PM.add(createMergeFunctionsPass());
00471 }
00472 
00473 void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM,
00474                                                 TargetMachine *TM) {
00475   if (TM) {
00476     PM.add(new DataLayoutPass());
00477     TM->addAnalysisPasses(PM);
00478   }
00479 
00480   if (LibraryInfo)
00481     PM.add(new TargetLibraryInfo(*LibraryInfo));
00482 
00483   if (VerifyInput)
00484     PM.add(createVerifierPass());
00485 
00486   if (StripDebug)
00487     PM.add(createStripSymbolsPass(true));
00488 
00489   if (VerifyInput)
00490     PM.add(createDebugInfoVerifierPass());
00491 
00492   if (OptLevel != 0)
00493     addLTOOptimizationPasses(PM);
00494 
00495   if (VerifyOutput) {
00496     PM.add(createVerifierPass());
00497     PM.add(createDebugInfoVerifierPass());
00498   }
00499 }
00500 
00501 inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {
00502     return reinterpret_cast<PassManagerBuilder*>(P);
00503 }
00504 
00505 inline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) {
00506   return reinterpret_cast<LLVMPassManagerBuilderRef>(P);
00507 }
00508 
00509 LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate() {
00510   PassManagerBuilder *PMB = new PassManagerBuilder();
00511   return wrap(PMB);
00512 }
00513 
00514 void LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB) {
00515   PassManagerBuilder *Builder = unwrap(PMB);
00516   delete Builder;
00517 }
00518 
00519 void
00520 LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB,
00521                                   unsigned OptLevel) {
00522   PassManagerBuilder *Builder = unwrap(PMB);
00523   Builder->OptLevel = OptLevel;
00524 }
00525 
00526 void
00527 LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB,
00528                                    unsigned SizeLevel) {
00529   PassManagerBuilder *Builder = unwrap(PMB);
00530   Builder->SizeLevel = SizeLevel;
00531 }
00532 
00533 void
00534 LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB,
00535                                             LLVMBool Value) {
00536   PassManagerBuilder *Builder = unwrap(PMB);
00537   Builder->DisableUnitAtATime = Value;
00538 }
00539 
00540 void
00541 LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB,
00542                                             LLVMBool Value) {
00543   PassManagerBuilder *Builder = unwrap(PMB);
00544   Builder->DisableUnrollLoops = Value;
00545 }
00546 
00547 void
00548 LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB,
00549                                                  LLVMBool Value) {
00550   // NOTE: The simplify-libcalls pass has been removed.
00551 }
00552 
00553 void
00554 LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB,
00555                                               unsigned Threshold) {
00556   PassManagerBuilder *Builder = unwrap(PMB);
00557   Builder->Inliner = createFunctionInliningPass(Threshold);
00558 }
00559 
00560 void
00561 LLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB,
00562                                                   LLVMPassManagerRef PM) {
00563   PassManagerBuilder *Builder = unwrap(PMB);
00564   FunctionPassManager *FPM = unwrap<FunctionPassManager>(PM);
00565   Builder->populateFunctionPassManager(*FPM);
00566 }
00567 
00568 void
00569 LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB,
00570                                                 LLVMPassManagerRef PM) {
00571   PassManagerBuilder *Builder = unwrap(PMB);
00572   PassManagerBase *MPM = unwrap(PM);
00573   Builder->populateModulePassManager(*MPM);
00574 }
00575 
00576 void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB,
00577                                                   LLVMPassManagerRef PM,
00578                                                   LLVMBool Internalize,
00579                                                   LLVMBool RunInliner) {
00580   PassManagerBuilder *Builder = unwrap(PMB);
00581   PassManagerBase *LPM = unwrap(PM);
00582 
00583   // A small backwards compatibility hack. populateLTOPassManager used to take
00584   // an RunInliner option.
00585   if (RunInliner && !Builder->Inliner)
00586     Builder->Inliner = createFunctionInliningPass();
00587 
00588   Builder->populateLTOPassManager(*LPM);
00589 }