Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit c7a16bd

Browse files
dccialexcrichton
authored andcommitted
[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
1 parent 1aecec4 commit c7a16bd

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

lib/Transforms/IPO/PassManagerBuilder.cpp

+11-13
Original file line numberDiff line numberDiff line change
@@ -494,17 +494,6 @@ void PassManagerBuilder::populateModulePassManager(
494494
// we must insert a no-op module pass to reset the pass manager.
495495
MPM.add(createBarrierNoopPass());
496496

497-
// The inliner performs some kind of dead code elimination as it goes,
498-
// but there are cases that are not really caught by it. We might
499-
// at some point consider teaching the inliner about them, but it
500-
// is OK for now to run GlobalOpt + GlobalDCE in tandem as their
501-
// benefits generally outweight the cost, making the whole pipeline
502-
// faster.
503-
if (RunInliner) {
504-
MPM.add(createGlobalOptimizerPass());
505-
MPM.add(createGlobalDCEPass());
506-
}
507-
508497
if (!DisableUnitAtATime && OptLevel > 1 && !PrepareForLTO &&
509498
!PrepareForThinLTO)
510499
// Remove avail extern fns and globals definitions if we aren't
@@ -521,12 +510,21 @@ void PassManagerBuilder::populateModulePassManager(
521510
if (!DisableUnitAtATime)
522511
MPM.add(createReversePostOrderFunctionAttrsPass());
523512

513+
// The inliner performs some kind of dead code elimination as it goes,
514+
// but there are cases that are not really caught by it. We might
515+
// at some point consider teaching the inliner about them, but it
516+
// is OK for now to run GlobalOpt + GlobalDCE in tandem as their
517+
// benefits generally outweight the cost, making the whole pipeline
518+
// faster.
519+
if (RunInliner) {
520+
MPM.add(createGlobalOptimizerPass());
521+
MPM.add(createGlobalDCEPass());
522+
}
523+
524524
// If we are planning to perform ThinLTO later, let's not bloat the code with
525525
// unrolling/vectorization/... now. We'll first run the inliner + CGSCC passes
526526
// during ThinLTO and perform the rest of the optimizations afterward.
527527
if (PrepareForThinLTO) {
528-
// Reduce the size of the IR as much as possible.
529-
MPM.add(createGlobalOptimizerPass());
530528
// Rename anon globals to be able to export them in the summary.
531529
MPM.add(createNameAnonGlobalPass());
532530
return;

test/Other/pass-pipelines.ll

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@
5555
; Next we break out of the main Function passes inside the CGSCC pipeline with
5656
; a barrier pass.
5757
; CHECK-O2: A No-Op Barrier Pass
58-
; Reduce the size of the IR ASAP after the inliner.
59-
; CHECK-O2-NEXT: Global Variable Optimizer
60-
; CHECK-O2: Dead Global Elimination
6158
; CHECK-O2-NEXT: Eliminate Available Externally
6259
; Inferring function attribute should be right after the CGSCC pipeline, before
6360
; any other optimizations/analyses.
6461
; CHECK-O2-NEXT: CallGraph
6562
; CHECK-O2-NEXT: Deduce function attributes in RPO
6663
; CHECK-O2-NOT: Manager
64+
; Reduce the size of the IR ASAP after the inliner.
65+
; CHECK-O2-NEXT: Global Variable Optimizer
66+
; CHECK-O2: Dead Global Elimination
6767
; Next is the late function pass pipeline.
6868
; CHECK-O2: FunctionPass Manager
6969
; CHECK-O2-NOT: Manager

0 commit comments

Comments
 (0)