[llvm-commits] [llvm] r72811 - in /llvm/trunk: include/llvm/Support/StandardPasses.h tools/llvm-ld/Optimize.cpp tools/lto/LTOCodeGenerator.cpp

Daniel Dunbar daniel at zuster.org
Wed Jun 3 14:51:32 PDT 2009


Author: ddunbar
Date: Wed Jun  3 16:51:32 2009
New Revision: 72811

URL: http://llvm.org/viewvc/llvm-project?rev=72811&view=rev
Log:
Change LTO to run the global opt pass twice.
 - This matches llvm-ld.

It took a bit of archeology to figure out what the right thing to do was
(whether this was intentionally added or intentionally removed). My final
conclusion is that Chris added this intentionally here:
  http://llvm.org/viewvc/llvm-project?view=rev&revision=16913
but the changes weren't propogated to llvm-ld until here:
  http://llvm.org/viewvc/llvm-project?view=rev&revision=34058
which was after lto.cpp had been cloned off (of llvm-ld), here:
  http://llvm.org/viewvc/llvm-project?view=rev&revision=29494

>From the commit message, it looks like the motivation for running global opt
again is because we ran it prior to inlining. Based on that I updated the
comment and also only run the pass if we actually ran the inliner.

Chris, please review.

Modified:
    llvm/trunk/include/llvm/Support/StandardPasses.h
    llvm/trunk/tools/llvm-ld/Optimize.cpp
    llvm/trunk/tools/lto/LTOCodeGenerator.cpp

Modified: llvm/trunk/include/llvm/Support/StandardPasses.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=72811&r1=72810&r2=72811&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/StandardPasses.h (original)
+++ llvm/trunk/include/llvm/Support/StandardPasses.h Wed Jun  3 16:51:32 2009
@@ -60,15 +60,10 @@
   ///
   /// Internalize - Run the internalize pass.
   /// RunInliner - Use a function inlining pass.
-  /// RunSecondGlobalOpt - Run the global optimizer pass twice.
   /// VerifyEach - Run the verifier after each pass.
-  //
-  // FIXME: RunSecondGlobalOpt should go away once we resolve which of LTO or
-  // llvm-ld is better.
   static inline void createStandardLTOPasses(PassManager *PM,
                                              bool Internalize,
                                              bool RunInliner,
-                                             bool RunSecondGlobalOpt,
                                              bool VerifyEach);
 
   // Implementations
@@ -173,7 +168,6 @@
   static inline void createStandardLTOPasses(PassManager *PM,
                                              bool Internalize,
                                              bool RunInliner,
-                                             bool RunSecondGlobalOpt,
                                              bool VerifyEach) {
     // Now that composite has been compiled, scan through the module, looking
     // for a main function.  If main is defined, mark all other functions
@@ -207,8 +201,8 @@
       addOnePass(PM, createFunctionInliningPass(), VerifyEach);
 
     addOnePass(PM, createPruneEHPass(), VerifyEach);   // Remove dead EH info.
-    // Optimize globals again.
-    if (RunSecondGlobalOpt)
+    // Optimize globals again if we ran the inliner.
+    if (RunInliner)
       addOnePass(PM, createGlobalOptimizerPass(), VerifyEach);
     addOnePass(PM, createGlobalDCEPass(), VerifyEach); // Remove dead functions.
 

Modified: llvm/trunk/tools/llvm-ld/Optimize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ld/Optimize.cpp?rev=72811&r1=72810&r2=72811&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-ld/Optimize.cpp (original)
+++ llvm/trunk/tools/llvm-ld/Optimize.cpp Wed Jun  3 16:51:32 2009
@@ -94,7 +94,7 @@
 
   if (!DisableOptimizations)
     createStandardLTOPasses(&Passes, !DisableInternalize, !DisableInline,
-                            /*RunSecondGlobalOpt=*/true, VerifyEach);
+                            VerifyEach);
 
   // If the -s or -S command line options were specified, strip the symbols out
   // of the resulting program to make it smaller.  -s and -S are GNU ld options

Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=72811&r1=72810&r2=72811&view=diff

==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Wed Jun  3 16:51:32 2009
@@ -391,7 +391,6 @@
     passes.add(new TargetData(*_target->getTargetData()));
     
     createStandardLTOPasses(&passes, /*Internalize=*/ false, !DisableInline,
-                            /*RunSecondGlobalOpt=*/ false, 
                             /*VerifyEach=*/ false);
 
     // Make sure everything is still good.





More information about the llvm-commits mailing list