[llvm] r205471 - Revert "Reapply "LTO: add API to set strategy for -internalize""

Duncan P. N. Exon Smith dexonsmith at apple.com
Wed Apr 2 15:05:58 PDT 2014


Author: dexonsmith
Date: Wed Apr  2 17:05:57 2014
New Revision: 205471

URL: http://llvm.org/viewvc/llvm-project?rev=205471&view=rev
Log:
Revert "Reapply "LTO: add API to set strategy for -internalize""

This reverts commit r199244.

Conflicts:
	include/llvm-c/lto.h
	include/llvm/LTO/LTOCodeGenerator.h
	lib/LTO/LTOCodeGenerator.cpp

Modified:
    llvm/trunk/include/llvm-c/lto.h
    llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h
    llvm/trunk/include/llvm/Transforms/IPO.h
    llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
    llvm/trunk/lib/Transforms/IPO/Internalize.cpp
    llvm/trunk/tools/lto/lto.cpp

Modified: llvm/trunk/include/llvm-c/lto.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=205471&r1=205470&r2=205471&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/lto.h (original)
+++ llvm/trunk/include/llvm-c/lto.h Wed Apr  2 17:05:57 2014
@@ -82,15 +82,6 @@ typedef enum {
     LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2
 } lto_codegen_model;
 
-/**
- * \since LTO_API_VERSION=6
- */
-typedef enum {
-    LTO_INTERNALIZE_FULL   = 0,
-    LTO_INTERNALIZE_NONE   = 1,
-    LTO_INTERNALIZE_HIDDEN = 2
-} lto_internalize_strategy;
-
 /** opaque reference to a loaded object module */
 typedef struct LTOModule*         lto_module_t;
 
