Don't internalize all but main by default.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 5 Aug 2014 20:10:38 +0000 (20:10 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 5 Aug 2014 20:10:38 +0000 (20:10 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214919 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Transforms/IPO/PassManagerBuilder.h
lib/LTO/LTOCodeGenerator.cpp
lib/Transforms/IPO/PassManagerBuilder.cpp
test/Other/link-opts.ll [deleted file]
tools/bugpoint/bugpoint.cpp
tools/opt/opt.cpp

index 50877d013702095421cdf40773bae07f227b764f..71b2426a52bd61b107b16f3b953af93d7732a0b5 100644 (file)
@@ -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
index fe179cf1ac6e4a3eab0eb29eda6f3564412c00e3..a51b1c9df8b10be41874d40cabcf5b25e81b7fe1 100644 (file)
@@ -475,10 +475,8 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
   // 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());
index 98477b5d71fc8bc1e4681bacecb5da07c99e39be..3d846b01d3a703b7e6f3227b888d89373e1077bf 100644 (file)
@@ -284,18 +284,11 @@ void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
 }
 
 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 LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB,
                                                   LLVMBool RunInliner) {
   PassManagerBuilder *Builder = unwrap(PMB);
   PassManagerBase *LPM = unwrap(PM);
-  Builder->populateLTOPassManager(*LPM, Internalize != 0, RunInliner != 0);
+  Builder->populateLTOPassManager(*LPM, RunInliner != 0, false);
 }
diff --git a/test/Other/link-opts.ll b/test/Other/link-opts.ll
deleted file mode 100644 (file)
index 8e58ac8..0000000
+++ /dev/null
@@ -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
-}
index c7dae0f45b663bb6e6ca3eb8575e6d14aa827d1b..cbecc3599700caea085600f7c92b988664c526bd 100644 (file)
@@ -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) {
index 6ba6340040b35d109e9c4c937a7231bf1d708bf2..1ff795d67d22c2417796534ac3d02d323e8a3ecb 100644 (file)
@@ -108,10 +108,6 @@ static cl::opt<bool>
 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(PassManagerBase &PM) {
   if (DisableOptimizations) return;
 
   PassManagerBuilder Builder;
-  Builder.populateLTOPassManager(PM, /*Internalize=*/ !DisableInternalize,
-                                 /*RunInliner=*/ !DisableInline);
+  Builder.populateLTOPassManager(PM, /*RunInliner=*/!DisableInline, false);
 }
 
 //===----------------------------------------------------------------------===//