[PATCH] D19773: Tweak the ThinLTO pass pipeline

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Mon May 2 10:59:07 PDT 2016


joker.eph updated this revision to Diff 55851.
joker.eph added a comment.

Rebase after splitting other changes


http://reviews.llvm.org/D19773

Files:
  lib/Transforms/IPO/PassManagerBuilder.cpp

Index: lib/Transforms/IPO/PassManagerBuilder.cpp
===================================================================
--- lib/Transforms/IPO/PassManagerBuilder.cpp
+++ lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -242,11 +242,6 @@
   MPM.add(createTailCallEliminationPass()); // Eliminate tail calls
   MPM.add(createCFGSimplificationPass());     // Merge & remove BBs
   MPM.add(createReassociatePass());           // Reassociate expressions
-  if (PrepareForThinLTO) {
-    MPM.add(createAggressiveDCEPass());        // Delete dead instructions
-    addInstructionCombiningPass(MPM);          // Combine silly seq's
-    return;
-  }
   // Rotate Loop - disable header duplication at -Oz
   MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));
   MPM.add(createLICMPass());                  // Hoist loop invariants
@@ -430,26 +425,21 @@
     return;
   }
 
+  if (PerformThinLTO)
+    // Optimize globals now when performing ThinLTO, this enables more
+    // optimizations later.
+    MPM.add(createGlobalOptimizerPass());
+
   // Scheduling LoopVersioningLICM when inlining is over, because after that
   // we may see more accurate aliasing. Reason to run this late is that too
   // early versioning may prevent further inlining due to increase of code
-  // size. By placing it just after inlining other optimizations which runs 
-  // later might get benefit of no-alias assumption in clone loop. 
+  // size. By placing it just after inlining other optimizations which runs
+  // later might get benefit of no-alias assumption in clone loop.
   if (UseLoopVersioningLICM) {
     MPM.add(createLoopVersioningLICMPass());    // Do LoopVersioningLICM
     MPM.add(createLICMPass());                  // Hoist loop invariants
   }
 
-  if (PerformThinLTO) {
-    // Remove dead fns and globals. Removing unreferenced functions could lead
-    // to more opportunities for globalopt.
-    MPM.add(createGlobalDCEPass());
-    MPM.add(createGlobalOptimizerPass());
-    // Remove dead fns and globals after globalopt.
-    MPM.add(createGlobalDCEPass());
-    addFunctionSimplificationPasses(MPM);
-  }
-
   if (EnableNonLTOGlobalsModRef)
     // We add a fresh GlobalsModRef run at this point. This is particularly
     // useful as the above will have inlined, DCE'ed, and function-attr


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19773.55851.patch
Type: text/x-patch
Size: 2295 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160502/d331d64e/attachment.bin>


More information about the llvm-commits mailing list