mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 21:24:00 +00:00
Bring r226038 back.
No change in this commit, but clang was changed to also produce trivial comdats when needed. Original message: Don't create new comdats in CodeGen. This patch stops the implicit creation of comdats during codegen. Clang now sets the comdat explicitly when it is required. With this patch clang and gcc now produce the same result in pr19848. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226467 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -156,19 +156,27 @@ static bool ConvertToString(ArrayRef<uint64_t> Record, unsigned Idx,
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool hasImplicitComdat(size_t Val) {
|
||||
switch (Val) {
|
||||
default:
|
||||
return false;
|
||||
case 1: // Old WeakAnyLinkage
|
||||
case 4: // Old LinkOnceAnyLinkage
|
||||
case 10: // Old WeakODRLinkage
|
||||
case 11: // Old LinkOnceODRLinkage
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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::ExternalLinkage; // Obsolete DLLImportLinkage
|
||||
case 6:
|
||||
@ -179,10 +187,6 @@ static GlobalValue::LinkageTypes getDecodedLinkage(unsigned Val) {
|
||||
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:
|
||||
@ -191,6 +195,18 @@ static GlobalValue::LinkageTypes getDecodedLinkage(unsigned Val) {
|
||||
return GlobalValue::PrivateLinkage; // Obsolete LinkerPrivateWeakLinkage
|
||||
case 15:
|
||||
return GlobalValue::ExternalLinkage; // Obsolete LinkOnceODRAutoHideLinkage
|
||||
case 1: // Old value with implicit comdat.
|
||||
case 16:
|
||||
return GlobalValue::WeakAnyLinkage;
|
||||
case 10: // Old value with implicit comdat.
|
||||
case 17:
|
||||
return GlobalValue::WeakODRLinkage;
|
||||
case 4: // Old value with implicit comdat.
|
||||
case 18:
|
||||
return GlobalValue::LinkOnceAnyLinkage;
|
||||
case 11: // Old value with implicit comdat.
|
||||
case 19:
|
||||
return GlobalValue::LinkOnceODRLinkage;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1118,6 +1134,10 @@ std::error_code BitcodeReader::ParseValueSymbolTable() {
|
||||
Value *V = ValueList[ValueID];
|
||||
|
||||
V->setName(StringRef(ValueName.data(), ValueName.size()));
|
||||
if (auto *GO = dyn_cast<GlobalObject>(V)) {
|
||||
if (GO->getComdat() == reinterpret_cast<Comdat *>(1))
|
||||
GO->setComdat(TheModule->getOrInsertComdat(V->getName()));
|
||||
}
|
||||
ValueName.clear();
|
||||
break;
|
||||
}
|
||||
@ -2140,7 +2160,8 @@ std::error_code BitcodeReader::ParseModule(bool Resume) {
|
||||
Ty = cast<PointerType>(Ty)->getElementType();
|
||||
|
||||
bool isConstant = Record[1];
|
||||
GlobalValue::LinkageTypes Linkage = getDecodedLinkage(Record[3]);
|
||||
uint64_t RawLinkage = Record[3];
|
||||
GlobalValue::LinkageTypes Linkage = getDecodedLinkage(RawLinkage);
|
||||
unsigned Alignment = (1 << Record[4]) >> 1;
|
||||
std::string Section;
|
||||
if (Record[5]) {
|
||||
@ -2178,7 +2199,7 @@ std::error_code BitcodeReader::ParseModule(bool Resume) {
|
||||
if (Record.size() > 10)
|
||||
NewGV->setDLLStorageClass(GetDecodedDLLStorageClass(Record[10]));
|
||||
else
|
||||
UpgradeDLLImportExportLinkage(NewGV, Record[3]);
|
||||
UpgradeDLLImportExportLinkage(NewGV, RawLinkage);
|
||||
|
||||
ValueList.push_back(NewGV);
|
||||
|
||||
@ -2186,11 +2207,14 @@ std::error_code BitcodeReader::ParseModule(bool Resume) {
|
||||
if (unsigned InitID = Record[2])
|
||||
GlobalInits.push_back(std::make_pair(NewGV, InitID-1));
|
||||
|
||||
if (Record.size() > 11)
|
||||
if (Record.size() > 11) {
|
||||
if (unsigned ComdatID = Record[11]) {
|
||||
assert(ComdatID <= ComdatList.size());
|
||||
NewGV->setComdat(ComdatList[ComdatID - 1]);
|
||||
}
|
||||
} else if (hasImplicitComdat(RawLinkage)) {
|
||||
NewGV->setComdat(reinterpret_cast<Comdat *>(1));
|
||||
}
|
||||
break;
|
||||
}
|
||||
// FUNCTION: [type, callingconv, isproto, linkage, paramattr,
|
||||
@ -2214,7 +2238,8 @@ std::error_code BitcodeReader::ParseModule(bool Resume) {
|
||||
|
||||
Func->setCallingConv(static_cast<CallingConv::ID>(Record[1]));
|
||||
bool isProto = Record[2];
|
||||
Func->setLinkage(getDecodedLinkage(Record[3]));
|
||||
uint64_t RawLinkage = Record[3];
|
||||
Func->setLinkage(getDecodedLinkage(RawLinkage));
|
||||
Func->setAttributes(getAttributes(Record[4]));
|
||||
|
||||
Func->setAlignment((1 << Record[5]) >> 1);
|
||||
@ -2242,13 +2267,16 @@ std::error_code BitcodeReader::ParseModule(bool Resume) {
|
||||
if (Record.size() > 11)
|
||||
Func->setDLLStorageClass(GetDecodedDLLStorageClass(Record[11]));
|
||||
else
|
||||
UpgradeDLLImportExportLinkage(Func, Record[3]);
|
||||
UpgradeDLLImportExportLinkage(Func, RawLinkage);
|
||||
|
||||
if (Record.size() > 12)
|
||||
if (Record.size() > 12) {
|
||||
if (unsigned ComdatID = Record[12]) {
|
||||
assert(ComdatID <= ComdatList.size());
|
||||
Func->setComdat(ComdatList[ComdatID - 1]);
|
||||
}
|
||||
} else if (hasImplicitComdat(RawLinkage)) {
|
||||
Func->setComdat(reinterpret_cast<Comdat *>(1));
|
||||
}
|
||||
|
||||
if (Record.size() > 13 && Record[13] != 0)
|
||||
FunctionPrefixes.push_back(std::make_pair(Func, Record[13]-1));
|
||||
|
Reference in New Issue
Block a user