mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-26 21:32:10 +00:00
Remove the one-definition-rule version of extern_weak
linkage: this linkage type only applies to declarations, but ODR is only relevant to globals with definitions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66650 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
841c6a4345
commit
5f4ee1fc5d
@ -554,15 +554,13 @@ All Global Variables and Functions have one of the following types of linkage:
|
||||
<dt><tt><b><a name="linkage_linkonce">linkonce_odr</a></b></tt>: </dt>
|
||||
<dt><tt><b><a name="linkage_common">common_odr</a></b></tt>: </dt>
|
||||
<dt><tt><b><a name="linkage_weak">weak_odr</a></b></tt>: </dt>
|
||||
<dt><tt><b><a name="linkage_externweak">extern_weak_odr</a></b></tt>: </dt>
|
||||
<dd>Some languages allow inequivalent globals to be merged, such as two
|
||||
functions with different semantics. Other languages, such as <tt>C++</tt>,
|
||||
ensure that only equivalent globals are ever merged (the "one definition
|
||||
rule" - <tt>odr</tt>). Such languages can use the <tt>linkonce_odr</tt>,
|
||||
<tt>common_odr</tt>, <tt>weak_odr</tt> and <tt>extern_weak_odr</tt> linkage
|
||||
types to indicate that the global will only be merged with equivalent
|
||||
globals. These linkage types are otherwise the same as their
|
||||
non-<tt>odr</tt> versions.
|
||||
<tt>common_odr</tt> and <tt>weak_odr</tt> linkage types to indicate that
|
||||
the global will only be merged with equivalent globals. These linkage
|
||||
types are otherwise the same as their non-<tt>odr</tt> versions.
|
||||
</dd>
|
||||
|
||||
<dt><tt><b><a name="linkage_external">externally visible</a></b></tt>:</dt>
|
||||
@ -606,8 +604,8 @@ preventing a collision. Since "<tt>main</tt>" and "<tt>puts</tt>" are
|
||||
external (i.e., lacking any linkage declarations), they are accessible
|
||||
outside of the current module.</p>
|
||||
<p>It is illegal for a function <i>declaration</i>
|
||||
to have any linkage type other than "externally visible", <tt>dllimport</tt>,
|
||||
<tt>extern_weak</tt> or <tt>extern_weak_odr</tt>.</p>
|
||||
to have any linkage type other than "externally visible", <tt>dllimport</tt>
|
||||
or <tt>extern_weak</tt>.</p>
|
||||
<p>Aliases can have only <tt>external</tt>, <tt>internal</tt>, <tt>weak</tt>
|
||||
or <tt>weak_odr</tt> linkages.</p>
|
||||
</div>
|
||||
|
@ -127,9 +127,7 @@ typedef enum {
|
||||
LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
|
||||
LLVMDLLImportLinkage, /**< Function to be imported from DLL */
|
||||
LLVMDLLExportLinkage, /**< Function to be accessible from DLL */
|
||||
LLVMExternalWeakAnyLinkage,/**< ExternalWeak linkage description */
|
||||
LLVMExternalWeakODRLinkage,/**< Same, but only replaced by something
|
||||
equivalent. */
|
||||
LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
|
||||
LLVMGhostLinkage, /**< Stand-in functions for streaming fns from
|
||||
bitcode */
|
||||
LLVMCommonAnyLinkage, /**< Tentative definitions */
|
||||
|
@ -40,8 +40,7 @@ public:
|
||||
PrivateLinkage, ///< Like Internal, but omit from symbol table
|
||||
DLLImportLinkage, ///< Function to be imported from DLL
|
||||
DLLExportLinkage, ///< Function to be accessible from DLL
|
||||
ExternalWeakAnyLinkage,///< ExternalWeak linkage description
|
||||
ExternalWeakODRLinkage,///< Same, but only replaced by something equivalent.
|
||||
ExternalWeakLinkage,///< ExternalWeak linkage description
|
||||
GhostLinkage, ///< Stand-in functions for streaming fns from BC files
|
||||
CommonAnyLinkage, ///< Tentative definitions
|
||||
CommonODRLinkage ///< Same, but only replaced by something equivalent.
|
||||
@ -112,9 +111,6 @@ public:
|
||||
static LinkageTypes getCommonLinkage(bool ODR) {
|
||||
return ODR ? CommonODRLinkage : CommonAnyLinkage;
|
||||
}
|
||||
static LinkageTypes getExternalWeakLinkage(bool ODR) {
|
||||
return ODR ? ExternalWeakODRLinkage : ExternalWeakAnyLinkage;
|
||||
}
|
||||
|
||||
bool hasExternalLinkage() const { return Linkage == ExternalLinkage; }
|
||||
bool hasLinkOnceLinkage() const {
|
||||
@ -131,10 +127,7 @@ public:
|
||||
}
|
||||
bool hasDLLImportLinkage() const { return Linkage == DLLImportLinkage; }
|
||||
bool hasDLLExportLinkage() const { return Linkage == DLLExportLinkage; }
|
||||
bool hasExternalWeakLinkage() const {
|
||||
return Linkage == ExternalWeakAnyLinkage ||
|
||||
Linkage == ExternalWeakODRLinkage;
|
||||
}
|
||||
bool hasExternalWeakLinkage() const { return Linkage == ExternalWeakLinkage; }
|
||||
bool hasGhostLinkage() const { return Linkage == GhostLinkage; }
|
||||
bool hasCommonLinkage() const {
|
||||
return Linkage == CommonAnyLinkage || Linkage == CommonODRLinkage;
|
||||
@ -150,7 +143,7 @@ public:
|
||||
return (Linkage == WeakAnyLinkage ||
|
||||
Linkage == LinkOnceAnyLinkage ||
|
||||
Linkage == CommonAnyLinkage ||
|
||||
Linkage == ExternalWeakAnyLinkage);
|
||||
Linkage == ExternalWeakLinkage);
|
||||
}
|
||||
|
||||
/// isWeakForLinker - Whether the definition of this global may be replaced at
|
||||
@ -162,8 +155,7 @@ public:
|
||||
Linkage == LinkOnceODRLinkage ||
|
||||
Linkage == CommonAnyLinkage ||
|
||||
Linkage == CommonODRLinkage ||
|
||||
Linkage == ExternalWeakAnyLinkage ||
|
||||
Linkage == ExternalWeakODRLinkage);
|
||||
Linkage == ExternalWeakLinkage);
|
||||
}
|
||||
|
||||
/// copyAttributesFrom - copy all additional attributes (those not needed to
|
||||
|
@ -468,7 +468,6 @@ lltok::Kind LLLexer::LexIdentifier() {
|
||||
KEYWORD(hidden);
|
||||
KEYWORD(protected);
|
||||
KEYWORD(extern_weak);
|
||||
KEYWORD(extern_weak_odr);
|
||||
KEYWORD(external);
|
||||
KEYWORD(thread_local);
|
||||
KEYWORD(zeroinitializer);
|
||||
|
@ -125,7 +125,6 @@ bool LLParser::ParseTopLevelEntities() {
|
||||
case lltok::kw_common_odr: // OptionalLinkage
|
||||
case lltok::kw_dllimport: // OptionalLinkage
|
||||
case lltok::kw_extern_weak: // OptionalLinkage
|
||||
case lltok::kw_extern_weak_odr: // OptionalLinkage
|
||||
case lltok::kw_external: { // OptionalLinkage
|
||||
unsigned Linkage, Visibility;
|
||||
if (ParseOptionalLinkage(Linkage) ||
|
||||
@ -458,8 +457,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
|
||||
// present.
|
||||
Constant *Init = 0;
|
||||
if (!HasLinkage || (Linkage != GlobalValue::DLLImportLinkage &&
|
||||
Linkage != GlobalValue::ExternalWeakAnyLinkage &&
|
||||
Linkage != GlobalValue::ExternalWeakODRLinkage &&
|
||||
Linkage != GlobalValue::ExternalWeakLinkage &&
|
||||
Linkage != GlobalValue::ExternalLinkage)) {
|
||||
if (ParseGlobalValue(Ty, Init))
|
||||
return true;
|
||||
@ -574,10 +572,10 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, const Type *Ty,
|
||||
return 0;
|
||||
}
|
||||
|
||||
FwdVal = Function::Create(FT, GlobalValue::ExternalWeakAnyLinkage, Name, M);
|
||||
FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M);
|
||||
} else {
|
||||
FwdVal = new GlobalVariable(PTy->getElementType(), false,
|
||||
GlobalValue::ExternalWeakAnyLinkage, 0, Name, M);
|
||||
GlobalValue::ExternalWeakLinkage, 0, Name, M);
|
||||
}
|
||||
|
||||
ForwardRefVals[Name] = std::make_pair(FwdVal, Loc);
|
||||
@ -618,10 +616,10 @@ GlobalValue *LLParser::GetGlobalVal(unsigned ID, const Type *Ty, LocTy Loc) {
|
||||
Error(Loc, "function may not return opaque type");
|
||||
return 0;
|
||||
}
|
||||
FwdVal = Function::Create(FT, GlobalValue::ExternalWeakAnyLinkage, "", M);
|
||||
FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, "", M);
|
||||
} else {
|
||||
FwdVal = new GlobalVariable(PTy->getElementType(), false,
|
||||
GlobalValue::ExternalWeakAnyLinkage, 0, "", M);
|
||||
GlobalValue::ExternalWeakLinkage, 0, "", M);
|
||||
}
|
||||
|
||||
ForwardRefValIDs[ID] = std::make_pair(FwdVal, Loc);
|
||||
@ -753,7 +751,6 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
|
||||
/// ::= 'common_odr'
|
||||
/// ::= 'dllimport'
|
||||
/// ::= 'extern_weak'
|
||||
/// ::= 'extern_weak_odr'
|
||||
/// ::= 'external'
|
||||
bool LLParser::ParseOptionalLinkage(unsigned &Res, bool &HasLinkage) {
|
||||
HasLinkage = false;
|
||||
@ -770,9 +767,7 @@ bool LLParser::ParseOptionalLinkage(unsigned &Res, bool &HasLinkage) {
|
||||
case lltok::kw_common: Res = GlobalValue::CommonAnyLinkage; break;
|
||||
case lltok::kw_common_odr: Res = GlobalValue::CommonODRLinkage; break;
|
||||
case lltok::kw_dllimport: Res = GlobalValue::DLLImportLinkage; break;
|
||||
case lltok::kw_extern_weak: Res = GlobalValue::ExternalWeakAnyLinkage; break;
|
||||
case lltok::kw_extern_weak_odr:
|
||||
Res = GlobalValue::ExternalWeakODRLinkage; break;
|
||||
case lltok::kw_extern_weak: Res = GlobalValue::ExternalWeakLinkage; break;
|
||||
case lltok::kw_external: Res = GlobalValue::ExternalLinkage; break;
|
||||
}
|
||||
Lex.Lex();
|
||||
@ -2103,8 +2098,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
|
||||
case GlobalValue::ExternalLinkage:
|
||||
break; // always ok.
|
||||
case GlobalValue::DLLImportLinkage:
|
||||
case GlobalValue::ExternalWeakAnyLinkage:
|
||||
case GlobalValue::ExternalWeakODRLinkage:
|
||||
case GlobalValue::ExternalWeakLinkage:
|
||||
if (isDefine)
|
||||
return Error(LinkageLoc, "invalid linkage for function definition");
|
||||
break;
|
||||
|
@ -39,7 +39,7 @@ namespace lltok {
|
||||
kw_private, kw_internal, kw_linkonce, kw_linkonce_odr, kw_weak, kw_weak_odr,
|
||||
kw_appending, kw_dllimport, kw_dllexport, kw_common, kw_common_odr,
|
||||
kw_default, kw_hidden, kw_protected,
|
||||
kw_extern_weak, kw_extern_weak_odr,
|
||||
kw_extern_weak,
|
||||
kw_external, kw_thread_local,
|
||||
kw_zeroinitializer,
|
||||
kw_undef, kw_null,
|
||||
|
@ -65,12 +65,11 @@ static GlobalValue::LinkageTypes GetDecodedLinkage(unsigned Val) {
|
||||
case 4: return GlobalValue::LinkOnceAnyLinkage;
|
||||
case 5: return GlobalValue::DLLImportLinkage;
|
||||
case 6: return GlobalValue::DLLExportLinkage;
|
||||
case 7: return GlobalValue::ExternalWeakAnyLinkage;
|
||||
case 7: return GlobalValue::ExternalWeakLinkage;
|
||||
case 8: return GlobalValue::CommonAnyLinkage;
|
||||
case 9: return GlobalValue::PrivateLinkage;
|
||||
case 10: return GlobalValue::WeakODRLinkage;
|
||||
case 11: return GlobalValue::LinkOnceODRLinkage;
|
||||
case 12: return GlobalValue::ExternalWeakODRLinkage;
|
||||
case 13: return GlobalValue::CommonODRLinkage;
|
||||
}
|
||||
}
|
||||
|
@ -282,12 +282,11 @@ static unsigned getEncodedLinkage(const GlobalValue *GV) {
|
||||
case GlobalValue::LinkOnceAnyLinkage: return 4;
|
||||
case GlobalValue::DLLImportLinkage: return 5;
|
||||
case GlobalValue::DLLExportLinkage: return 6;
|
||||
case GlobalValue::ExternalWeakAnyLinkage: return 7;
|
||||
case GlobalValue::ExternalWeakLinkage: return 7;
|
||||
case GlobalValue::CommonAnyLinkage: return 8;
|
||||
case GlobalValue::PrivateLinkage: return 9;
|
||||
case GlobalValue::WeakODRLinkage: return 10;
|
||||
case GlobalValue::LinkOnceODRLinkage: return 11;
|
||||
case GlobalValue::ExternalWeakODRLinkage: return 12;
|
||||
case GlobalValue::CommonODRLinkage: return 13;
|
||||
}
|
||||
}
|
||||
|
@ -310,10 +310,8 @@ namespace {
|
||||
Out << "GlobalValue::DLLImportLinkage"; break;
|
||||
case GlobalValue::DLLExportLinkage:
|
||||
Out << "GlobalValue::DLLExportLinkage"; break;
|
||||
case GlobalValue::ExternalWeakAnyLinkage:
|
||||
Out << "GlobalValue::ExternalWeakAnyLinkage"; break;
|
||||
case GlobalValue::ExternalWeakODRLinkage:
|
||||
Out << "GlobalValue::ExternalWeakODRLinkage"; break;
|
||||
case GlobalValue::ExternalWeakLinkage:
|
||||
Out << "GlobalValue::ExternalWeakLinkage"; break;
|
||||
case GlobalValue::GhostLinkage:
|
||||
Out << "GlobalValue::GhostLinkage"; break;
|
||||
case GlobalValue::CommonAnyLinkage:
|
||||
|
@ -438,8 +438,7 @@ bool XCoreAsmPrinter::doInitialization(Module &M) {
|
||||
switch (I->getLinkage()) {
|
||||
default:
|
||||
assert(0 && "Unexpected linkage");
|
||||
case Function::ExternalWeakAnyLinkage:
|
||||
case Function::ExternalWeakODRLinkage:
|
||||
case Function::ExternalWeakLinkage:
|
||||
ExtWeakSymbols.insert(I);
|
||||
// fallthrough
|
||||
case Function::ExternalLinkage:
|
||||
|
@ -1194,8 +1194,7 @@ static void PrintLinkage(GlobalValue::LinkageTypes LT, raw_ostream &Out) {
|
||||
case GlobalValue::AppendingLinkage: Out << "appending "; break;
|
||||
case GlobalValue::DLLImportLinkage: Out << "dllimport "; break;
|
||||
case GlobalValue::DLLExportLinkage: Out << "dllexport "; break;
|
||||
case GlobalValue::ExternalWeakAnyLinkage: Out << "extern_weak "; break;
|
||||
case GlobalValue::ExternalWeakODRLinkage: Out << "extern_weak_odr "; break;
|
||||
case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break;
|
||||
case GlobalValue::ExternalLinkage: break;
|
||||
case GlobalValue::GhostLinkage:
|
||||
Out << "GhostLinkage not allowed in AsmWriter!\n";
|
||||
|
@ -94,7 +94,6 @@ GVInternalLinkage
|
||||
GVExternalLinkage
|
||||
::= dllimport
|
||||
| "extern_weak"
|
||||
| "extern_weak_odr"
|
||||
| + external
|
||||
;
|
||||
|
||||
@ -109,7 +108,6 @@ FunctionDeclareLinkage
|
||||
::= + _
|
||||
| dllimport
|
||||
| "extern_weak"
|
||||
| "extern_weak_odr"
|
||||
;
|
||||
|
||||
FunctionDefineLinkage
|
||||
|
@ -41,7 +41,7 @@ syn keyword llvmStatement extractvalue insertvalue
|
||||
syn keyword llvmKeyword define declare global constant
|
||||
syn keyword llvmKeyword internal external
|
||||
syn keyword llvmKeyword linkonce linkonce_odr weak weak_odr appending
|
||||
syn keyword llvmKeyword common common_odr extern_weak extern_weak_odr
|
||||
syn keyword llvmKeyword common common_odr extern_weak
|
||||
syn keyword llvmKeyword thread_local dllimport dllexport
|
||||
syn keyword llvmKeyword hidden protected default
|
||||
syn keyword llvmKeyword except deplibs
|
||||
|
Loading…
Reference in New Issue
Block a user