mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +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:
@ -1856,7 +1856,9 @@ error_code BitcodeReader::ParseModule(bool Resume) {
|
||||
Section = SectionTable[Record[5]-1];
|
||||
}
|
||||
GlobalValue::VisibilityTypes Visibility = GlobalValue::DefaultVisibility;
|
||||
if (Record.size() > 6)
|
||||
// Local linkage must have default visibility.
|
||||
if (Record.size() > 6 && !GlobalValue::isLocalLinkage(Linkage))
|
||||
// FIXME: Change to an error if non-default in 4.0.
|
||||
Visibility = GetDecodedVisibility(Record[6]);
|
||||
|
||||
GlobalVariable::ThreadLocalMode TLM = GlobalVariable::NotThreadLocal;
|
||||
@ -1922,7 +1924,10 @@ error_code BitcodeReader::ParseModule(bool Resume) {
|
||||
return Error(InvalidID);
|
||||
Func->setSection(SectionTable[Record[6]-1]);
|
||||
}
|
||||
Func->setVisibility(GetDecodedVisibility(Record[7]));
|
||||
// Local linkage must have default visibility.
|
||||
if (!Func->hasLocalLinkage())
|
||||
// FIXME: Change to an error if non-default in 4.0.
|
||||
Func->setVisibility(GetDecodedVisibility(Record[7]));
|
||||
if (Record.size() > 8 && Record[8]) {
|
||||
if (Record[8]-1 > GCTable.size())
|
||||
return Error(InvalidID);
|
||||
@ -1964,7 +1969,9 @@ error_code BitcodeReader::ParseModule(bool Resume) {
|
||||
GlobalAlias *NewGA = new GlobalAlias(Ty, GetDecodedLinkage(Record[2]),
|
||||
"", nullptr, TheModule);
|
||||
// Old bitcode files didn't have visibility field.
|
||||
if (Record.size() > 3)
|
||||
// Local linkage must have default visibility.
|
||||
if (Record.size() > 3 && !NewGA->hasLocalLinkage())
|
||||
// FIXME: Change to an error if non-default in 4.0.
|
||||
NewGA->setVisibility(GetDecodedVisibility(Record[3]));
|
||||
if (Record.size() > 4)
|
||||
NewGA->setDLLStorageClass(GetDecodedDLLStorageClass(Record[4]));
|
||||
|
Reference in New Issue
Block a user