@@ -403,16 +394,6 @@ lto_codegen_set_assembler_args(lto_code_
                                int nargs);
 
 /**
- * Sets the strategy to use during internalize.  Default strategy is
- * LTO_INTERNALIZE_FULL.
- *
- * \since LTO_API_VERSION=6
- */
-extern void
-lto_codegen_set_internalize_strategy(lto_code_gen_t cg,
-                                     lto_internalize_strategy);
-
-/**
  * Tells LTO optimization passes that this symbol must be preserved
  * because it is referenced by native code or a command line option.
  *

Modified: llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h?rev=205471&r1=205470&r2=205471&view=diff
==============================================================================
--- llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h (original)
+++ llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h Wed Apr  2 17:05:57 2014
@@ -71,7 +71,6 @@ struct LTOCodeGenerator {
   void setTargetOptions(llvm::TargetOptions options);
   void setDebugInfo(lto_debug_model);
   void setCodePICModel(lto_codegen_model);
-  void setInternalizeStrategy(lto_internalize_strategy);
 
   void setCpu(const char *mCpu) { MCpu = mCpu; }
 
@@ -118,14 +117,6 @@ struct LTOCodeGenerator {
 
   void setDiagnosticHandler(lto_diagnostic_handler_t, void *);
 
-  bool shouldInternalize() const {
-    return InternalizeStrategy != LTO_INTERNALIZE_NONE;
-  }
-
-  bool shouldOnlyInternalizeHidden() const {
-    return InternalizeStrategy == LTO_INTERNALIZE_HIDDEN;
-  }
-
 private:
   void initializeLTOPasses();
 
@@ -154,7 +145,6 @@ private:
   bool EmitDwarfDebugInfo;
   bool ScopeRestrictionsDone;
   lto_codegen_model CodeModel;
-  lto_internalize_strategy InternalizeStrategy;
   StringSet MustPreserveSymbols;
   StringSet AsmUndefinedRefs;
   llvm::MemoryBuffer *NativeObjectFile;

Modified: llvm/trunk/include/llvm/Transforms/IPO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO.h?rev=205471&r1=205470&r2=205471&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/IPO.h (original)
+++ llvm/trunk/include/llvm/Transforms/IPO.h Wed Apr  2 17:05:57 2014
@@ -112,19 +112,14 @@ Pass *createPruneEHPass();
 ////
 /// The symbols in \p ExportList are never internalized.
 ///
-/// When OnlyHidden=true, only symbols with hidden visibility are internalized.
-///
 /// The symbol in DSOList are internalized if it is safe to drop them from
 /// the symbol table.
 ///
 /// Note that commandline options that are used with the above function are not
 /// used now!
-ModulePass *createInternalizePass(ArrayRef<const char *> ExportList,
-                                  bool OnlyHidden = false);
+ModulePass *createInternalizePass(ArrayRef<const char *> ExportList);
 /// createInternalizePass - Same as above, but with an empty exportList.
-ModulePass *createInternalizePass(bool OnlyHidden = false);
-/// createInternalizePass - Resolve ambiguity when passed a const char *.
-ModulePass *createInternalizePass(const char *SingleExport);
+ModulePass *createInternalizePass();
 
 //===----------------------------------------------------------------------===//
 /// createDeadArgEliminationPass - This pass removes arguments from functions

Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=205471&r1=205470&r2=205471&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Wed Apr  2 17:05:57 2014
@@ -65,8 +65,7 @@ const char* LTOCodeGenerator::getVersion
 LTOCodeGenerator::LTOCodeGenerator()
     : Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)),
       TargetMach(NULL), EmitDwarfDebugInfo(false), ScopeRestrictionsDone(false),
-      CodeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
-      InternalizeStrategy(LTO_INTERNALIZE_FULL), NativeObjectFile(NULL),
+      CodeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC), NativeObjectFile(NULL),
       DiagHandler(NULL), DiagContext(NULL) {
   initializeLTOPasses();
 }
@@ -169,18 +168,6 @@ void LTOCodeGenerator::setCodePICModel(l
   llvm_unreachable("Unknown PIC model!");
 }
 
-void
-LTOCodeGenerator::setInternalizeStrategy(lto_internalize_strategy Strategy) {
-  switch (Strategy) {
-  case LTO_INTERNALIZE_FULL:
-  case LTO_INTERNALIZE_NONE:
-  case LTO_INTERNALIZE_HIDDEN:
-    InternalizeStrategy = Strategy;
-    return;
-  }
-  llvm_unreachable("Unknown internalize strategy!");
-}
-
 bool LTOCodeGenerator::writeMergedModules(const char *path,
                                           std::string &errMsg) {
   if (!determineTarget(errMsg))
@@ -402,7 +389,7 @@ static void accumulateAndSortLibcalls(st
 }
 
 void LTOCodeGenerator::applyScopeRestrictions() {
-  if (ScopeRestrictionsDone || !shouldInternalize())
+  if (ScopeRestrictionsDone)
     return;
   Module *mergedModule = Linker.getModule();
 
@@ -454,8 +441,7 @@ void LTOCodeGenerator::applyScopeRestric
     LLVMCompilerUsed->setSection("llvm.metadata");
   }
 
-  passes.add(
-      createInternalizePass(MustPreserveList, shouldOnlyInternalizeHidden()));
+  passes.add(createInternalizePass(MustPreserveList));
 
   // apply scope restrictions
   passes.run(*mergedModule);

Modified: llvm/trunk/lib/Transforms/IPO/Internalize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Internalize.cpp?rev=205471&r1=205470&r2=205471&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Internalize.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Internalize.cpp Wed Apr  2 17:05:57 2014
@@ -54,11 +54,10 @@ APIList("internalize-public-api-list", c
 namespace {
   class InternalizePass : public ModulePass {
     std::set<std::string> ExternalNames;
-    bool OnlyHidden;
   public:
     static char ID; // Pass identification, replacement for typeid
-    explicit InternalizePass(bool OnlyHidden = false);
-    explicit InternalizePass(ArrayRef<const char *> ExportList, bool OnlyHidden);
+    explicit InternalizePass();
+    explicit InternalizePass(ArrayRef<const char *> ExportList);
     void LoadFile(const char *Filename);
     bool runOnModule(Module &M) override;
 
@@ -73,17 +72,15 @@ char InternalizePass::ID = 0;
 INITIALIZE_PASS(InternalizePass, "internalize",
                 "Internalize Global Symbols", false, false)
 
-InternalizePass::InternalizePass(bool OnlyHidden)
-  : ModulePass(ID), OnlyHidden(OnlyHidden) {
+InternalizePass::InternalizePass() : ModulePass(ID) {
   initializeInternalizePassPass(*PassRegistry::getPassRegistry());
   if (!APIFile.empty())           // If a filename is specified, use it.
     LoadFile(APIFile.c_str());
   ExternalNames.insert(APIList.begin(), APIList.end());
 }
 
-InternalizePass::InternalizePass(ArrayRef<const char *> ExportList,
-                                 bool OnlyHidden)
-  : ModulePass(ID), OnlyHidden(OnlyHidden) {
+InternalizePass::InternalizePass(ArrayRef<const char *> ExportList)
+    : ModulePass(ID) {
   initializeInternalizePassPass(*PassRegistry::getPassRegistry());
   for(ArrayRef<const char *>::const_iterator itr = ExportList.begin();
         itr != ExportList.end(); itr++) {
@@ -108,11 +105,7 @@ void InternalizePass::LoadFile(const cha
 }
 
 static bool shouldInternalize(const GlobalValue &GV,
-                              const std::set<std::string> &ExternalNames,
-                              bool OnlyHidden) {
-  if (OnlyHidden && !GV.hasHiddenVisibility())
-    return false;
-
+                              const std::set<std::string> &ExternalNames) {
   // Function must be defined here
   if (GV.isDeclaration())
     return false;
@@ -162,7 +155,7 @@ bool InternalizePass::runOnModule(Module
 
   // Mark all functions not in the api as internal.
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
-    if (!shouldInternalize(*I, ExternalNames, OnlyHidden))
+    if (!shouldInternalize(*I, ExternalNames))
       continue;
 
     I->setLinkage(GlobalValue::InternalLinkage);
@@ -198,7 +191,7 @@ bool InternalizePass::runOnModule(Module
   // internal as well.
   for (Module::global_iterator I = M.global_begin(), E = M.global_end();
        I != E; ++I) {
-    if (!shouldInternalize(*I, ExternalNames, OnlyHidden))
+    if (!shouldInternalize(*I, ExternalNames))
       continue;
 
     I->setLinkage(GlobalValue::InternalLinkage);
@@ -210,7 +203,7 @@ bool InternalizePass::runOnModule(Module
   // Mark all aliases that are not in the api as internal as well.
   for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end();
        I != E; ++I) {
-    if (!shouldInternalize(*I, ExternalNames, OnlyHidden))
+    if (!shouldInternalize(*I, ExternalNames))
       continue;
 
     I->setLinkage(GlobalValue::InternalLinkage);
@@ -222,15 +215,8 @@ bool InternalizePass::runOnModule(Module
   return Changed;
 }
 
-ModulePass *llvm::createInternalizePass(bool OnlyHidden) {
-  return new InternalizePass(OnlyHidden);
-}
-
-ModulePass *llvm::createInternalizePass(ArrayRef<const char *> ExportList,
-                                        bool OnlyHidden) {
-  return new InternalizePass(ExportList, OnlyHidden);
-}
+ModulePass *llvm::createInternalizePass() { return new InternalizePass(); }
 
-ModulePass *llvm::createInternalizePass(const char *SingleExport) {
-  return createInternalizePass(ArrayRef<const char *>(SingleExport));
+ModulePass *llvm::createInternalizePass(ArrayRef<const char *> ExportList) {
+  return new InternalizePass(ExportList);
 }

Modified: llvm/trunk/tools/lto/lto.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=205471&r1=205470&r2=205471&view=diff
==============================================================================
--- llvm/trunk/tools/lto/lto.cpp (original)
+++ llvm/trunk/tools/lto/lto.cpp Wed Apr  2 17:05:57 2014
@@ -264,13 +264,6 @@ void lto_codegen_set_assembler_args(lto_
   // In here only for backwards compatibility. We use MC now.
 }
 
-/// lto_codegen_set_internalize_strategy - Sets the strategy to use during
-/// internalize.
-void lto_codegen_set_internalize_strategy(lto_code_gen_t cg,
-                                          lto_internalize_strategy strategy) {
-  cg->setInternalizeStrategy(strategy);
-}
-
 /// lto_codegen_add_must_preserve_symbol - Adds to a list of all global symbols
 /// that must exist in the final generated code. If a function is not listed
 /// there, it might be inlined into every usage and optimized away.





More information about the llvm-commits mailing list