mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-12 13:30:51 +00:00
Add plumbing for the `linker_private' linkage type. This type is meant for
"private" symbols which the assember shouldn't strip, but which the linker may remove after evaluation. This is mostly useful for Objective-C metadata. This is plumbing, so we don't have a use of it yet. More to come, etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76385 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3f189a3eb4
commit
3d10a5a757
@ -20,7 +20,24 @@
|
||||
<li><a href="#highlevel">High Level Structure</a>
|
||||
<ol>
|
||||
<li><a href="#modulestructure">Module Structure</a></li>
|
||||
<li><a href="#linkage">Linkage Types</a></li>
|
||||
<li><a href="#linkage">Linkage Types</a>
|
||||
<ol>
|
||||
<li><a href="#linkage_private">private</a></li>
|
||||
<li><a href="#linkage_linker_private">linker_private</a></li>
|
||||
<li><a href="#linkage_internal">internal</a></li>
|
||||
<li><a href="#linkage_available_externally">available_externally</a></li>
|
||||
<li><a href="#linkage_linkonce">linkonce</a></li>
|
||||
<li><a href="#linkage_common">common</a></li>
|
||||
<li><a href="#linkage_weak">weak</a></li>
|
||||
<li><a href="#linkage_appending">appending</a></li>
|
||||
<li><a href="#linkage_externweak">extern_weak</a></li>
|
||||
<li><a href="#linkage_linkonce">linkonce_odr</a></li>
|
||||
<li><a href="#linkage_weak">weak_odr</a></li>
|
||||
<li><a href="#linkage_external">externally visible</a></li>
|
||||
<li><a href="#linkage_dllimport">dllimport</a></li>
|
||||
<li><a href="#linkage_dllexport">dllexport</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><a href="#callingconv">Calling Conventions</a></li>
|
||||
<li><a href="#namedtypes">Named Types</a></li>
|
||||
<li><a href="#globalvars">Global Variables</a></li>
|
||||
@ -502,6 +519,11 @@ All Global Variables and Functions have one of the following types of linkage:
|
||||
object file.
|
||||
</dd>
|
||||
|
||||
<dt><tt><b><a name="linkage_linker_private">linker_private</a></b></tt>: </dt>
|
||||
|
||||
<dd>Similar to private, but the symbol is passed through the assembler and
|
||||
removed by the linker after evaluation.</dd>
|
||||
|
||||
<dt><tt><b><a name="linkage_internal">internal</a></b></tt>: </dt>
|
||||
|
||||
<dd> 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:
|
||||
'<tt>static</tt>' keyword in C.
|
||||
</dd>
|
||||
|
||||
<dt><tt><b><a name="available_externally">available_externally</a></b></tt>:
|
||||
<dt><tt><b><a name="linkage_available_externally">available_externally</a></b></tt>:
|
||||
</dt>
|
||||
|
||||
<dd>Globals with "<tt>available_externally</tt>" linkage are never emitted
|
||||
|
@ -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 */
|
||||
|
@ -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; }
|
||||
|
@ -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
|
||||
|
@ -474,6 +474,7 @@ lltok::Kind LLLexer::LexIdentifier() {
|
||||
KEYWORD(global); KEYWORD(constant);
|
||||
|
||||
KEYWORD(private);
|
||||
KEYWORD(linker_private);
|
||||
KEYWORD(internal);
|
||||
KEYWORD(available_externally);
|
||||
KEYWORD(linkonce);
|
||||
|
@ -123,7 +123,8 @@ bool LLParser::ParseTopLevelEntities() {
|
||||
// optional leading prefixes, the production is:
|
||||
// GlobalVar ::= OptionalLinkage OptionalVisibility OptionalThreadLocal
|
||||
// OptionalAddrSpace ('constant'|'global') ...
|
||||
case lltok::kw_private: // 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
|
||||
@ -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,8 +809,9 @@ 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;
|
||||
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;
|
||||
@ -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:
|
||||
|
@ -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,
|
||||
|
@ -73,6 +73,7 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,6 +294,7 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
@ -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:
|
||||
|
@ -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!");
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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!");
|
||||
|
@ -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';
|
||||
|
@ -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;
|
||||
|
@ -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!");
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -1334,11 +1334,10 @@ void AssemblyWriter::printModule(const Module *M) {
|
||||
|
||||
static void PrintLinkage(GlobalValue::LinkageTypes LT, raw_ostream &Out) {
|
||||
switch (LT) {
|
||||
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::AvailableExternallyLinkage:
|
||||
Out << "available_externally ";
|
||||
break;
|
||||
case GlobalValue::LinkOnceAnyLinkage: Out << "linkonce "; break;
|
||||
case GlobalValue::LinkOnceODRLinkage: Out << "linkonce_odr "; break;
|
||||
case GlobalValue::WeakAnyLinkage: Out << "weak "; break;
|
||||
@ -1348,7 +1347,9 @@ static void PrintLinkage(GlobalValue::LinkageTypes LT, raw_ostream &Out) {
|
||||
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::AvailableExternallyLinkage:
|
||||
Out << "available_externally ";
|
||||
break;
|
||||
case GlobalValue::GhostLinkage:
|
||||
llvm_unreachable("GhostLinkage not allowed in AsmWriter!");
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
@ -129,9 +141,12 @@ std::string Mangler::getMangledName(const GlobalValue *GV, const char *Suffix,
|
||||
assert((!isa<Function>(GV) || !cast<Function>(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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user