diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2017-02-02 05:12:15 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2017-02-02 05:12:15 +0000 |
commit | c387e70c699330dbfb6599a005a281960ca6da70 (patch) | |
tree | e2aec70573611a8e47d21e6217b285e62a686324 /llvm/lib/LTO/LTO.cpp | |
parent | 1116d6915cefd57fb6f20540f10a7859a214cae8 (diff) | |
download | bcm5719-llvm-c387e70c699330dbfb6599a005a281960ca6da70.tar.gz bcm5719-llvm-c387e70c699330dbfb6599a005a281960ca6da70.zip |
Linker: Move special casing for available_externally in IRMover to clients. NFCI.
The goal is to simplify the semantic model for clients of IRMover.
Differential Revision: https://reviews.llvm.org/D29435
llvm-svn: 293864
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index e602c64337c..4d0c039891e 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -455,20 +455,29 @@ Error LTO::addRegularLTO(BitcodeModule BM, const SymbolResolution *&ResI, SymbolResolution Res = *ResI++; addSymbolToGlobalRes(Used, Sym, Res, 0); - if (Sym.getFlags() & object::BasicSymbolRef::SF_Undefined) - continue; - if (Res.Prevailing && Sym.isGV()) { + if (Sym.isGV()) { GlobalValue *GV = Sym.getGV(); - Keep.push_back(GV); - switch (GV->getLinkage()) { - default: - break; - case GlobalValue::LinkOnceAnyLinkage: - GV->setLinkage(GlobalValue::WeakAnyLinkage); - break; - case GlobalValue::LinkOnceODRLinkage: - GV->setLinkage(GlobalValue::WeakODRLinkage); - break; + if (Res.Prevailing) { + if (Sym.getFlags() & object::BasicSymbolRef::SF_Undefined) + continue; + Keep.push_back(GV); + switch (GV->getLinkage()) { + default: + break; + case GlobalValue::LinkOnceAnyLinkage: + GV->setLinkage(GlobalValue::WeakAnyLinkage); + break; + case GlobalValue::LinkOnceODRLinkage: + GV->setLinkage(GlobalValue::WeakODRLinkage); + break; + } + } else if (GV->hasAvailableExternallyLinkage()) { + // We can link available_externally symbols even if they are + // non-prevailing. + GlobalValue *CombinedGV = + RegularLTO.CombinedModule->getNamedValue(GV->getName()); + if (!CombinedGV || CombinedGV->isDeclaration()) + Keep.push_back(GV); } } // Common resolution: collect the maximum size/alignment over all commons. |