1 //===- PassManagerBuilder.cpp - Build Standard Pass -----------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file defines the PassManagerBuilder class, which is used to set up a 11 // "standard" optimization sequence suitable for languages like C and C++. 12 // 13 //===----------------------------------------------------------------------===// 14 15 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/PassManager.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/Target/TargetSubtargetInfo.h" 28 #include "llvm/Transforms/IPO.h" 29 #include "llvm/Transforms/Scalar.h" 30 #include "llvm/Transforms/Vectorize.h" 31 32 using namespace llvm; 33 34 static cl::opt<bool> 35 RunLoopVectorization("vectorize-loops", cl::Hidden, 36 cl::desc("Run the Loop vectorization passes")); 37 38 static cl::opt<bool> 39 RunSLPVectorization("vectorize-slp", cl::Hidden, 40 cl::desc("Run the SLP vectorization passes")); 41 42 static cl::opt<bool> 43 RunBBVectorization("vectorize-slp-aggressive", cl::Hidden, 44 cl::desc("Run the BB vectorization passes")); 45 46 static cl::opt<bool> 47 UseGVNAfterVectorization("use-gvn-after-vectorization", 48 cl::init(false), cl::Hidden, 49 cl::desc("Run GVN instead of Early CSE after vectorization passes")); 50 51 static cl::opt<bool> ExtraVectorizerPasses( 52 "extra-vectorizer-passes", cl::init(false), cl::Hidden, 53 cl::desc("Run cleanup optimization passes after vectorization.")); 54 55 static cl::opt<bool> UseNewSROA("use-new-sroa", 56 cl::init(true), cl::Hidden, 57 cl::desc("Enable the new, experimental SROA pass")); 58 59 static cl::opt<bool> 60 RunLoopRerolling("reroll-loops", cl::Hidden, 61 cl::desc("Run the loop rerolling pass")); 62 63 static cl::opt<bool> RunLoadCombine("combine-loads", cl::init(false), 64 cl::Hidden, 65 cl::desc("Run the load combining pass")); 66 67 static cl::opt<bool> 68 RunSLPAfterLoopVectorization("run-slp-after-loop-vectorization", 69 cl::init(true), cl::Hidden, 70 cl::desc("Run the SLP vectorizer (and BB vectorizer) after the Loop " 71 "vectorizer instead of before")); 72 73 static cl::opt<bool> UseCFLAA("use-cfl-aa", 74 cl::init(false), cl::Hidden, 75 cl::desc("Enable the new, experimental CFL alias analysis")); 76 77 static cl::opt<bool> 78 EnableMLSM("mlsm", cl::init(true), cl::Hidden, 79 cl::desc("Enable motion of merged load and store")); 80 81 PassManagerBuilder::PassManagerBuilder() { 82 OptLevel = 2; 83 SizeLevel = 0; 84 LibraryInfo = nullptr; 85 Inliner = nullptr; 86 DisableTailCalls = false; 87 DisableUnitAtATime = false; 88 DisableUnrollLoops = false; 89 BBVectorize = RunBBVectorization; 90 SLPVectorize = RunSLPVectorization; 91 LoopVectorize = RunLoopVectorization; 92 RerollLoops = RunLoopRerolling; 93 LoadCombine = RunLoadCombine; 94 DisableGVNLoadPRE = false; 95 VerifyInput = false; 96 VerifyOutput = false; 97 StripDebug = false; 98 MergeFunctions = false; 99 } 100 101 PassManagerBuilder::~PassManagerBuilder() { 102 delete LibraryInfo; 103 delete Inliner; 104 } 105 106 /// Set of global extensions, automatically added as part of the standard set. 107 static ManagedStatic<SmallVector<std::pair<PassManagerBuilder::ExtensionPointTy, 108 PassManagerBuilder::ExtensionFn>, 8> > GlobalExtensions; 109 110 void PassManagerBuilder::addGlobalExtension( 111 PassManagerBuilder::ExtensionPointTy Ty, 112 PassManagerBuilder::ExtensionFn Fn) { 113 GlobalExtensions->push_back(std::make_pair(Ty, Fn)); 114 } 115 116 void PassManagerBuilder::addExtension(ExtensionPointTy Ty, ExtensionFn Fn) { 117 Extensions.push_back(std::make_pair(Ty, Fn)); 118 } 119 120 void PassManagerBuilder::addExtensionsToPM(ExtensionPointTy ETy, 121 PassManagerBase &PM) const { 122 for (unsigned i = 0, e = GlobalExtensions->size(); i != e; ++i) 123 if ((*GlobalExtensions)[i].first == ETy) 124 (*GlobalExtensions)[i].second(*this, PM); 125 for (unsigned i = 0, e = Extensions.size(); i != e; ++i) 126 if (Extensions[i].first == ETy) 127 Extensions[i].second(*this, PM); 128 } 129 130 void 131 PassManagerBuilder::addInitialAliasAnalysisPasses(PassManagerBase &PM) const { 132 // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that 133 // BasicAliasAnalysis wins if they disagree. This is intended to help 134 // support "obvious" type-punning idioms. 135 if (UseCFLAA) 136 PM.add(createCFLAliasAnalysisPass()); 137 PM.add(createTypeBasedAliasAnalysisPass()); 138 PM.add(createScopedNoAliasAAPass()); 139 PM.add(createBasicAliasAnalysisPass()); 140 } 141 142 void PassManagerBuilder::populateFunctionPassManager(FunctionPassManager &FPM) { 143 addExtensionsToPM(EP_EarlyAsPossible, FPM); 144 145 // Add LibraryInfo if we have some. 146 if (LibraryInfo) 147 FPM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo)); 148 149 if (OptLevel == 0) return; 150 151 addInitialAliasAnalysisPasses(FPM); 152 153 FPM.add(createCFGSimplificationPass()); 154 if (UseNewSROA) 155 FPM.add(createSROAPass()); 156 else 157 FPM.add(createScalarReplAggregatesPass()); 158 FPM.add(createEarlyCSEPass()); 159 FPM.add(createLowerExpectIntrinsicPass()); 160 } 161 162 void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) { 163 // If all optimizations are disabled, just run the always-inline pass and, 164 // if enabled, the function merging pass. 165 if (OptLevel == 0) { 166 if (Inliner) { 167 MPM.add(Inliner); 168 Inliner = nullptr; 169 } 170 171 // FIXME: The BarrierNoopPass is a HACK! The inliner pass above implicitly 172 // creates a CGSCC pass manager, but we don't want to add extensions into 173 // that pass manager. To prevent this we insert a no-op module pass to reset 174 // the pass manager to get the same behavior as EP_OptimizerLast in non-O0 175 // builds. The function merging pass is 176 if (MergeFunctions) 177 MPM.add(createMergeFunctionsPass()); 178 else if (!GlobalExtensions->empty() || !Extensions.empty()) 179 MPM.add(createBarrierNoopPass()); 180 181 addExtensionsToPM(EP_EnabledOnOptLevel0, MPM); 182 return; 183 } 184 185 // Add LibraryInfo if we have some. 186 if (LibraryInfo) 187 MPM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo)); 188 189 addInitialAliasAnalysisPasses(MPM); 190 191 if (!DisableUnitAtATime) { 192 addExtensionsToPM(EP_ModuleOptimizerEarly, MPM); 193 194 MPM.add(createIPSCCPPass()); // IP SCCP 195 MPM.add(createGlobalOptimizerPass()); // Optimize out global vars 196 197 MPM.add(createDeadArgEliminationPass()); // Dead argument elimination 198 199 MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE 200 addExtensionsToPM(EP_Peephole, MPM); 201 MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE 202 } 203 204 // Start of CallGraph SCC passes. 205 if (!DisableUnitAtATime) 206 MPM.add(createPruneEHPass()); // Remove dead EH info 207 if (Inliner) { 208 MPM.add(Inliner); 209 Inliner = nullptr; 210 } 211 if (!DisableUnitAtATime) 212 MPM.add(createFunctionAttrsPass()); // Set readonly/readnone attrs 213 if (OptLevel > 2) 214 MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args 215 216 // Start of function pass. 217 // Break up aggregate allocas, using SSAUpdater. 218 if (UseNewSROA) 219 MPM.add(createSROAPass(/*RequiresDomTree*/ false)); 220 else 221 MPM.add(createScalarReplAggregatesPass(-1, false)); 222 MPM.add(createEarlyCSEPass()); // Catch trivial redundancies 223 MPM.add(createJumpThreadingPass()); // Thread jumps. 224 MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals 225 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs 226 MPM.add(createInstructionCombiningPass()); // Combine silly seq's 227 addExtensionsToPM(EP_Peephole, MPM); 228 229 if (!DisableTailCalls) 230 MPM.add(createTailCallEliminationPass()); // Eliminate tail calls 231 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs 232 MPM.add(createReassociatePass()); // Reassociate expressions 233 // Rotate Loop - disable header duplication at -Oz 234 MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1)); 235 MPM.add(createLICMPass()); // Hoist loop invariants 236 MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3)); 237 MPM.add(createInstructionCombiningPass()); 238 MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars 239 MPM.add(createLoopIdiomPass()); // Recognize idioms like memset. 240 MPM.add(createLoopDeletionPass()); // Delete dead loops 241 242 if (!DisableUnrollLoops) 243 MPM.add(createSimpleLoopUnrollPass()); // Unroll small loops 244 addExtensionsToPM(EP_LoopOptimizerEnd, MPM); 245 246 if (OptLevel > 1) { 247 if (EnableMLSM) 248 MPM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds 249 MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies 250 } 251 MPM.add(createMemCpyOptPass()); // Remove memcpy / form memset 252 MPM.add(createSCCPPass()); // Constant prop with SCCP 253 254 // Run instcombine after redundancy elimination to exploit opportunities 255 // opened up by them. 256 MPM.add(createInstructionCombiningPass()); 257 addExtensionsToPM(EP_Peephole, MPM); 258 MPM.add(createJumpThreadingPass()); // Thread jumps 259 MPM.add(createCorrelatedValuePropagationPass()); 260 MPM.add(createDeadStoreEliminationPass()); // Delete dead stores 261 262 addExtensionsToPM(EP_ScalarOptimizerLate, MPM); 263 264 if (RerollLoops) 265 MPM.add(createLoopRerollPass()); 266 if (!RunSLPAfterLoopVectorization) { 267 if (SLPVectorize) 268 MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains. 269 270 if (BBVectorize) { 271 MPM.add(createBBVectorizePass()); 272 MPM.add(createInstructionCombiningPass()); 273 addExtensionsToPM(EP_Peephole, MPM); 274 if (OptLevel > 1 && UseGVNAfterVectorization) 275 MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies 276 else 277 MPM.add(createEarlyCSEPass()); // Catch trivial redundancies 278 279 // BBVectorize may have significantly shortened a loop body; unroll again. 280 if (!DisableUnrollLoops) 281 MPM.add(createLoopUnrollPass()); 282 } 283 } 284 285 if (LoadCombine) 286 MPM.add(createLoadCombinePass()); 287 288 MPM.add(createAggressiveDCEPass()); // Delete dead instructions 289 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs 290 MPM.add(createInstructionCombiningPass()); // Clean up after everything. 291 addExtensionsToPM(EP_Peephole, MPM); 292 293 // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC 294 // pass manager that we are specifically trying to avoid. To prevent this 295 // we must insert a no-op module pass to reset the pass manager. 296 MPM.add(createBarrierNoopPass()); 297 298 // Re-rotate loops in all our loop nests. These may have fallout out of 299 // rotated form due to GVN or other transformations, and the vectorizer relies 300 // on the rotated form. 301 if (ExtraVectorizerPasses) 302 MPM.add(createLoopRotatePass()); 303 304 MPM.add(createLoopVectorizePass(DisableUnrollLoops, LoopVectorize)); 305 // FIXME: Because of #pragma vectorize enable, the passes below are always 306 // inserted in the pipeline, even when the vectorizer doesn't run (ex. when 307 // on -O1 and no #pragma is found). Would be good to have these two passes 308 // as function calls, so that we can only pass them when the vectorizer 309 // changed the code. 310 MPM.add(createInstructionCombiningPass()); 311 if (OptLevel > 1 && ExtraVectorizerPasses) { 312 // At higher optimization levels, try to clean up any runtime overlap and 313 // alignment checks inserted by the vectorizer. We want to track correllated 314 // runtime checks for two inner loops in the same outer loop, fold any 315 // common computations, hoist loop-invariant aspects out of any outer loop, 316 // and unswitch the runtime checks if possible. Once hoisted, we may have 317 // dead (or speculatable) control flows or more combining opportunities. 318 MPM.add(createEarlyCSEPass()); 319 MPM.add(createCorrelatedValuePropagationPass()); 320 MPM.add(createInstructionCombiningPass()); 321 MPM.add(createLICMPass()); 322 MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3)); 323 MPM.add(createCFGSimplificationPass()); 324 MPM.add(createInstructionCombiningPass()); 325 } 326 327 if (RunSLPAfterLoopVectorization) { 328 if (SLPVectorize) { 329 MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains. 330 if (OptLevel > 1 && ExtraVectorizerPasses) { 331 MPM.add(createEarlyCSEPass()); 332 } 333 } 334 335 if (BBVectorize) { 336 MPM.add(createBBVectorizePass()); 337 MPM.add(createInstructionCombiningPass()); 338 addExtensionsToPM(EP_Peephole, MPM); 339 if (OptLevel > 1 && UseGVNAfterVectorization) 340 MPM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies 341 else 342 MPM.add(createEarlyCSEPass()); // Catch trivial redundancies 343 344 // BBVectorize may have significantly shortened a loop body; unroll again. 345 if (!DisableUnrollLoops) 346 MPM.add(createLoopUnrollPass()); 347 } 348 } 349 350 addExtensionsToPM(EP_Peephole, MPM); 351 MPM.add(createCFGSimplificationPass()); 352 MPM.add(createInstructionCombiningPass()); 353 354 if (!DisableUnrollLoops) 355 MPM.add(createLoopUnrollPass()); // Unroll small loops 356 357 // After vectorization and unrolling, assume intrinsics may tell us more 358 // about pointer alignments. 359 MPM.add(createAlignmentFromAssumptionsPass()); 360 361 if (!DisableUnitAtATime) { 362 // FIXME: We shouldn't bother with this anymore. 363 MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes 364 365 // GlobalOpt already deletes dead functions and globals, at -O2 try a 366 // late pass of GlobalDCE. It is capable of deleting dead cycles. 367 if (OptLevel > 1) { 368 MPM.add(createGlobalDCEPass()); // Remove dead fns and globals. 369 MPM.add(createConstantMergePass()); // Merge dup global constants 370 } 371 } 372 373 if (MergeFunctions) 374 MPM.add(createMergeFunctionsPass()); 375 376 addExtensionsToPM(EP_OptimizerLast, MPM); 377 } 378 379 void PassManagerBuilder::addLTOOptimizationPasses(PassManagerBase &PM) { 380 // Provide AliasAnalysis services for optimizations. 381 addInitialAliasAnalysisPasses(PM); 382 383 // Propagate constants at call sites into the functions they call. This 384 // opens opportunities for globalopt (and inlining) by substituting function 385 // pointers passed as arguments to direct uses of functions. 386 PM.add(createIPSCCPPass()); 387 388 // Now that we internalized some globals, see if we can hack on them! 389 PM.add(createGlobalOptimizerPass()); 390 391 // Linking modules together can lead to duplicated global constants, only 392 // keep one copy of each constant. 393 PM.add(createConstantMergePass()); 394 395 // Remove unused arguments from functions. 396 PM.add(createDeadArgEliminationPass()); 397 398 // Reduce the code after globalopt and ipsccp. Both can open up significant 399 // simplification opportunities, and both can propagate functions through 400 // function pointers. When this happens, we often have to resolve varargs 401 // calls, etc, so let instcombine do this. 402 PM.add(createInstructionCombiningPass()); 403 addExtensionsToPM(EP_Peephole, PM); 404 405 // Inline small functions 406 bool RunInliner = Inliner; 407 if (RunInliner) { 408 PM.add(Inliner); 409 Inliner = nullptr; 410 } 411 412 PM.add(createPruneEHPass()); // Remove dead EH info. 413 414 // Optimize globals again if we ran the inliner. 415 if (RunInliner) 416 PM.add(createGlobalOptimizerPass()); 417 PM.add(createGlobalDCEPass()); // Remove dead functions. 418 419 // If we didn't decide to inline a function, check to see if we can 420 // transform it to pass arguments by value instead of by reference. 421 PM.add(createArgumentPromotionPass()); 422 423 // The IPO passes may leave cruft around. Clean up after them. 424 PM.add(createInstructionCombiningPass()); 425 addExtensionsToPM(EP_Peephole, PM); 426 PM.add(createJumpThreadingPass()); 427 428 // Break up allocas 429 if (UseNewSROA) 430 PM.add(createSROAPass()); 431 else 432 PM.add(createScalarReplAggregatesPass()); 433 434 // Run a few AA driven optimizations here and now, to cleanup the code. 435 PM.add(createFunctionAttrsPass()); // Add nocapture. 436 PM.add(createGlobalsModRefPass()); // IP alias analysis. 437 438 PM.add(createLICMPass()); // Hoist loop invariants. 439 if (EnableMLSM) 440 PM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds. 441 PM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies. 442 PM.add(createMemCpyOptPass()); // Remove dead memcpys. 443 444 // Nuke dead stores. 445 PM.add(createDeadStoreEliminationPass()); 446 447 // More loops are countable; try to optimize them. 448 PM.add(createIndVarSimplifyPass()); 449 PM.add(createLoopDeletionPass()); 450 PM.add(createLoopVectorizePass(true, LoopVectorize)); 451 452 // More scalar chains could be vectorized due to more alias information 453 if (RunSLPAfterLoopVectorization) 454 if (SLPVectorize) 455 PM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains. 456 457 // After vectorization, assume intrinsics may tell us more about pointer 458 // alignments. 459 PM.add(createAlignmentFromAssumptionsPass()); 460 461 if (LoadCombine) 462 PM.add(createLoadCombinePass()); 463 464 // Cleanup and simplify the code after the scalar optimizations. 465 PM.add(createInstructionCombiningPass()); 466 addExtensionsToPM(EP_Peephole, PM); 467 468 PM.add(createJumpThreadingPass()); 469 470 // Delete basic blocks, which optimization passes may have killed. 471 PM.add(createCFGSimplificationPass()); 472 473 // Now that we have optimized the program, discard unreachable functions. 474 PM.add(createGlobalDCEPass()); 475 476 // FIXME: this is profitable (for compiler time) to do at -O0 too, but 477 // currently it damages debug info. 478 if (MergeFunctions) 479 PM.add(createMergeFunctionsPass()); 480 } 481 482 void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM, 483 TargetMachine *TM) { 484 if (TM) { 485 PM.add(new DataLayoutPass()); 486 TM->addAnalysisPasses(PM); 487 } 488 489 if (LibraryInfo) 490 PM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo)); 491 492 if (VerifyInput) 493 PM.add(createVerifierPass()); 494 495 if (StripDebug) 496 PM.add(createStripSymbolsPass(true)); 497 498 if (VerifyInput) 499 PM.add(createDebugInfoVerifierPass()); 500 501 if (OptLevel != 0) 502 addLTOOptimizationPasses(PM); 503 504 if (VerifyOutput) { 505 PM.add(createVerifierPass()); 506 PM.add(createDebugInfoVerifierPass()); 507 } 508 } 509 510 inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) { 511 return reinterpret_cast<PassManagerBuilder*>(P); 512 } 513 514 inline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) { 515 return reinterpret_cast<LLVMPassManagerBuilderRef>(P); 516 } 517 518 LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate() { 519 PassManagerBuilder *PMB = new PassManagerBuilder(); 520 return wrap(PMB); 521 } 522 523 void LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB) { 524 PassManagerBuilder *Builder = unwrap(PMB); 525 delete Builder; 526 } 527 528 void 529 LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB, 530 unsigned OptLevel) { 531 PassManagerBuilder *Builder = unwrap(PMB); 532 Builder->OptLevel = OptLevel; 533 } 534 535 void 536 LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB, 537 unsigned SizeLevel) { 538 PassManagerBuilder *Builder = unwrap(PMB); 539 Builder->SizeLevel = SizeLevel; 540 } 541 542 void 543 LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB, 544 LLVMBool Value) { 545 PassManagerBuilder *Builder = unwrap(PMB); 546 Builder->DisableUnitAtATime = Value; 547 } 548 549 void 550 LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB, 551 LLVMBool Value) { 552 PassManagerBuilder *Builder = unwrap(PMB); 553 Builder->DisableUnrollLoops = Value; 554 } 555 556 void 557 LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB, 558 LLVMBool Value) { 559 // NOTE: The simplify-libcalls pass has been removed. 560 } 561 562 void 563 LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB, 564 unsigned Threshold) { 565 PassManagerBuilder *Builder = unwrap(PMB); 566 Builder->Inliner = createFunctionInliningPass(Threshold); 567 } 568 569 void 570 LLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB, 571 LLVMPassManagerRef PM) { 572 PassManagerBuilder *Builder = unwrap(PMB); 573 FunctionPassManager *FPM = unwrap<FunctionPassManager>(PM); 574 Builder->populateFunctionPassManager(*FPM); 575 } 576 577 void 578 LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB, 579 LLVMPassManagerRef PM) { 580 PassManagerBuilder *Builder = unwrap(PMB); 581 PassManagerBase *MPM = unwrap(PM); 582 Builder->populateModulePassManager(*MPM); 583 } 584 585 void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB, 586 LLVMPassManagerRef PM, 587 LLVMBool Internalize, 588 LLVMBool RunInliner) { 589 PassManagerBuilder *Builder = unwrap(PMB); 590 PassManagerBase *LPM = unwrap(PM); 591 592 // A small backwards compatibility hack. populateLTOPassManager used to take 593 // an RunInliner option. 594 if (RunInliner && !Builder->Inliner) 595 Builder->Inliner = createFunctionInliningPass(); 596 597 Builder->populateLTOPassManager(*LPM); 598 } 599