mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 04:38:24 +00:00
IR: Don't allow non-default visibility on local linkage
Visibilities of `hidden` and `protected` are meaningless for symbols with local linkage. - Change the assembler to reject non-default visibility on symbols with local linkage. - Change the bitcode reader to auto-upgrade `hidden` and `protected` to `default` when the linkage is local. - Update LangRef. <rdar://problem/16141113> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208263 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -622,6 +622,11 @@ bool LLParser::ParseStandaloneMetadata() {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool isValidVisibilityForLinkage(unsigned V, unsigned L) {
|
||||
return !GlobalValue::isLocalLinkage((GlobalValue::LinkageTypes)L) ||
|
||||
(GlobalValue::VisibilityTypes)V == GlobalValue::DefaultVisibility;
|
||||
}
|
||||
|
||||
/// ParseAlias:
|
||||
/// ::= GlobalVar '=' OptionalVisibility OptionalDLLStorageClass 'alias'
|
||||
/// OptionalLinkage Aliasee
|
||||
@ -646,6 +651,10 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
|
||||
if(!GlobalAlias::isValidLinkage(Linkage))
|
||||
return Error(LinkageLoc, "invalid linkage type for alias");
|
||||
|
||||
if (!isValidVisibilityForLinkage(Visibility, L))
|
||||
return Error(LinkageLoc,
|
||||
"symbol with local linkage must have default visibility");
|
||||
|
||||
Constant *Aliasee;
|
||||
LocTy AliaseeLoc = Lex.getLoc();
|
||||
if (Lex.getKind() != lltok::kw_bitcast &&
|
||||
@ -714,6 +723,10 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
|
||||
bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
|
||||
unsigned Linkage, bool HasLinkage,
|
||||
unsigned Visibility, unsigned DLLStorageClass) {
|
||||
if (!isValidVisibilityForLinkage(Visibility, Linkage))
|
||||
return Error(NameLoc,
|
||||
"symbol with local linkage must have default visibility");
|
||||
|
||||
unsigned AddrSpace;
|
||||
bool IsConstant, UnnamedAddr, IsExternallyInitialized;
|
||||
GlobalVariable::ThreadLocalMode TLM;
|
||||
@ -3014,6 +3027,10 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
|
||||
return Error(LinkageLoc, "invalid function linkage type");
|
||||
}
|
||||
|
||||
if (!isValidVisibilityForLinkage(Visibility, Linkage))
|
||||
return Error(LinkageLoc,
|
||||
"symbol with local linkage must have default visibility");
|
||||
|
||||
if (!FunctionType::isValidReturnType(RetType))
|
||||
return Error(RetTypeLoc, "invalid function return type");
|
||||
|
||||
|
Reference in New Issue
Block a user