diff --git a/docs/LangRef.html b/docs/LangRef.html
index 44e6fa126e0..4fb712ee3bb 100644
--- a/docs/LangRef.html
+++ b/docs/LangRef.html
@@ -20,7 +20,24 @@
High Level Structure
- Module Structure
- - Linkage Types
+ - Linkage Types
+
+ - private
+ - linker_private
+ - internal
+ - available_externally
+ - linkonce
+ - common
+ - weak
+ - appending
+ - extern_weak
+ - linkonce_odr
+ - weak_odr
+ - externally visible
+ - dllimport
+ - dllexport
+
+
- Calling Conventions
- Named Types
- Global Variables
@@ -502,6 +519,11 @@ All Global Variables and Functions have one of the following types of linkage:
object file.
+ - linker_private:
+
+ - Similar to private, but the symbol is passed through the assembler and
+ removed by the linker after evaluation.
+
- internal:
- Similar to private, but the value shows as a local symbol (STB_LOCAL in
@@ -509,7 +531,7 @@ All Global Variables and Functions have one of the following types of linkage:
'static' keyword in C.
- - available_externally:
+
- available_externally:
- Globals with "available_externally" linkage are never emitted
diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h
index 71e71a9c998..5d4b091ece3 100644
--- a/include/llvm-c/Core.h
+++ b/include/llvm-c/Core.h
@@ -141,6 +141,7 @@ typedef enum {
LLVMInternalLinkage, /**< Rename collisions when linking (static
functions) */
LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
+ LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
LLVMDLLImportLinkage, /**< Function to be imported from DLL */
LLVMDLLExportLinkage, /**< Function to be accessible from DLL */
LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
diff --git a/include/llvm/GlobalValue.h b/include/llvm/GlobalValue.h
index 0df7ababed7..b897f9f6bba 100644
--- a/include/llvm/GlobalValue.h
+++ b/include/llvm/GlobalValue.h
@@ -37,13 +37,14 @@ public:
WeakAnyLinkage, ///< Keep one copy of named function when linking (weak)
WeakODRLinkage, ///< Same, but only replaced by something equivalent.
AppendingLinkage, ///< Special purpose, only applies to global arrays
- InternalLinkage, ///< Rename collisions when linking (static functions)
- PrivateLinkage, ///< Like Internal, but omit from symbol table
+ InternalLinkage, ///< Rename collisions when linking (static functions).
+ PrivateLinkage, ///< Like Internal, but omit from symbol table.
+ LinkerPrivateLinkage, ///< Like Private, but linker removes.
DLLImportLinkage, ///< Function to be imported from DLL
- DLLExportLinkage, ///< Function to be accessible from DLL
- ExternalWeakLinkage,///< ExternalWeak linkage description
- GhostLinkage, ///< Stand-in functions for streaming fns from BC files
- CommonLinkage ///< Tentative definitions
+ DLLExportLinkage, ///< Function to be accessible from DLL.
+ ExternalWeakLinkage,///< ExternalWeak linkage description.
+ GhostLinkage, ///< Stand-in functions for streaming fns from BC files.
+ CommonLinkage ///< Tentative definitions.
};
/// @brief An enumeration for the kinds of visibility of global values.
@@ -123,8 +124,10 @@ public:
bool hasAppendingLinkage() const { return Linkage == AppendingLinkage; }
bool hasInternalLinkage() const { return Linkage == InternalLinkage; }
bool hasPrivateLinkage() const { return Linkage == PrivateLinkage; }
+ bool hasLinkerPrivateLinkage() const { return Linkage==LinkerPrivateLinkage; }
bool hasLocalLinkage() const {
- return Linkage == InternalLinkage || Linkage == PrivateLinkage;
+ return hasInternalLinkage() || hasPrivateLinkage() ||
+ hasLinkerPrivateLinkage();
}
bool hasDLLImportLinkage() const { return Linkage == DLLImportLinkage; }
bool hasDLLExportLinkage() const { return Linkage == DLLExportLinkage; }
diff --git a/include/llvm/Support/Mangler.h b/include/llvm/Support/Mangler.h
index e04245dc2b5..416f382bef4 100644
--- a/include/llvm/Support/Mangler.h
+++ b/include/llvm/Support/Mangler.h
@@ -25,6 +25,14 @@ class Value;
class GlobalValue;
class Mangler {
+public:
+ enum ManglerPrefixTy {
+ DefaultPrefixTy, ///< Emit default string before each symbol.
+ PrivatePrefixTy, ///< Emit "private" prefix before each symbol.
+ LinkerPrivatePrefixTy ///< Emit "linker private" prefix before each symbol.
+ };
+
+private:
/// Prefix - This string is added to each symbol that is emitted, unless the
/// symbol is marked as not needing this prefix.
const char *Prefix;
@@ -33,6 +41,10 @@ class Mangler {
/// linkage.
const char *PrivatePrefix;
+ /// LinkerPrivatePrefix - This string is emitted before each symbol with
+ /// "linker_private" linkage.
+ const char *LinkerPrivatePrefix;
+
/// UseQuotes - If this is set, the target accepts global names in quotes,
/// e.g. "foo bar" is a legal name. This syntax is used instead of escaping
/// the space character. By default, this is false.
@@ -50,12 +62,13 @@ class Mangler {
/// AcceptableChars - This bitfield contains a one for each character that is
/// allowed to be part of an unmangled name.
- unsigned AcceptableChars[256/32];
-public:
+ unsigned AcceptableChars[256 / 32];
+public:
// Mangler ctor - if a prefix is specified, it will be prepended onto all
// symbols.
- Mangler(Module &M, const char *Prefix = "", const char *privatePrefix = "");
+ Mangler(Module &M, const char *Prefix = "", const char *privatePrefix = "",
+ const char *linkerPrivatePrefix = "");
/// setUseQuotes - If UseQuotes is set to true, this target accepts quoted
/// strings for assembler labels.
@@ -90,7 +103,7 @@ public:
/// from getValueName.
///
std::string makeNameProper(const std::string &x,
- bool hasPrivateLinkage = false);
+ ManglerPrefixTy PrefixTy = DefaultPrefixTy);
};
} // End llvm namespace
diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp
index 1dc463110bc..a2e5b76fd3a 100644
--- a/lib/AsmParser/LLLexer.cpp
+++ b/lib/AsmParser/LLLexer.cpp
@@ -474,6 +474,7 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD(global); KEYWORD(constant);
KEYWORD(private);
+ KEYWORD(linker_private);
KEYWORD(internal);
KEYWORD(available_externally);
KEYWORD(linkonce);
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 6a6478f37ba..8092d577794 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -123,18 +123,19 @@ bool LLParser::ParseTopLevelEntities() {
// optional leading prefixes, the production is:
// GlobalVar ::= OptionalLinkage OptionalVisibility OptionalThreadLocal
// OptionalAddrSpace ('constant'|'global') ...
- case lltok::kw_private: // OptionalLinkage
- case lltok::kw_internal: // OptionalLinkage
- case lltok::kw_weak: // OptionalLinkage
- case lltok::kw_weak_odr: // OptionalLinkage
- case lltok::kw_linkonce: // OptionalLinkage
- case lltok::kw_linkonce_odr: // OptionalLinkage
- case lltok::kw_appending: // OptionalLinkage
- case lltok::kw_dllexport: // OptionalLinkage
- case lltok::kw_common: // OptionalLinkage
- case lltok::kw_dllimport: // OptionalLinkage
- case lltok::kw_extern_weak: // OptionalLinkage
- case lltok::kw_external: { // OptionalLinkage
+ case lltok::kw_private : // OptionalLinkage
+ case lltok::kw_linker_private: // OptionalLinkage
+ case lltok::kw_internal: // OptionalLinkage
+ case lltok::kw_weak: // OptionalLinkage
+ case lltok::kw_weak_odr: // OptionalLinkage
+ case lltok::kw_linkonce: // OptionalLinkage
+ case lltok::kw_linkonce_odr: // OptionalLinkage
+ case lltok::kw_appending: // OptionalLinkage
+ case lltok::kw_dllexport: // OptionalLinkage
+ case lltok::kw_common: // OptionalLinkage
+ case lltok::kw_dllimport: // OptionalLinkage
+ case lltok::kw_extern_weak: // OptionalLinkage
+ case lltok::kw_external: { // OptionalLinkage
unsigned Linkage, Visibility;
if (ParseOptionalLinkage(Linkage) ||
ParseOptionalVisibility(Visibility) ||
@@ -420,7 +421,8 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
Linkage != GlobalValue::WeakAnyLinkage &&
Linkage != GlobalValue::WeakODRLinkage &&
Linkage != GlobalValue::InternalLinkage &&
- Linkage != GlobalValue::PrivateLinkage)
+ Linkage != GlobalValue::PrivateLinkage &&
+ Linkage != GlobalValue::LinkerPrivateLinkage)
return Error(LinkageLoc, "invalid linkage type for alias");
Constant *Aliasee;
@@ -792,6 +794,7 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
/// ParseOptionalLinkage
/// ::= /*empty*/
/// ::= 'private'
+/// ::= 'linker_private'
/// ::= 'internal'
/// ::= 'weak'
/// ::= 'weak_odr'
@@ -806,22 +809,23 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
bool LLParser::ParseOptionalLinkage(unsigned &Res, bool &HasLinkage) {
HasLinkage = false;
switch (Lex.getKind()) {
- default: Res = GlobalValue::ExternalLinkage; return false;
- case lltok::kw_private: Res = GlobalValue::PrivateLinkage; 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;
- case lltok::kw_linkonce: Res = GlobalValue::LinkOnceAnyLinkage; break;
- case lltok::kw_linkonce_odr: Res = GlobalValue::LinkOnceODRLinkage; break;
+ 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_internal: Res = GlobalValue::InternalLinkage; break;
+ case lltok::kw_weak: Res = GlobalValue::WeakAnyLinkage; break;
+ case lltok::kw_weak_odr: Res = GlobalValue::WeakODRLinkage; break;
+ case lltok::kw_linkonce: Res = GlobalValue::LinkOnceAnyLinkage; break;
+ case lltok::kw_linkonce_odr: Res = GlobalValue::LinkOnceODRLinkage; break;
case lltok::kw_available_externally:
Res = GlobalValue::AvailableExternallyLinkage;
break;
- case lltok::kw_appending: Res = GlobalValue::AppendingLinkage; break;
- case lltok::kw_dllexport: Res = GlobalValue::DLLExportLinkage; break;
- case lltok::kw_common: Res = GlobalValue::CommonLinkage; break;
- case lltok::kw_dllimport: Res = GlobalValue::DLLImportLinkage; break;
- case lltok::kw_extern_weak: Res = GlobalValue::ExternalWeakLinkage; break;
- case lltok::kw_external: Res = GlobalValue::ExternalLinkage; break;
+ case lltok::kw_appending: Res = GlobalValue::AppendingLinkage; break;
+ case lltok::kw_dllexport: Res = GlobalValue::DLLExportLinkage; break;
+ case lltok::kw_common: Res = GlobalValue::CommonLinkage; break;
+ case lltok::kw_dllimport: Res = GlobalValue::DLLImportLinkage; break;
+ case lltok::kw_extern_weak: Res = GlobalValue::ExternalWeakLinkage; break;
+ case lltok::kw_external: Res = GlobalValue::ExternalLinkage; break;
}
Lex.Lex();
HasLinkage = true;
@@ -2211,6 +2215,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
return Error(LinkageLoc, "invalid linkage for function definition");
break;
case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
case GlobalValue::InternalLinkage:
case GlobalValue::AvailableExternallyLinkage:
case GlobalValue::LinkOnceAnyLinkage:
diff --git a/lib/AsmParser/LLToken.h b/lib/AsmParser/LLToken.h
index 8f813f39b64..0f00eb63b08 100644
--- a/lib/AsmParser/LLToken.h
+++ b/lib/AsmParser/LLToken.h
@@ -36,8 +36,9 @@ namespace lltok {
kw_declare, kw_define,
kw_global, kw_constant,
- kw_private, kw_internal, kw_linkonce, kw_linkonce_odr, kw_weak, kw_weak_odr,
- kw_appending, kw_dllimport, kw_dllexport, kw_common,kw_available_externally,
+ kw_private, kw_linker_private, kw_internal, kw_linkonce, kw_linkonce_odr,
+ kw_weak, kw_weak_odr, kw_appending, kw_dllimport, kw_dllexport, kw_common,
+ kw_available_externally,
kw_default, kw_hidden, kw_protected,
kw_extern_weak,
kw_external, kw_thread_local,
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index e4d3c5e1ade..bc1eba01e2d 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -60,19 +60,20 @@ static bool ConvertToString(SmallVector &Record, unsigned Idx,
static GlobalValue::LinkageTypes GetDecodedLinkage(unsigned Val) {
switch (Val) {
default: // Map unknown/new linkages to external
- case 0: return GlobalValue::ExternalLinkage;
- case 1: return GlobalValue::WeakAnyLinkage;
- case 2: return GlobalValue::AppendingLinkage;
- case 3: return GlobalValue::InternalLinkage;
- case 4: return GlobalValue::LinkOnceAnyLinkage;
- case 5: return GlobalValue::DLLImportLinkage;
- case 6: return GlobalValue::DLLExportLinkage;
- case 7: return GlobalValue::ExternalWeakLinkage;
- case 8: return GlobalValue::CommonLinkage;
- case 9: return GlobalValue::PrivateLinkage;
+ case 0: return GlobalValue::ExternalLinkage;
+ case 1: return GlobalValue::WeakAnyLinkage;
+ case 2: return GlobalValue::AppendingLinkage;
+ case 3: return GlobalValue::InternalLinkage;
+ case 4: return GlobalValue::LinkOnceAnyLinkage;
+ case 5: return GlobalValue::DLLImportLinkage;
+ case 6: return GlobalValue::DLLExportLinkage;
+ case 7: return GlobalValue::ExternalWeakLinkage;
+ case 8: return GlobalValue::CommonLinkage;
+ case 9: return GlobalValue::PrivateLinkage;
case 10: return GlobalValue::WeakODRLinkage;
case 11: return GlobalValue::LinkOnceODRLinkage;
case 12: return GlobalValue::AvailableExternallyLinkage;
+ case 13: return GlobalValue::LinkerPrivateLinkage;
}
}
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp
index 55ec9e5e434..d7acd14a803 100644
--- a/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -281,19 +281,20 @@ static unsigned getEncodedLinkage(const GlobalValue *GV) {
switch (GV->getLinkage()) {
default: llvm_unreachable("Invalid linkage!");
case GlobalValue::GhostLinkage: // Map ghost linkage onto external.
- case GlobalValue::ExternalLinkage: return 0;
- case GlobalValue::WeakAnyLinkage: return 1;
- case GlobalValue::AppendingLinkage: return 2;
- case GlobalValue::InternalLinkage: return 3;
- case GlobalValue::LinkOnceAnyLinkage: return 4;
- case GlobalValue::DLLImportLinkage: return 5;
- case GlobalValue::DLLExportLinkage: return 6;
- case GlobalValue::ExternalWeakLinkage: return 7;
- case GlobalValue::CommonLinkage: return 8;
- case GlobalValue::PrivateLinkage: return 9;
- case GlobalValue::WeakODRLinkage: return 10;
- case GlobalValue::LinkOnceODRLinkage: return 11;
- case GlobalValue::AvailableExternallyLinkage: return 12;
+ case GlobalValue::ExternalLinkage: return 0;
+ case GlobalValue::WeakAnyLinkage: return 1;
+ case GlobalValue::AppendingLinkage: return 2;
+ case GlobalValue::InternalLinkage: return 3;
+ case GlobalValue::LinkOnceAnyLinkage: return 4;
+ case GlobalValue::DLLImportLinkage: return 5;
+ case GlobalValue::DLLExportLinkage: return 6;
+ case GlobalValue::ExternalWeakLinkage: return 7;
+ case GlobalValue::CommonLinkage: return 8;
+ case GlobalValue::PrivateLinkage: return 9;
+ case GlobalValue::WeakODRLinkage: return 10;
+ case GlobalValue::LinkOnceODRLinkage: return 11;
+ case GlobalValue::AvailableExternallyLinkage: return 12;
+ case GlobalValue::LinkerPrivateLinkage: return 13;
}
}
diff --git a/lib/CodeGen/MachOWriter.cpp b/lib/CodeGen/MachOWriter.cpp
index d19b218b2f3..4e24c7c2bb0 100644
--- a/lib/CodeGen/MachOWriter.cpp
+++ b/lib/CodeGen/MachOWriter.cpp
@@ -764,6 +764,9 @@ MachOSym::MachOSym(const GlobalValue *gv, std::string name, uint8_t sect,
case GlobalValue::PrivateLinkage:
GVName = TAI->getPrivateGlobalPrefix() + name;
break;
+ case GlobalValue::LinkerPrivateLinkage:
+ GVName = TAI->getLessPrivateGlobalPrefix() + name;
+ break;
case GlobalValue::InternalLinkage:
GVName = TAI->getGlobalPrefix() + name;
break;
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 85ba9330737..afc06e4e47a 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -709,6 +709,9 @@ CalculateAliasLinkage(const GlobalValue *SGV, const GlobalValue *DGV) {
else if (SL == GlobalValue::InternalLinkage &&
DL == GlobalValue::InternalLinkage)
return GlobalValue::InternalLinkage;
+ else if (SL == GlobalValue::LinkerPrivateLinkage &&
+ DL == GlobalValue::LinkerPrivateLinkage)
+ return GlobalValue::LinkerPrivateLinkage;
else {
assert (SL == GlobalValue::PrivateLinkage &&
DL == GlobalValue::PrivateLinkage && "Unexpected linkage type");
diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
index e561929af5d..08c664880c2 100644
--- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
+++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
@@ -93,12 +93,15 @@ namespace {
void Init(const std::string &GV, Mangler *Mang) {
// Already initialized.
if (!Stub.empty()) return;
- Stub = Mang->makeNameProper(GV+"$stub", true);
- LazyPtr = Mang->makeNameProper(GV+"$lazy_ptr", true);
- SLP = Mang->makeNameProper(GV+"$slp", true);
- SCV = Mang->makeNameProper(GV+"$scv", true);
+ Stub = Mang->makeNameProper(GV + "$stub",
+ Mangler::PrivatePrefixTy);
+ LazyPtr = Mang->makeNameProper(GV + "$lazy_ptr",
+ Mangler::PrivatePrefixTy);
+ SLP = Mang->makeNameProper(GV + "$slp",
+ Mangler::PrivatePrefixTy);
+ SCV = Mang->makeNameProper(GV + "$scv",
+ Mangler::PrivatePrefixTy);
}
-
};
/// FnStubs - Keeps the set of external function GlobalAddresses that the
@@ -256,6 +259,7 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
switch (F->getLinkage()) {
default: llvm_unreachable("Unknown linkage type!");
case Function::PrivateLinkage:
+ case Function::LinkerPrivateLinkage:
case Function::InternalLinkage:
SwitchToTextSection("\t.text", F);
break;
@@ -1184,6 +1188,7 @@ void ARMAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
O << "\t.globl " << name << "\n";
// FALL THROUGH
case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
case GlobalValue::InternalLinkage:
break;
default:
diff --git a/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp b/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
index b772c14892f..ce07225030e 100644
--- a/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
+++ b/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
@@ -157,6 +157,7 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
default: llvm_unreachable("Unknown linkage type!");
case Function::InternalLinkage: // Symbols default to internal.
case Function::PrivateLinkage:
+ case Function::LinkerPrivateLinkage:
break;
case Function::ExternalLinkage:
O << "\t.globl " << CurrentFnName << "\n";
@@ -245,6 +246,7 @@ void AlphaAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
break;
case GlobalValue::InternalLinkage:
case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
break;
default:
llvm_unreachable("Unknown linkage type!");
diff --git a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
index 3c677182153..59e5c6e6455 100644
--- a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
+++ b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
@@ -437,6 +437,7 @@ LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF)
switch (F->getLinkage()) {
default: llvm_unreachable("Unknown linkage type!");
case Function::PrivateLinkage:
+ case Function::LinkerPrivateLinkage:
case Function::InternalLinkage: // Symbols default to internal.
break;
case Function::ExternalLinkage:
@@ -571,6 +572,7 @@ void LinuxAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
<< "\t.type " << name << ", @object\n";
// FALL THROUGH
case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
case GlobalValue::InternalLinkage:
break;
default:
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp
index d232a55cd79..71af8a90411 100644
--- a/lib/Target/CppBackend/CPPBackend.cpp
+++ b/lib/Target/CppBackend/CPPBackend.cpp
@@ -288,6 +288,8 @@ namespace {
Out << "GlobalValue::InternalLinkage"; break;
case GlobalValue::PrivateLinkage:
Out << "GlobalValue::PrivateLinkage"; break;
+ case GlobalValue::LinkerPrivateLinkage:
+ Out << "GlobalValue::LinkerPrivateLinkage"; break;
case GlobalValue::AvailableExternallyLinkage:
Out << "GlobalValue::AvailableExternallyLinkage "; break;
case GlobalValue::LinkOnceAnyLinkage:
diff --git a/lib/Target/ELFTargetAsmInfo.cpp b/lib/Target/ELFTargetAsmInfo.cpp
index 752f4757ddd..0338ba42858 100644
--- a/lib/Target/ELFTargetAsmInfo.cpp
+++ b/lib/Target/ELFTargetAsmInfo.cpp
@@ -77,6 +77,7 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
switch (F->getLinkage()) {
default: llvm_unreachable("Unknown linkage type!");
case Function::PrivateLinkage:
+ case Function::LinkerPrivateLinkage:
case Function::InternalLinkage:
case Function::DLLExportLinkage:
case Function::ExternalLinkage:
diff --git a/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp b/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp
index c224c8a32c2..dbf1b4c1eec 100644
--- a/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp
+++ b/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp
@@ -317,6 +317,7 @@ void IA64AsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
// FALL THROUGH
case GlobalValue::InternalLinkage:
case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
break;
case GlobalValue::GhostLinkage:
llvm_unreachable("GhostLinkage cannot appear in IA64AsmPrinter!");
diff --git a/lib/Target/MSP430/MSP430AsmPrinter.cpp b/lib/Target/MSP430/MSP430AsmPrinter.cpp
index 2ff5eecbfd7..49e2a2e08fa 100644
--- a/lib/Target/MSP430/MSP430AsmPrinter.cpp
+++ b/lib/Target/MSP430/MSP430AsmPrinter.cpp
@@ -103,6 +103,7 @@ void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
default: llvm_unreachable("Unknown linkage type!");
case Function::InternalLinkage: // Symbols default to internal.
case Function::PrivateLinkage:
+ case Function::LinkerPrivateLinkage:
break;
case Function::ExternalLinkage:
O << "\t.globl\t" << CurrentFnName << '\n';
diff --git a/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp b/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
index abdd5a3d1d4..36c1c044a5c 100644
--- a/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
+++ b/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
@@ -538,6 +538,7 @@ printModuleLevelGV(const GlobalVariable* GVar) {
O << TAI->getGlobalDirective() << name << '\n';
// Fall Through
case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
case GlobalValue::InternalLinkage:
if (CVA && CVA->isCString())
printSizeAndType = false;
diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
index a3526ccfea6..a4fcdf661b9 100644
--- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
+++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
@@ -70,9 +70,12 @@ namespace {
void Init(const std::string &GV, Mangler *Mang) {
// Already initialized.
if (!Stub.empty()) return;
- Stub = Mang->makeNameProper(GV+"$stub", true);
- LazyPtr = Mang->makeNameProper(GV+"$lazy_ptr", true);
- AnonSymbol = Mang->makeNameProper(GV+"$stub$tmp", true);
+ Stub = Mang->makeNameProper(GV + "$stub",
+ Mangler::PrivatePrefixTy);
+ LazyPtr = Mang->makeNameProper(GV + "$lazy_ptr",
+ Mangler::PrivatePrefixTy);
+ AnonSymbol = Mang->makeNameProper(GV + "$stub$tmp",
+ Mangler::PrivatePrefixTy);
}
};
@@ -594,6 +597,7 @@ bool PPCLinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
switch (F->getLinkage()) {
default: llvm_unreachable("Unknown linkage type!");
case Function::PrivateLinkage:
+ case Function::LinkerPrivateLinkage:
case Function::InternalLinkage: // Symbols default to internal.
break;
case Function::ExternalLinkage:
@@ -725,6 +729,7 @@ void PPCLinuxAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
// FALL THROUGH
case GlobalValue::InternalLinkage:
case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
break;
default:
llvm_unreachable("Unknown linkage type!");
@@ -771,6 +776,7 @@ bool PPCDarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
switch (F->getLinkage()) {
default: llvm_unreachable("Unknown linkage type!");
case Function::PrivateLinkage:
+ case Function::LinkerPrivateLinkage:
case Function::InternalLinkage: // Symbols default to internal.
break;
case Function::ExternalLinkage:
@@ -954,6 +960,7 @@ void PPCDarwinAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
// FALL THROUGH
case GlobalValue::InternalLinkage:
case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
break;
default:
llvm_unreachable("Unknown linkage type!");
diff --git a/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp b/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
index f6a5e0b4362..3247cecc978 100644
--- a/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
+++ b/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
@@ -294,6 +294,7 @@ void SparcAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
O << TAI->getGlobalDirective() << name << '\n';
// FALL THROUGH
case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
case GlobalValue::InternalLinkage:
break;
case GlobalValue::GhostLinkage:
diff --git a/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp b/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
index 1bb4d42590a..7dd6fcc304d 100644
--- a/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
+++ b/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
@@ -118,6 +118,7 @@ void SystemZAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
default: assert(0 && "Unknown linkage type!");
case Function::InternalLinkage: // Symbols default to internal.
case Function::PrivateLinkage:
+ case Function::LinkerPrivateLinkage:
break;
case Function::ExternalLinkage:
O << "\t.globl\t" << CurrentFnName << '\n';
@@ -396,6 +397,7 @@ void SystemZAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
O << "\t.globl " << name << '\n';
// FALL THROUGH
case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
case GlobalValue::InternalLinkage:
break;
default:
diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
index 2cec3736a38..4cb447b630d 100644
--- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
@@ -171,6 +171,7 @@ void X86ATTAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
default: llvm_unreachable("Unknown linkage type!");
case Function::InternalLinkage: // Symbols default to internal.
case Function::PrivateLinkage:
+ case Function::LinkerPrivateLinkage:
EmitAlignment(FnAlign, F);
break;
case Function::DLLExportLinkage:
@@ -877,6 +878,7 @@ void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
O << "\t.globl " << name << '\n';
// FALL THROUGH
case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
case GlobalValue::InternalLinkage:
break;
default:
diff --git a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
index 4b888416423..3c2722ea022 100644
--- a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
@@ -146,6 +146,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
switch (F->getLinkage()) {
default: llvm_unreachable("Unsupported linkage type!");
case Function::PrivateLinkage:
+ case Function::LinkerPrivateLinkage:
case Function::InternalLinkage:
EmitAlignment(FnAlign);
break;
diff --git a/lib/Target/XCore/XCoreAsmPrinter.cpp b/lib/Target/XCore/XCoreAsmPrinter.cpp
index 218b21d0939..6bb29b3ff97 100644
--- a/lib/Target/XCore/XCoreAsmPrinter.cpp
+++ b/lib/Target/XCore/XCoreAsmPrinter.cpp
@@ -172,6 +172,7 @@ emitGlobal(const GlobalVariable *GV)
// FALL THROUGH
case GlobalValue::InternalLinkage:
case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
break;
case GlobalValue::GhostLinkage:
llvm_unreachable("Should not have any unmaterialized functions!");
@@ -228,6 +229,7 @@ emitFunctionStart(MachineFunction &MF)
default: llvm_unreachable("Unknown linkage type!");
case Function::InternalLinkage: // Symbols default to internal.
case Function::PrivateLinkage:
+ case Function::LinkerPrivateLinkage:
break;
case Function::ExternalLinkage:
emitGlobalDirective(CurrentFnName);
diff --git a/lib/Transforms/IPO/MergeFunctions.cpp b/lib/Transforms/IPO/MergeFunctions.cpp
index e93a08784f0..6d6ecf2b22b 100644
--- a/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/lib/Transforms/IPO/MergeFunctions.cpp
@@ -451,6 +451,7 @@ static LinkageCategory categorize(const Function *F) {
switch (F->getLinkage()) {
case GlobalValue::InternalLinkage:
case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
return Internal;
case GlobalValue::WeakAnyLinkage:
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index eab845f3ca8..d5f211b14fd 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -1334,21 +1334,22 @@ void AssemblyWriter::printModule(const Module *M) {
static void PrintLinkage(GlobalValue::LinkageTypes LT, raw_ostream &Out) {
switch (LT) {
- case GlobalValue::PrivateLinkage: Out << "private "; break;
- case GlobalValue::InternalLinkage: Out << "internal "; break;
+ case GlobalValue::ExternalLinkage: break;
+ case GlobalValue::PrivateLinkage: Out << "private "; break;
+ case GlobalValue::LinkerPrivateLinkage: Out << "linker_private "; break;
+ case GlobalValue::InternalLinkage: Out << "internal "; break;
+ case GlobalValue::LinkOnceAnyLinkage: Out << "linkonce "; break;
+ case GlobalValue::LinkOnceODRLinkage: Out << "linkonce_odr "; break;
+ case GlobalValue::WeakAnyLinkage: Out << "weak "; break;
+ case GlobalValue::WeakODRLinkage: Out << "weak_odr "; break;
+ case GlobalValue::CommonLinkage: Out << "common "; break;
+ case GlobalValue::AppendingLinkage: Out << "appending "; break;
+ case GlobalValue::DLLImportLinkage: Out << "dllimport "; break;
+ case GlobalValue::DLLExportLinkage: Out << "dllexport "; break;
+ case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break;
case GlobalValue::AvailableExternallyLinkage:
Out << "available_externally ";
break;
- case GlobalValue::LinkOnceAnyLinkage: Out << "linkonce "; break;
- case GlobalValue::LinkOnceODRLinkage: Out << "linkonce_odr "; break;
- case GlobalValue::WeakAnyLinkage: Out << "weak "; break;
- case GlobalValue::WeakODRLinkage: Out << "weak_odr "; break;
- case GlobalValue::CommonLinkage: Out << "common "; break;
- case GlobalValue::AppendingLinkage: Out << "appending "; break;
- case GlobalValue::DLLImportLinkage: Out << "dllimport "; break;
- case GlobalValue::DLLExportLinkage: Out << "dllexport "; break;
- case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break;
- case GlobalValue::ExternalLinkage: break;
case GlobalValue::GhostLinkage:
llvm_unreachable("GhostLinkage not allowed in AsmWriter!");
}
diff --git a/lib/VMCore/Mangler.cpp b/lib/VMCore/Mangler.cpp
index 5828e21e022..c4c2502f0c2 100644
--- a/lib/VMCore/Mangler.cpp
+++ b/lib/VMCore/Mangler.cpp
@@ -32,7 +32,7 @@ static std::string MangleLetter(unsigned char C) {
/// in them, so mangle them as appropriate.
///
std::string Mangler::makeNameProper(const std::string &X,
- bool hasPrivateLinkage) {
+ ManglerPrefixTy PrefixTy) {
assert(!X.empty() && "Cannot mangle empty strings");
if (!UseQuotes) {
@@ -59,9 +59,13 @@ std::string Mangler::makeNameProper(const std::string &X,
if (NeedPrefix) {
Result = Prefix + Result;
- if (hasPrivateLinkage)
+
+ if (PrefixTy == PrivatePrefixTy)
Result = PrivatePrefix + Result;
+ else if (PrefixTy == LinkerPrivatePrefixTy)
+ Result = LinkerPrivatePrefix + Result;
}
+
return Result;
}
@@ -93,8 +97,12 @@ std::string Mangler::makeNameProper(const std::string &X,
return X.substr(1); // Strip off the \001.
Result = Prefix + X;
- if (hasPrivateLinkage)
+
+ if (PrefixTy == PrivatePrefixTy)
Result = PrivatePrefix + Result;
+ else if (PrefixTy == LinkerPrivatePrefixTy)
+ Result = LinkerPrivatePrefix + Result;
+
return Result;
}
@@ -112,9 +120,13 @@ std::string Mangler::makeNameProper(const std::string &X,
if (NeedPrefix) {
Result = Prefix + Result;
- if (hasPrivateLinkage)
+
+ if (PrefixTy == PrivatePrefixTy)
Result = PrivatePrefix + Result;
+ else if (PrefixTy == LinkerPrivatePrefixTy)
+ Result = LinkerPrivatePrefix + Result;
}
+
Result = '"' + Result + '"';
return Result;
}
@@ -128,10 +140,13 @@ std::string Mangler::getMangledName(const GlobalValue *GV, const char *Suffix,
bool ForcePrivate) {
assert((!isa(GV) || !cast(GV)->isIntrinsic()) &&
"Intrinsic functions cannot be mangled by Mangler");
-
+
+ ManglerPrefixTy PrefixTy =
+ (GV->hasPrivateLinkage() || ForcePrivate) ? PrivatePrefixTy :
+ GV->hasLinkerPrivateLinkage() ? LinkerPrivatePrefixTy : DefaultPrefixTy;
+
if (GV->hasName())
- return makeNameProper(GV->getName() + Suffix,
- GV->hasPrivateLinkage() | ForcePrivate);
+ return makeNameProper(GV->getName() + Suffix, PrefixTy);
// Get the ID for the global, assigning a new one if we haven't got one
// already.
@@ -139,12 +154,13 @@ std::string Mangler::getMangledName(const GlobalValue *GV, const char *Suffix,
if (ID == 0) ID = NextAnonGlobalID++;
// Must mangle the global into a unique ID.
- return makeNameProper("__unnamed_" + utostr(ID) + Suffix,
- GV->hasPrivateLinkage() | ForcePrivate);
+ return makeNameProper("__unnamed_" + utostr(ID) + Suffix, PrefixTy);
}
-Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix)
- : Prefix(prefix), PrivatePrefix (privatePrefix), UseQuotes(false),
+Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix,
+ const char *linkerPrivatePrefix)
+ : Prefix(prefix), PrivatePrefix(privatePrefix),
+ LinkerPrivatePrefix(linkerPrivatePrefix), UseQuotes(false),
NextAnonGlobalID(1) {
std::fill(AcceptableChars, array_endof(AcceptableChars), 0);
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp
index eef9a66cc37..325b0acf98b 100644
--- a/tools/llvm-nm/llvm-nm.cpp
+++ b/tools/llvm-nm/llvm-nm.cpp
@@ -88,7 +88,8 @@ static char TypeCharForSymbol(GlobalValue &GV) {
static void DumpSymbolNameForGlobalValue(GlobalValue &GV) {
// Private linkage and available_externally linkage don't exist in symtab.
- if (GV.hasPrivateLinkage() || GV.hasAvailableExternallyLinkage()) return;
+ if (GV.hasPrivateLinkage() || GV.hasLinkerPrivateLinkage() ||
+ GV.hasAvailableExternallyLinkage()) return;
const std::string SymbolAddrStr = " "; // Not used yet...
char TypeChar = TypeCharForSymbol(GV);