diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-04-02 22:05:57 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-04-02 22:05:57 +0000 |
commit | 3845c071a7b4ff54d7d8ff4642a66e3a666349d1 (patch) | |
tree | 4162e4420434e64a5f60e7dc60427bcfd1279f57 /lib | |
parent | 172e0ca8c5c7af54cd88a0620ccb72fccce0abef (diff) | |
download | llvm-3845c071a7b4ff54d7d8ff4642a66e3a666349d1.tar.gz llvm-3845c071a7b4ff54d7d8ff4642a66e3a666349d1.tar.bz2 llvm-3845c071a7b4ff54d7d8ff4642a66e3a666349d1.tar.xz |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205471 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/LTO/LTOCodeGenerator.cpp | 20 | ||||
-rw-r--r-- | lib/Transforms/IPO/Internalize.cpp | 38 |
2 files changed, 15 insertions, 43 deletions
diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp index b7f41357af..51d0899881 100644 --- a/lib/LTO/LTOCodeGenerator.cpp +++ b/lib/LTO/LTOCodeGenerator.cpp @@ -65,8 +65,7 @@ const char* LTOCodeGenerator::getVersionString() { 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(lto_codegen_model model) { 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(std::vector<StringRef> &Libcalls, } void LTOCodeGenerator::applyScopeRestrictions() { - if (ScopeRestrictionsDone || !shouldInternalize()) + if (ScopeRestrictionsDone) return; Module *mergedModule = Linker.getModule(); @@ -454,8 +441,7 @@ void LTOCodeGenerator::applyScopeRestrictions() { LLVMCompilerUsed->setSection("llvm.metadata"); } - passes.add( - createInternalizePass(MustPreserveList, shouldOnlyInternalizeHidden())); + passes.add(createInternalizePass(MustPreserveList)); // apply scope restrictions passes.run(*mergedModule); diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp index 29a01bd080..c1fe01cebc 100644 --- a/lib/Transforms/IPO/Internalize.cpp +++ b/lib/Transforms/IPO/Internalize.cpp @@ -54,11 +54,10 @@ APIList("internalize-public-api-list", cl::value_desc("list"), 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 char *Filename) { } 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 &M) { // 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 &M) { // 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 &M) { // 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 &M) { 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); } |