llvm.org GIT mirror llvm / bfe76f9
[PassManager] Improve the interaction between -O2 and ThinLTO. Run GDCE slightly later so that we don't have to repeat it twice when preparing for Thin. Thanks to Mehdi for the suggestion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314999 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 1 year, 11 months ago
2 changed file(s) with 14 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
507507 // we must insert a no-op module pass to reset the pass manager.
508508 MPM.add(createBarrierNoopPass());
509509
510 // The inliner performs some kind of dead code elimination as it goes,
511 // but there are cases that are not really caught by it. We might
512 // at some point consider teaching the inliner about them, but it
513 // is OK for now to run GlobalOpt + GlobalDCE in tandem as their
514 // benefits generally outweight the cost, making the whole pipeline
515 // faster.
516 if (RunInliner) {
517 MPM.add(createGlobalOptimizerPass());
518 MPM.add(createGlobalDCEPass());
519 }
520
521510 if (RunPartialInlining)
522511 MPM.add(createPartialInliningPass());
523512
537526 if (!DisableUnitAtATime)
538527 MPM.add(createReversePostOrderFunctionAttrsPass());
539528
529 // The inliner performs some kind of dead code elimination as it goes,
530 // but there are cases that are not really caught by it. We might
531 // at some point consider teaching the inliner about them, but it
532 // is OK for now to run GlobalOpt + GlobalDCE in tandem as their
533 // benefits generally outweight the cost, making the whole pipeline
534 // faster.
535 if (RunInliner) {
536 MPM.add(createGlobalOptimizerPass());
537 MPM.add(createGlobalDCEPass());
538 }
539
540540 // If we are planning to perform ThinLTO later, let's not bloat the code with
541541 // unrolling/vectorization/... now. We'll first run the inliner + CGSCC passes
542542 // during ThinLTO and perform the rest of the optimizations afterward.
543543 if (PrepareForThinLTO) {
544 // Reduce the size of the IR as much as possible.
545 MPM.add(createGlobalOptimizerPass());
546544 // Rename anon globals to be able to export them in the summary.
547545 MPM.add(createNameAnonGlobalPass());
548546 return;
5454 ; Next we break out of the main Function passes inside the CGSCC pipeline with
5555 ; a barrier pass.
5656 ; CHECK-O2: A No-Op Barrier Pass
57 ; Reduce the size of the IR ASAP after the inliner.
58 ; CHECK-O2-NEXT: Global Variable Optimizer
59 ; CHECK-O2: Dead Global Elimination
6057 ; CHECK-O2-NEXT: Eliminate Available Externally
6158 ; Inferring function attribute should be right after the CGSCC pipeline, before
6259 ; any other optimizations/analyses.
6360 ; CHECK-O2-NEXT: CallGraph
6461 ; CHECK-O2-NEXT: Deduce function attributes in RPO
6562 ; CHECK-O2-NOT: Manager
63 ; Reduce the size of the IR ASAP after the inliner.
64 ; CHECK-O2-NEXT: Global Variable Optimizer
65 ; CHECK-O2: Dead Global Elimination
6666 ; Next is the late function pass pipeline.
6767 ; CHECK-O2: FunctionPass Manager
6868 ; CHECK-O2-NOT: Manager