[llvm] r214919 - Don't internalize all but main by default.

Rafael Espindola rafael.espindola at gmail.com
Tue Aug 5 13:10:38 PDT 2014


Author: rafael
Date: Tue Aug  5 15:10:38 2014
New Revision: 214919

URL: http://llvm.org/viewvc/llvm-project?rev=214919&view=rev
Log:
Don't internalize all but main by default.

This is mostly a cleanup, but it changes a fairly old behavior.

Every "real" LTO user was already disabling the silly internalize pass
and creating the internalize pass itself. The difference with this
patch is for "opt -std-link-opts" and the C api.

Now to get a usable behavior out of opt one doesn't need the funny
looking command line:

opt -internalize -disable-internalize -internalize-public-api-list=foo,bar -std-link-opts

Removed:
    llvm/trunk/test/Other/link-opts.ll
Modified:
    llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h
    llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
    llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
    llvm/trunk/tools/bugpoint/bugpoint.cpp
    llvm/trunk/tools/opt/opt.cpp

Modified: llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h?rev=214919&r1=214918&r2=214919&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h (original)
+++ llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h Tue Aug  5 15:10:38 2014
@@ -144,8 +144,8 @@ public:
 
   /// populateModulePassManager - This sets up the primary pass manager.
   void populateModulePassManager(PassManagerBase &MPM);
-  void populateLTOPassManager(PassManagerBase &PM, bool Internalize,
-                              bool RunInliner, bool DisableGVNLoadPRE = false);
+  void populateLTOPassManager(PassManagerBase &PM, bool RunInliner,
+                              bool DisableGVNLoadPRE);
 };
 
 /// Registers a function for adding a standard set of passes.  This should be

Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=214919&r1=214918&r2=214919&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Tue Aug  5 15:10:38 2014
@@ -475,10 +475,8 @@ bool LTOCodeGenerator::generateObjectFil
   // keeps only main if it exists and does nothing for libraries. Instead
   // we create the pass ourselves with the symbol list provided by the linker.
   if (!DisableOpt)
-    PassManagerBuilder().populateLTOPassManager(passes,
-                                              /*Internalize=*/false,
-                                              !DisableInline,
-                                              DisableGVNLoadPRE);
+    PassManagerBuilder().populateLTOPassManager(passes, !DisableInline,
+                                                DisableGVNLoadPRE);
 
   // Make sure everything is still good.
   passes.add(createVerifierPass());

Modified: llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=214919&r1=214918&r2=214919&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp Tue Aug  5 15:10:38 2014
@@ -284,18 +284,11 @@ void PassManagerBuilder::populateModuleP
 }
 
 void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM,
-                                                bool Internalize,
                                                 bool RunInliner,
                                                 bool DisableGVNLoadPRE) {
   // Provide AliasAnalysis services for optimizations.
   addInitialAliasAnalysisPasses(PM);
 
-  // Now that composite has been compiled, scan through the module, looking
-  // for a main function.  If main is defined, mark all other functions
-  // internal.
-  if (Internalize)
-    PM.add(createInternalizePass("main"));
-
   // Propagate constants at call sites into the functions they call.  This
   // opens opportunities for globalopt (and inlining) by substituting function
   // pointers passed as arguments to direct uses of functions.
@@ -461,5 +454,5 @@ void LLVMPassManagerBuilderPopulateLTOPa
                                                   LLVMBool RunInliner) {
   PassManagerBuilder *Builder = unwrap(PMB);
   PassManagerBase *LPM = unwrap(PM);
-  Builder->populateLTOPassManager(*LPM, Internalize != 0, RunInliner != 0);
+  Builder->populateLTOPassManager(*LPM, RunInliner != 0, false);
 }

Removed: llvm/trunk/test/Other/link-opts.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/link-opts.ll?rev=214918&view=auto
==============================================================================
--- llvm/trunk/test/Other/link-opts.ll (original)
+++ llvm/trunk/test/Other/link-opts.ll (removed)
@@ -1,13 +0,0 @@
-;RUN: opt -S -std-link-opts < %s | FileCheck %s
-; Simple test to check that -std-link-opts keeps only the main function.
-
-; CHECK-NOT: define
-; CHECK: define void @main
-; CHECK-NOT: define
-define void @main() {
-  ret void
-}
-
-define void @foo() {
-  ret void
-}

Modified: llvm/trunk/tools/bugpoint/bugpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/bugpoint.cpp?rev=214919&r1=214918&r2=214919&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/bugpoint.cpp (original)
+++ llvm/trunk/tools/bugpoint/bugpoint.cpp Tue Aug  5 15:10:38 2014
@@ -179,8 +179,7 @@ int main(int argc, char **argv) {
 
   if (StandardLinkOpts) {
     PassManagerBuilder Builder;
-    Builder.populateLTOPassManager(PM, /*Internalize=*/true,
-                                   /*RunInliner=*/true);
+    Builder.populateLTOPassManager(PM, /*RunInliner=*/true, false);
   }
 
   if (OptLevelO1 || OptLevelO2 || OptLevelO3) {

Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=214919&r1=214918&r2=214919&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Tue Aug  5 15:10:38 2014
@@ -109,10 +109,6 @@ DisableOptimizations("disable-opt",
                      cl::desc("Do not run any optimization passes"));
 
 static cl::opt<bool>
-DisableInternalize("disable-internalize",
-                   cl::desc("Do not mark all symbols as internal"));
-
-static cl::opt<bool>
 StandardCompileOpts("std-compile-opts",
                    cl::desc("Include the standard compile time optimizations"));
 
@@ -271,8 +267,7 @@ static void AddStandardLinkPasses(PassMa
   if (DisableOptimizations) return;
 
   PassManagerBuilder Builder;
-  Builder.populateLTOPassManager(PM, /*Internalize=*/ !DisableInternalize,
-                                 /*RunInliner=*/ !DisableInline);
+  Builder.populateLTOPassManager(PM, /*RunInliner=*/!DisableInline, false);
 }
 
 //===----------------------------------------------------------------------===//





More information about the llvm-commits mailing list