[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.
llvm-svn: 314999
diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
index 1a17508..67fd4b9 100644
--- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -508,17 +508,6 @@
// we must insert a no-op module pass to reset the pass manager.
MPM.add(createBarrierNoopPass());
- // The inliner performs some kind of dead code elimination as it goes,
- // but there are cases that are not really caught by it. We might
- // at some point consider teaching the inliner about them, but it
- // is OK for now to run GlobalOpt + GlobalDCE in tandem as their
- // benefits generally outweight the cost, making the whole pipeline
- // faster.
- if (RunInliner) {
- MPM.add(createGlobalOptimizerPass());
- MPM.add(createGlobalDCEPass());
- }
-
if (RunPartialInlining)
MPM.add(createPartialInliningPass());
@@ -538,12 +527,21 @@
if (!DisableUnitAtATime)
MPM.add(createReversePostOrderFunctionAttrsPass());
+ // The inliner performs some kind of dead code elimination as it goes,
+ // but there are cases that are not really caught by it. We might
+ // at some point consider teaching the inliner about them, but it
+ // is OK for now to run GlobalOpt + GlobalDCE in tandem as their
+ // benefits generally outweight the cost, making the whole pipeline
+ // faster.
+ if (RunInliner) {
+ MPM.add(createGlobalOptimizerPass());
+ MPM.add(createGlobalDCEPass());
+ }
+
// If we are planning to perform ThinLTO later, let's not bloat the code with
// unrolling/vectorization/... now. We'll first run the inliner + CGSCC passes
// during ThinLTO and perform the rest of the optimizations afterward.
if (PrepareForThinLTO) {
- // Reduce the size of the IR as much as possible.
- MPM.add(createGlobalOptimizerPass());
// Rename anon globals to be able to export them in the summary.
MPM.add(createNameAnonGlobalPass());
return;