[llvm] r268394 - Move "Eliminate Available Externally" immediately after the inliner

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Tue May 3 08:46:01 PDT 2016


Author: mehdi_amini
Date: Tue May  3 10:46:00 2016
New Revision: 268394

URL: http://llvm.org/viewvc/llvm-project?rev=268394&view=rev
Log:
Move "Eliminate Available Externally" immediately after the inliner

This pass is supposed to reduce the size of the IR for compile time
purpose. We should run it ASAP, except when we prepare for LTO or
ThinLTO, and we want to keep them available for link-time inline.

Differential Revision: http://reviews.llvm.org/D19813

From: Mehdi Amini <mehdi.amini at apple.com>

Modified:
    llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
    llvm/trunk/test/Other/pass-pipelines.ll

Modified: llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=268394&r1=268393&r2=268394&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp Tue May  3 10:46:00 2016
@@ -404,6 +404,19 @@ void PassManagerBuilder::populateModuleP
   // we must insert a no-op module pass to reset the pass manager.
   MPM.add(createBarrierNoopPass());
 
+  if (!DisableUnitAtATime && OptLevel > 1 && !PrepareForLTO &&
+      !PrepareForThinLTO)
+    // Remove avail extern fns and globals definitions if we aren't
+    // compiling an object file for later LTO. For LTO we want to preserve
+    // these so they are eligible for inlining at link-time. Note if they
+    // are unreferenced they will be removed by GlobalDCE later, so
+    // this only impacts referenced available externally globals.
+    // Eventually they will be suppressed during codegen, but eliminating
+    // here enables more opportunity for GlobalDCE as it may make
+    // globals referenced by available external functions dead
+    // and saves running remaining passes on the eliminated functions.
+    MPM.add(createEliminateAvailableExternallyPass());
+
   if (!DisableUnitAtATime)
     MPM.add(createReversePostOrderFunctionAttrsPass());
 
@@ -428,18 +441,6 @@ void PassManagerBuilder::populateModuleP
     MPM.add(createLICMPass());                  // Hoist loop invariants
   }
 
-  if (!DisableUnitAtATime && OptLevel > 1 && !PrepareForLTO)
-    // Remove avail extern fns and globals definitions if we aren't
-    // compiling an object file for later LTO. For LTO we want to preserve
-    // these so they are eligible for inlining at link-time. Note if they
-    // are unreferenced they will be removed by GlobalDCE later, so
-    // this only impacts referenced available externally globals.
-    // Eventually they will be suppressed during codegen, but eliminating
-    // here enables more opportunity for GlobalDCE as it may make
-    // globals referenced by available external functions dead
-    // and saves running remaining passes on the eliminated functions.
-    MPM.add(createEliminateAvailableExternallyPass());
-
   if (PerformThinLTO) {
     // Remove dead fns and globals. Removing unreferenced functions could lead
     // to more opportunities for globalopt.

Modified: llvm/trunk/test/Other/pass-pipelines.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/pass-pipelines.ll?rev=268394&r1=268393&r2=268394&view=diff
==============================================================================
--- llvm/trunk/test/Other/pass-pipelines.ll (original)
+++ llvm/trunk/test/Other/pass-pipelines.ll Tue May  3 10:46:00 2016
@@ -55,7 +55,10 @@
 ; Next we break out of the main Function passes inside the CGSCC pipeline with
 ; a barrier pass.
 ; CHECK-O2: A No-Op Barrier Pass
-; Inferring function attribute should be immediately after the CGSCC pipeline.
+; Reduce the size of the IR ASAP after the inliner.
+; CHECK-O2-NEXT: Eliminate Available Externally
+; Inferring function attribute should be right after the CGSCC pipeline, before
+; any other optimizations/analyses.
 ; CHECK-O2-NEXT: CallGraph
 ; CHECK-O2-NEXT: Deduce function attributes in RPO
 ; CHECK-O2-NOT: Manager




More information about the llvm-commits mailing list