diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-03-13 23:18:37 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-03-13 23:18:37 +0000 |
| commit | 2fb5bc33a3054da6d8eb3d71d274fc30cc4f22cd (patch) | |
| tree | a0b08933e135ce640151d9b04242ef09997cbc52 /llvm/lib | |
| parent | 16c6bf49b7d7c41f45b334912c5fe4bc7528fa7c (diff) | |
| download | bcm5719-llvm-2fb5bc33a3054da6d8eb3d71d274fc30cc4f22cd.tar.gz bcm5719-llvm-2fb5bc33a3054da6d8eb3d71d274fc30cc4f22cd.zip | |
Remove the linker_private and linker_private_weak linkages.
These linkages were introduced some time ago, but it was never very
clear what exactly their semantics were or what they should be used
for. Some investigation found these uses:
* utf-16 strings in clang.
* non-unnamed_addr strings produced by the sanitizers.
It turns out they were just working around a more fundamental problem.
For some sections a MachO linker needs a symbol in order to split the
section into atoms, and llvm had no idea that was the case. I fixed
that in r201700 and it is now safe to use the private linkage. When
the object ends up in a section that requires symbols, llvm will use a
'l' prefix instead of a 'L' prefix and things just work.
With that, these linkages were already dead, but there was a potential
future user in the objc metadata information. I am still looking at
CGObjcMac.cpp, but at this point I am convinced that linker_private
and linker_private_weak are not what they need.
The objc uses are currently split in
* Regular symbols (no '\01' prefix). LLVM already directly provides
whatever semantics they need.
* Uses of a private name (start with "\01L" or "\01l") and private
linkage. We can drop the "\01L" and "\01l" prefixes as soon as llvm
agrees with clang on L being ok or not for a given section. I have two
patches in code review for this.
* Uses of private name and weak linkage.
The last case is the one that one could think would fit one of these
linkages. That is not the case. The semantics are
* the linker will merge these symbol by *name*.
* the linker will hide them in the final DSO.
Given that the merging is done by name, any of the private (or
internal) linkages would be a bad match. They allow llvm to rename the
symbols, and that is really not what we want. From the llvm point of
view, these objects should really be (linkonce|weak)(_odr)?.
For now, just keeping the "\01l" prefix is probably the best for these
symbols. If we one day want to have a more direct support in llvm,
IMHO what we should add is not a linkage, it is just a hidden_symbol
attribute. It would be applicable to multiple linkages. For example,
on weak it would produce the current behavior we have for objc
metadata. On internal, it would be equivalent to private (and we
should then remove private).
llvm-svn: 203866
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/AsmParser/LLLexer.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 10 | ||||
| -rw-r--r-- | llvm/lib/AsmParser/LLToken.h | 2 | ||||
| -rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/IR/Core.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/IR/Mangler.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/LTO/LTOModule.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/Object/IRObjectFile.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Target/CppBackend/CPPBackend.cpp | 4 |
12 files changed, 10 insertions, 42 deletions
diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp index 00b137d5a7a..1a5eec3db7d 100644 --- a/llvm/lib/AsmParser/LLLexer.cpp +++ b/llvm/lib/AsmParser/LLLexer.cpp @@ -480,8 +480,6 @@ lltok::Kind LLLexer::LexIdentifier() { KEYWORD(global); KEYWORD(constant); KEYWORD(private); - KEYWORD(linker_private); - KEYWORD(linker_private_weak); KEYWORD(internal); KEYWORD(available_externally); KEYWORD(linkonce); diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index f75d3c944a5..37151e68cb2 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -246,8 +246,6 @@ bool LLParser::ParseTopLevelEntities() { // OptionalThreadLocal OptionalAddrSpace OptionalUnNammedAddr // ('constant'|'global') ... case lltok::kw_private: // OptionalLinkage - case lltok::kw_linker_private: // OptionalLinkage - case lltok::kw_linker_private_weak: // OptionalLinkage case lltok::kw_internal: // OptionalLinkage case lltok::kw_weak: // OptionalLinkage case lltok::kw_weak_odr: // OptionalLinkage @@ -1278,8 +1276,6 @@ bool LLParser::ParseOptionalReturnAttrs(AttrBuilder &B) { /// ParseOptionalLinkage /// ::= /*empty*/ /// ::= 'private' -/// ::= 'linker_private' -/// ::= 'linker_private_weak' /// ::= 'internal' /// ::= 'weak' /// ::= 'weak_odr' @@ -1295,10 +1291,6 @@ bool LLParser::ParseOptionalLinkage(unsigned &Res, bool &HasLinkage) { switch (Lex.getKind()) { default: Res=GlobalValue::ExternalLinkage; return false; case lltok::kw_private: Res = GlobalValue::PrivateLinkage; break; - case lltok::kw_linker_private: Res = GlobalValue::LinkerPrivateLinkage; break; - case lltok::kw_linker_private_weak: - Res = GlobalValue::LinkerPrivateWeakLinkage; - break; case lltok::kw_internal: Res = GlobalValue::InternalLinkage; break; case lltok::kw_weak: Res = GlobalValue::WeakAnyLinkage; break; case lltok::kw_weak_odr: Res = GlobalValue::WeakODRLinkage; break; @@ -2992,8 +2984,6 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) { return Error(LinkageLoc, "invalid linkage for function definition"); break; case GlobalValue::PrivateLinkage: - case GlobalValue::LinkerPrivateLinkage: - case GlobalValue::LinkerPrivateWeakLinkage: case GlobalValue::InternalLinkage: case GlobalValue::AvailableExternallyLinkage: case GlobalValue::LinkOnceAnyLinkage: diff --git a/llvm/lib/AsmParser/LLToken.h b/llvm/lib/AsmParser/LLToken.h index 67f2c0c42b7..532e896b182 100644 --- a/llvm/lib/AsmParser/LLToken.h +++ b/llvm/lib/AsmParser/LLToken.h @@ -37,7 +37,7 @@ namespace lltok { kw_declare, kw_define, kw_global, kw_constant, - kw_private, kw_linker_private, kw_linker_private_weak, + kw_private, kw_internal, kw_linkonce, kw_linkonce_odr, kw_weak, kw_weak_odr, kw_appending, diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index eb716660eb4..19528c8e67b 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -88,8 +88,10 @@ static GlobalValue::LinkageTypes GetDecodedLinkage(unsigned Val) { case 10: return GlobalValue::WeakODRLinkage; case 11: return GlobalValue::LinkOnceODRLinkage; case 12: return GlobalValue::AvailableExternallyLinkage; - case 13: return GlobalValue::LinkerPrivateLinkage; - case 14: return GlobalValue::LinkerPrivateWeakLinkage; + case 13: + return GlobalValue::PrivateLinkage; // Obsolete LinkerPrivateLinkage + case 14: + return GlobalValue::PrivateLinkage; // Obsolete LinkerPrivateWeakLinkage } } diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index d390eedd362..5d1dac1e233 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -487,8 +487,6 @@ static unsigned getEncodedLinkage(const GlobalValue *GV) { case GlobalValue::WeakODRLinkage: return 10; case GlobalValue::LinkOnceODRLinkage: return 11; case GlobalValue::AvailableExternallyLinkage: return 12; - case GlobalValue::LinkerPrivateLinkage: return 13; - case GlobalValue::LinkerPrivateWeakLinkage: return 14; } llvm_unreachable("Invalid linkage"); } diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 66ce4e1075d..81316625704 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -272,7 +272,6 @@ void AsmPrinter::EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const { case GlobalValue::LinkOnceODRLinkage: case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakODRLinkage: - case GlobalValue::LinkerPrivateWeakLinkage: if (MAI->hasWeakDefDirective()) { // .globl _foo OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global); @@ -301,7 +300,6 @@ void AsmPrinter::EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const { return; case GlobalValue::PrivateLinkage: case GlobalValue::InternalLinkage: - case GlobalValue::LinkerPrivateLinkage: return; case GlobalValue::AvailableExternallyLinkage: llvm_unreachable("Should never emit this"); diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index a528e5f326b..93a59a63c89 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -1391,10 +1391,6 @@ static void PrintLinkage(GlobalValue::LinkageTypes LT, switch (LT) { case GlobalValue::ExternalLinkage: break; case GlobalValue::PrivateLinkage: Out << "private "; break; - case GlobalValue::LinkerPrivateLinkage: Out << "linker_private "; break; - case GlobalValue::LinkerPrivateWeakLinkage: - Out << "linker_private_weak "; - break; case GlobalValue::InternalLinkage: Out << "internal "; break; case GlobalValue::LinkOnceAnyLinkage: Out << "linkonce "; break; case GlobalValue::LinkOnceODRLinkage: Out << "linkonce_odr "; break; diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 4f3d8b19755..f52f46616c7 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -1159,10 +1159,6 @@ LLVMLinkage LLVMGetLinkage(LLVMValueRef Global) { return LLVMInternalLinkage; case GlobalValue::PrivateLinkage: return LLVMPrivateLinkage; - case GlobalValue::LinkerPrivateLinkage: - return LLVMLinkerPrivateLinkage; - case GlobalValue::LinkerPrivateWeakLinkage: - return LLVMLinkerPrivateWeakLinkage; case GlobalValue::ExternalWeakLinkage: return LLVMExternalWeakLinkage; case GlobalValue::CommonLinkage: @@ -1208,10 +1204,10 @@ void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage) { GV->setLinkage(GlobalValue::PrivateLinkage); break; case LLVMLinkerPrivateLinkage: - GV->setLinkage(GlobalValue::LinkerPrivateLinkage); + GV->setLinkage(GlobalValue::PrivateLinkage); break; case LLVMLinkerPrivateWeakLinkage: - GV->setLinkage(GlobalValue::LinkerPrivateWeakLinkage); + GV->setLinkage(GlobalValue::PrivateLinkage); break; case LLVMDLLImportLinkage: DEBUG(errs() diff --git a/llvm/lib/IR/Mangler.cpp b/llvm/lib/IR/Mangler.cpp index 4ee2cd2c935..d82388fdbf4 100644 --- a/llvm/lib/IR/Mangler.cpp +++ b/llvm/lib/IR/Mangler.cpp @@ -84,9 +84,6 @@ void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, PrefixTy = Mangler::LinkerPrivate; else PrefixTy = Mangler::Private; - } else if (GV->hasLinkerPrivateLinkage() || - GV->hasLinkerPrivateWeakLinkage()) { - PrefixTy = Mangler::LinkerPrivate; } if (!GV->hasName()) { diff --git a/llvm/lib/LTO/LTOModule.cpp b/llvm/lib/LTO/LTOModule.cpp index e2ef18db2ee..7387416ac73 100644 --- a/llvm/lib/LTO/LTOModule.cpp +++ b/llvm/lib/LTO/LTOModule.cpp @@ -408,8 +408,7 @@ void LTOModule::addDefinedSymbol(const GlobalValue *def, bool isFunction) { } // set definition part - if (def->hasWeakLinkage() || def->hasLinkOnceLinkage() || - def->hasLinkerPrivateWeakLinkage()) + if (def->hasWeakLinkage() || def->hasLinkOnceLinkage()) attr |= LTO_SYMBOL_DEFINITION_WEAK; else if (def->hasCommonLinkage()) attr |= LTO_SYMBOL_DEFINITION_TENTATIVE; @@ -424,8 +423,7 @@ void LTOModule::addDefinedSymbol(const GlobalValue *def, bool isFunction) { else if (canBeHidden(def)) attr |= LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN; else if (def->hasExternalLinkage() || def->hasWeakLinkage() || - def->hasLinkOnceLinkage() || def->hasCommonLinkage() || - def->hasLinkerPrivateWeakLinkage()) + def->hasLinkOnceLinkage() || def->hasCommonLinkage()) attr |= LTO_SYMBOL_SCOPE_DEFAULT; else attr |= LTO_SYMBOL_SCOPE_INTERNAL; diff --git a/llvm/lib/Object/IRObjectFile.cpp b/llvm/lib/Object/IRObjectFile.cpp index d5ea80d1d0e..a8aba26c5ae 100644 --- a/llvm/lib/Object/IRObjectFile.cpp +++ b/llvm/lib/Object/IRObjectFile.cpp @@ -110,8 +110,7 @@ uint32_t IRObjectFile::getSymbolFlags(DataRefImpl Symb) const { uint32_t Res = BasicSymbolRef::SF_None; if (GV.isDeclaration() || GV.hasAvailableExternallyLinkage()) Res |= BasicSymbolRef::SF_Undefined; - if (GV.hasPrivateLinkage() || GV.hasLinkerPrivateLinkage() || - GV.hasLinkerPrivateWeakLinkage()) + if (GV.hasPrivateLinkage()) Res |= BasicSymbolRef::SF_FormatSpecific; if (!GV.hasLocalLinkage()) Res |= BasicSymbolRef::SF_Global; diff --git a/llvm/lib/Target/CppBackend/CPPBackend.cpp b/llvm/lib/Target/CppBackend/CPPBackend.cpp index 31585d9296e..afd1f518cc2 100644 --- a/llvm/lib/Target/CppBackend/CPPBackend.cpp +++ b/llvm/lib/Target/CppBackend/CPPBackend.cpp @@ -283,10 +283,6 @@ void CppWriter::printLinkageType(GlobalValue::LinkageTypes LT) { Out << "GlobalValue::InternalLinkage"; break; case GlobalValue::PrivateLinkage: Out << "GlobalValue::PrivateLinkage"; break; - case GlobalValue::LinkerPrivateLinkage: - Out << "GlobalValue::LinkerPrivateLinkage"; break; - case GlobalValue::LinkerPrivateWeakLinkage: - Out << "GlobalValue::LinkerPrivateWeakLinkage"; break; case GlobalValue::AvailableExternallyLinkage: Out << "GlobalValue::AvailableExternallyLinkage "; break; case GlobalValue::LinkOnceAnyLinkage: |

