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 and,
00163   // if enabled, the function merging pass.
00164   if (OptLevel == 0) {
00165     if (Inliner) {
00166       MPM.add(Inliner);
00167       Inliner = nullptr;
00168     }
00169 
00170     // FIXME: The BarrierNoopPass is a HACK! The inliner pass above implicitly
00171     // creates a CGSCC pass manager, but we don't want to add extensions into
00172     // that pass manager. To prevent this we insert a no-op module pass to reset
00173     // the pass manager to get the same behavior as EP_OptimizerLast in non-O0
00174     // builds. The function merging pass is 
00175     if (MergeFunctions)
00176       MPM.add(createMergeFunctionsPass());
00177     else if (!GlobalExtensions->empty() || !Extensions.empty())
00178       MPM.add(createBarrierNoopPass());
00179 
00180     addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
00181     return;
00182   }
00183 
00184   // Add LibraryInfo if we have some.
00185   if (LibraryInfo) MPM.add(new TargetLibraryInfo(*LibraryInfo));
00186 
00187   addInitialAliasAnalysisPasses(MPM);
00188 
00189   if (!DisableUnitAtATime) {
00190     addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
00191 
00192     MPM.add(createIPSCCPPass());              // IP SCCP
00193     MPM.add(createGlobalOptimizerPass());     // Optimize out global vars
00194 
00195     MPM.add(createDeadArgEliminationPass());  // Dead argument elimination
00196 
00197     MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE
00198     addExtensionsToPM(EP_Peephole, MPM);
00199     MPM.add(createCFGSimplificationPass());   // Clean up after IPCP & DAE
00200   }
00201 
00202   // Start of CallGraph SCC passes.
00203   if (!DisableUnitAtATime)
00204     MPM.add(createPruneEHPass());             // Remove dead EH info
00205   if (Inliner) {
00206     MPM.add(Inliner);
00207     Inliner = nullptr;
00208   }
00209   if (!DisableUnitAtATime)
00210     MPM.add(createFunctionAttrsPass());       // Set readonly/readnone attrs
00211   if (OptLevel > 2)
00212     MPM.add(createArgumentPromotionPass());   // Scalarize uninlined fn args
00213 
00214   // Start of function pass.
00215   // Break up aggregate allocas, using SSAUpdater.
00216   if (UseNewSROA)
00217     MPM.add(createSROAPass(/*RequiresDomTree*/ false));
00218   else
00219     MPM.add(createScalarReplAggregatesPass(-1, false));
00220   MPM.add(createEarlyCSEPass());              // Catch trivial redundancies
00221   MPM.add(createJumpThreadingPass());         // Thread jumps.
00222   MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals
00223   MPM.add(createCFGSimplificationPass());     // Merge & remove BBs
00224   MPM.add(createInstructionCombiningPass());  // Combine silly seq's
00225   addExtensionsToPM(EP_Peephole, MPM);
00226 
00227   if (!DisableTailCalls)
00228     MPM.add(createTailCallEliminationPass()); // Eliminate tail calls
00229   MPM.add(createCFGSimplificationPass());     // Merge & remove BBs
00230   MPM.add(createReassociatePass());           // Reassociate expressions
00231   // Rotate Loop - disable header duplication at -Oz
00232   MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));
00233   MPM.add(createLICMPass());                  // Hoist loop invariants
00234   MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3));
00235   MPM.add(createInstructionCombiningPass());
00236   MPM.add(createIndVarSimplifyPass());        // Canonicalize indvars
00237   MPM.add(createLoopIdiomPass());             // Recognize idioms like memset.
00238   MPM.add(createLoopDeletionPass());          // Delete dead loops
00239 
00240   if (!DisableUnrollLoops)
00241     MPM.add(createSimpleLoopUnrollPass());    // Unroll small loops
00242   addExtensionsToPM(EP_LoopOptimizerEnd, MPM);
00243 
00244   if (OptLevel > 1) {
00245     if (EnableMLSM)
00246       MPM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds
00247     MPM.add(createGVNPass(DisableGVNLoadPRE));  // Remove redundancies
00248   }
00249   MPM.add(createMemCpyOptPass());             // Remove memcpy / form memset
00250   MPM.add(createSCCPPass());                  // Constant prop with SCCP
00251 
00252   // Run instcombine after redundancy elimination to exploit opportunities
00253   // opened up by them.
00254   MPM.add(createInstructionCombiningPass());
00255   addExtensionsToPM(EP_Peephole, MPM);
00256   MPM.add(createJumpThreadingPass());         // Thread jumps
00257   MPM.add(createCorrelatedValuePropagationPass());
00258   MPM.add(createDeadStoreEliminationPass());  // Delete dead stores
00259 
00260   addExtensionsToPM(EP_ScalarOptimizerLate, MPM);
00261 
00262   if (RerollLoops)
00263     MPM.add(createLoopRerollPass());
00264   if (!RunSLPAfterLoopVectorization) {
00265     if (SLPVectorize)
00266       MPM.add(createSLPVectorizerPass());   // Vectorize parallel scalar chains.
00267 
00268     if (BBVectorize) {
00269       MPM.add(createBBVectorizePass());
00270       MPM.add(createInstructionCombiningPass());
00271       addExtensionsToPM(EP_Peephole, MPM);
00272       if (OptLevel > 1 && UseGVNAfterVectorization)
00273         MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
00274       else
00275         MPM.add(createEarlyCSEPass());      // Catch trivial redundancies
00276 
00277       // BBVectorize may have significantly shortened a loop body; unroll again.
00278       if (!DisableUnrollLoops)
00279         MPM.add(createLoopUnrollPass());
00280     }
00281   }
00282 
00283   if (LoadCombine)
00284     MPM.add(createLoadCombinePass());
00285 
00286   MPM.add(createAggressiveDCEPass());         // Delete dead instructions
00287   MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
00288   MPM.add(createInstructionCombiningPass());  // Clean up after everything.
00289   addExtensionsToPM(EP_Peephole, MPM);
00290 
00291   // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
00292   // pass manager that we are specifically trying to avoid. To prevent this
00293   // we must insert a no-op module pass to reset the pass manager.
00294   MPM.add(createBarrierNoopPass());
00295 
00296   // Re-rotate loops in all our loop nests. These may have fallout out of
00297   // rotated form due to GVN or other transformations, and the vectorizer relies
00298   // on the rotated form.
00299   if (ExtraVectorizerPasses)
00300     MPM.add(createLoopRotatePass());
00301 
00302   MPM.add(createLoopVectorizePass(DisableUnrollLoops, LoopVectorize));
00303   // FIXME: Because of #pragma vectorize enable, the passes below are always
00304   // inserted in the pipeline, even when the vectorizer doesn't run (ex. when
00305   // on -O1 and no #pragma is found). Would be good to have these two passes
00306   // as function calls, so that we can only pass them when the vectorizer
00307   // changed the code.
00308   MPM.add(createInstructionCombiningPass());
00309   if (OptLevel > 1 && ExtraVectorizerPasses) {
00310     // At higher optimization levels, try to clean up any runtime overlap and
00311     // alignment checks inserted by the vectorizer. We want to track correllated
00312     // runtime checks for two inner loops in the same outer loop, fold any
00313     // common computations, hoist loop-invariant aspects out of any outer loop,
00314     // and unswitch the runtime checks if possible. Once hoisted, we may have
00315     // dead (or speculatable) control flows or more combining opportunities.
00316     MPM.add(createEarlyCSEPass());
00317     MPM.add(createCorrelatedValuePropagationPass());
00318     MPM.add(createInstructionCombiningPass());
00319     MPM.add(createLICMPass());
00320     MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3));
00321     MPM.add(createCFGSimplificationPass());
00322     MPM.add(createInstructionCombiningPass());
00323   }
00324 
00325   if (RunSLPAfterLoopVectorization) {
00326     if (SLPVectorize) {
00327       MPM.add(createSLPVectorizerPass());   // Vectorize parallel scalar chains.
00328       if (OptLevel > 1 && ExtraVectorizerPasses) {
00329         MPM.add(createEarlyCSEPass());
00330       }
00331     }
00332 
00333     if (BBVectorize) {
00334       MPM.add(createBBVectorizePass());
00335       MPM.add(createInstructionCombiningPass());
00336       addExtensionsToPM(EP_Peephole, MPM);
00337       if (OptLevel > 1 && UseGVNAfterVectorization)
00338         MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies
00339       else
00340         MPM.add(createEarlyCSEPass());      // Catch trivial redundancies
00341 
00342       // BBVectorize may have significantly shortened a loop body; unroll again.
00343       if (!DisableUnrollLoops)
00344         MPM.add(createLoopUnrollPass());
00345     }
00346   }
00347 
00348   addExtensionsToPM(EP_Peephole, MPM);
00349   MPM.add(createCFGSimplificationPass());
00350   MPM.add(createInstructionCombiningPass());
00351 
00352   if (!DisableUnrollLoops)
00353     MPM.add(createLoopUnrollPass());    // Unroll small loops
00354 
00355   // After vectorization and unrolling, assume intrinsics may tell us more
00356   // about pointer alignments.
00357   MPM.add(createAlignmentFromAssumptionsPass());
00358 
00359   if (!DisableUnitAtATime) {
00360     // FIXME: We shouldn't bother with this anymore.
00361     MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
00362 
00363     // GlobalOpt already deletes dead functions and globals, at -O2 try a
00364     // late pass of GlobalDCE.  It is capable of deleting dead cycles.
00365     if (OptLevel > 1) {
00366       MPM.add(createGlobalDCEPass());         // Remove dead fns and globals.
00367       MPM.add(createConstantMergePass());     // Merge dup global constants
00368     }
00369   }
00370 
00371   if (MergeFunctions)
00372     MPM.add(createMergeFunctionsPass());
00373 
00374   addExtensionsToPM(EP_OptimizerLast, MPM);
00375 }
00376 
00377 void PassManagerBuilder::addLTOOptimizationPasses(PassManagerBase &PM) {
00378   // Provide AliasAnalysis services for optimizations.
00379   addInitialAliasAnalysisPasses(PM);
00380 
00381   // Propagate constants at call sites into the functions they call.  This
00382   // opens opportunities for globalopt (and inlining) by substituting function
00383   // pointers passed as arguments to direct uses of functions.
00384   PM.add(createIPSCCPPass());
00385 
00386   // Now that we internalized some globals, see if we can hack on them!
00387   PM.add(createGlobalOptimizerPass());
00388 
00389   // Linking modules together can lead to duplicated global constants, only
00390   // keep one copy of each constant.
00391   PM.add(createConstantMergePass());
00392 
00393   // Remove unused arguments from functions.
00394   PM.add(createDeadArgEliminationPass());
00395 
00396   // Reduce the code after globalopt and ipsccp.  Both can open up significant
00397   // simplification opportunities, and both can propagate functions through
00398   // function pointers.  When this happens, we often have to resolve varargs
00399   // calls, etc, so let instcombine do this.
00400   PM.add(createInstructionCombiningPass());
00401   addExtensionsToPM(EP_Peephole, PM);
00402 
00403   // Inline small functions
00404   bool RunInliner = Inliner;
00405   if (RunInliner) {
00406     PM.add(Inliner);
00407     Inliner = nullptr;
00408   }
00409 
00410   PM.add(createPruneEHPass());   // Remove dead EH info.
00411 
00412   // Optimize globals again if we ran the inliner.
00413   if (RunInliner)
00414     PM.add(createGlobalOptimizerPass());
00415   PM.add(createGlobalDCEPass()); // Remove dead functions.
00416 
00417   // If we didn't decide to inline a function, check to see if we can
00418   // transform it to pass arguments by value instead of by reference.
00419   PM.add(createArgumentPromotionPass());
00420 
00421   // The IPO passes may leave cruft around.  Clean up after them.
00422   PM.add(createInstructionCombiningPass());
00423   addExtensionsToPM(EP_Peephole, PM);
00424   PM.add(createJumpThreadingPass());
00425 
00426   // Break up allocas
00427   if (UseNewSROA)
00428     PM.add(createSROAPass());
00429   else
00430     PM.add(createScalarReplAggregatesPass());
00431 
00432   // Run a few AA driven optimizations here and now, to cleanup the code.
00433   PM.add(createFunctionAttrsPass()); // Add nocapture.
00434   PM.add(createGlobalsModRefPass()); // IP alias analysis.
00435 
00436   PM.add(createLICMPass());                 // Hoist loop invariants.
00437   if (EnableMLSM)
00438     PM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds.
00439   PM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies.
00440   PM.add(createMemCpyOptPass());            // Remove dead memcpys.
00441 
00442   // Nuke dead stores.
00443   PM.add(createDeadStoreEliminationPass());
00444 
00445   // More loops are countable; try to optimize them.
00446   PM.add(createIndVarSimplifyPass());
00447   PM.add(createLoopDeletionPass());
00448   PM.add(createLoopVectorizePass(true, LoopVectorize));
00449 
00450   // More scalar chains could be vectorized due to more alias information
00451   if (RunSLPAfterLoopVectorization)
00452     if (SLPVectorize)
00453       PM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
00454 
00455   // After vectorization, assume intrinsics may tell us more about pointer
00456   // alignments.
00457   PM.add(createAlignmentFromAssumptionsPass());
00458 
00459   if (LoadCombine)
00460     PM.add(createLoadCombinePass());
00461 
00462   // Cleanup and simplify the code after the scalar optimizations.
00463   PM.add(createInstructionCombiningPass());
00464   addExtensionsToPM(EP_Peephole, PM);
00465 
00466   PM.add(createJumpThreadingPass());
00467 
00468   // Delete basic blocks, which optimization passes may have killed.
00469   PM.add(createCFGSimplificationPass());
00470 
00471   // Now that we have optimized the program, discard unreachable functions.
00472   PM.add(createGlobalDCEPass());
00473 
00474   // FIXME: this is profitable (for compiler time) to do at -O0 too, but
00475   // currently it damages debug info.
00476   if (MergeFunctions)
00477     PM.add(createMergeFunctionsPass());
00478 }
00479 
00480 void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM,
00481                                                 TargetMachine *TM) {
00482   if (TM) {
00483     PM.add(new DataLayoutPass());
00484     TM->addAnalysisPasses(PM);
00485   }
00486 
00487   if (LibraryInfo)
00488     PM.add(new TargetLibraryInfo(*LibraryInfo));
00489 
00490   if (VerifyInput)
00491     PM.add(createVerifierPass());
00492 
00493   if (StripDebug)
00494     PM.add(createStripSymbolsPass(true));
00495 
00496   if (VerifyInput)
00497     PM.add(createDebugInfoVerifierPass());
00498 
00499   if (OptLevel != 0)
00500     addLTOOptimizationPasses(PM);
00501 
00502   if (VerifyOutput) {
00503     PM.add(createVerifierPass());
00504     PM.add(createDebugInfoVerifierPass());
00505   }
00506 }
00507 
00508 inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {
00509     return reinterpret_cast<PassManagerBuilder*>(P);
00510 }
00511 
00512 inline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) {
00513   return reinterpret_cast<LLVMPassManagerBuilderRef>(P);
00514 }
00515 
00516 LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate() {
00517   PassManagerBuilder *PMB = new PassManagerBuilder();
00518   return wrap(PMB);
00519 }
00520 
00521 void LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB) {
00522   PassManagerBuilder *Builder = unwrap(PMB);
00523   delete Builder;
00524 }
00525 
00526 void
00527 LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB,
00528                                   unsigned OptLevel) {
00529   PassManagerBuilder *Builder = unwrap(PMB);
00530   Builder->OptLevel = OptLevel;
00531 }
00532 
00533 void
00534 LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB,
00535                                    unsigned SizeLevel) {
00536   PassManagerBuilder *Builder = unwrap(PMB);
00537   Builder->SizeLevel = SizeLevel;
00538 }
00539 
00540 void
00541 LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB,
00542                                             LLVMBool Value) {
00543   PassManagerBuilder *Builder = unwrap(PMB);
00544   Builder->DisableUnitAtATime = Value;
00545 }
00546 
00547 void
00548 LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB,
00549                                             LLVMBool Value) {
00550   PassManagerBuilder *Builder = unwrap(PMB);
00551   Builder->DisableUnrollLoops = Value;
00552 }
00553 
00554 void
00555 LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB,
00556                                                  LLVMBool Value) {
00557   // NOTE: The simplify-libcalls pass has been removed.
00558 }
00559 
00560 void
00561 LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB,
00562                                               unsigned Threshold) {
00563   PassManagerBuilder *Builder = unwrap(PMB);
00564   Builder->Inliner = createFunctionInliningPass(Threshold);
00565 }
00566 
00567 void
00568 LLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB,
00569                                                   LLVMPassManagerRef PM) {
00570   PassManagerBuilder *Builder = unwrap(PMB);
00571   FunctionPassManager *FPM = unwrap<FunctionPassManager>(PM);
00572   Builder->populateFunctionPassManager(*FPM);
00573 }
00574 
00575 void
00576 LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB,
00577                                                 LLVMPassManagerRef PM) {
00578   PassManagerBuilder *Builder = unwrap(PMB);
00579   PassManagerBase *MPM = unwrap(PM);
00580   Builder->populateModulePassManager(*MPM);
00581 }
00582 
00583 void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB,
00584                                                   LLVMPassManagerRef PM,
00585                                                   LLVMBool Internalize,
00586                                                   LLVMBool RunInliner) {
00587   PassManagerBuilder *Builder = unwrap(PMB);
00588   PassManagerBase *LPM = unwrap(PM);
00589 
00590   // A small backwards compatibility hack. populateLTOPassManager used to take
00591   // an RunInliner option.
00592   if (RunInliner && !Builder->Inliner)
00593     Builder->Inliner = createFunctionInliningPass();
00594 
00595   Builder->populateLTOPassManager(*LPM);
00596 }