mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-17 21:25:33 +00:00
AsmWriter/Bitcode: MDDerivedType and MDCompositeType
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229009 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1183,12 +1183,17 @@ std::error_code BitcodeReader::ParseMetadata() {
|
||||
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
|
||||
auto getMD =
|
||||
[&](unsigned ID) -> Metadata *{ return MDValueList.getValueFwdRef(ID); };
|
||||
auto getMDOrNull = [&](unsigned ID) -> Metadata *{
|
||||
if (ID)
|
||||
return getMD(ID - 1);
|
||||
return nullptr;
|
||||
};
|
||||
auto getMDString = [&](unsigned ID) -> MDString *{
|
||||
// This requires that the ID is not really a forward reference. In
|
||||
// particular, the MDString must already have been resolved.
|
||||
if (ID)
|
||||
return cast<MDString>(MDValueList.getValueFwdRef(ID - 1));
|
||||
return nullptr;
|
||||
return cast_or_null<MDString>(getMDOrNull(ID));
|
||||
};
|
||||
|
||||
#define GET_OR_DISTINCT(CLASS, DISTINCT, ARGS) \
|
||||
@@ -1382,6 +1387,36 @@ std::error_code BitcodeReader::ParseMetadata() {
|
||||
NextMDValueNo++);
|
||||
break;
|
||||
}
|
||||
case bitc::METADATA_DERIVED_TYPE: {
|
||||
if (Record.size() != 12)
|
||||
return Error("Invalid record");
|
||||
|
||||
MDValueList.AssignValue(
|
||||
GET_OR_DISTINCT(MDDerivedType, Record[0],
|
||||
(Context, Record[1], getMDString(Record[2]),
|
||||
getMDOrNull(Record[3]), Record[4],
|
||||
getMDOrNull(Record[5]), getMD(Record[6]), Record[7],
|
||||
Record[8], Record[9], Record[10],
|
||||
getMDOrNull(Record[11]))),
|
||||
NextMDValueNo++);
|
||||
break;
|
||||
}
|
||||
case bitc::METADATA_COMPOSITE_TYPE: {
|
||||
if (Record.size() != 16)
|
||||
return Error("Invalid record");
|
||||
|
||||
MDValueList.AssignValue(
|
||||
GET_OR_DISTINCT(MDCompositeType, Record[0],
|
||||
(Context, Record[1], getMDString(Record[2]),
|
||||
getMDOrNull(Record[3]), Record[4],
|
||||
getMDOrNull(Record[5]), getMDOrNull(Record[6]),
|
||||
Record[7], Record[8], Record[9], Record[10],
|
||||
getMDOrNull(Record[11]), Record[12],
|
||||
getMDOrNull(Record[13]), getMDOrNull(Record[14]),
|
||||
getMDString(Record[15]))),
|
||||
NextMDValueNo++);
|
||||
break;
|
||||
}
|
||||
case bitc::METADATA_FILE: {
|
||||
if (Record.size() != 3)
|
||||
return Error("Invalid record");
|
||||
|
Reference in New Issue
Block a user