diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-10-03 18:29:09 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-10-03 18:29:09 +0000 |
commit | 438900938c3ac9d7fac2dd5d2c85ca4b9b2e35f7 (patch) | |
tree | ee292d94cfa7c8661cc4cd598f32e66289df9aeb /lib/LTO/LTOCodeGenerator.cpp | |
parent | 1df59ef1aa271a4e33cf8973e14bcaf55c585231 (diff) | |
download | llvm-438900938c3ac9d7fac2dd5d2c85ca4b9b2e35f7.tar.gz llvm-438900938c3ac9d7fac2dd5d2c85ca4b9b2e35f7.tar.bz2 llvm-438900938c3ac9d7fac2dd5d2c85ca4b9b2e35f7.tar.xz |
Optimize linkonce_odr unnamed_addr functions during LTO.
Generalize the API so we can distinguish symbols that are needed just for a DSO
symbol table from those that are used from some native .o.
The symbols that are only wanted for the dso symbol table can be dropped if
llvm can prove every other dso has a copy (linkonce_odr) and the address is not
important (unnamed_addr).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191922 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/LTO/LTOCodeGenerator.cpp')
-rw-r--r-- | lib/LTO/LTOCodeGenerator.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp index 3abb6238b3..e35e33666e 100644 --- a/lib/LTO/LTOCodeGenerator.cpp +++ b/lib/LTO/LTOCodeGenerator.cpp @@ -310,6 +310,7 @@ bool LTOCodeGenerator::determineTarget(std::string &errMsg) { void LTOCodeGenerator:: applyRestriction(GlobalValue &GV, std::vector<const char*> &MustPreserveList, + std::vector<const char*> &DSOList, SmallPtrSet<GlobalValue*, 8> &AsmUsed, Mangler &Mangler) { SmallString<64> Buffer; @@ -319,6 +320,8 @@ applyRestriction(GlobalValue &GV, return; if (MustPreserveSymbols.count(Buffer)) MustPreserveList.push_back(GV.getName().data()); + if (DSOSymbols.count(Buffer)) + DSOList.push_back(GV.getName().data()); if (AsmUndefinedRefs.count(Buffer)) AsmUsed.insert(&GV); } @@ -348,17 +351,18 @@ void LTOCodeGenerator::applyScopeRestrictions() { NULL); Mangler Mangler(MContext, TargetMach); std::vector<const char*> MustPreserveList; + std::vector<const char*> DSOList; SmallPtrSet<GlobalValue*, 8> AsmUsed; for (Module::iterator f = mergedModule->begin(), e = mergedModule->end(); f != e; ++f) - applyRestriction(*f, MustPreserveList, AsmUsed, Mangler); + applyRestriction(*f, MustPreserveList, DSOList, AsmUsed, Mangler); for (Module::global_iterator v = mergedModule->global_begin(), e = mergedModule->global_end(); v != e; ++v) - applyRestriction(*v, MustPreserveList, AsmUsed, Mangler); + applyRestriction(*v, MustPreserveList, DSOList, AsmUsed, Mangler); for (Module::alias_iterator a = mergedModule->alias_begin(), e = mergedModule->alias_end(); a != e; ++a) - applyRestriction(*a, MustPreserveList, AsmUsed, Mangler); + applyRestriction(*a, MustPreserveList, DSOList, AsmUsed, Mangler); GlobalVariable *LLVMCompilerUsed = mergedModule->getGlobalVariable("llvm.compiler.used"); @@ -386,7 +390,7 @@ void LTOCodeGenerator::applyScopeRestrictions() { LLVMCompilerUsed->setSection("llvm.metadata"); } - passes.add(createInternalizePass(MustPreserveList)); + passes.add(createInternalizePass(MustPreserveList, DSOList)); // apply scope restrictions passes.run(*mergedModule); |