[DebugInfo] Change DIEnumerator payload type from int64_t to APInt

This allows the representation of arbitrarily large enumeration values.
See https://lists.llvm.org/pipermail/llvm-dev/2017-December/119475.html for context.

Reviewed By: andrewrk, aprantl, MaskRay

Differential Revision: https://reviews.llvm.org/D62475
This commit is contained in:
LemonBoy
2020-04-18 11:31:38 -07:00
committed by Fangrui Song
parent ecddafd84a
commit aad3d578da
17 changed files with 145 additions and 72 deletions

View File

@@ -2317,7 +2317,7 @@ Error BitcodeReader::resolveGlobalAndIndirectSymbolInits() {
return Error::success();
}
static APInt readWideAPInt(ArrayRef<uint64_t> Vals, unsigned TypeBits) {
APInt llvm::readWideAPInt(ArrayRef<uint64_t> Vals, unsigned TypeBits) {
SmallVector<uint64_t, 8> Words(Vals.size());
transform(Vals, Words.begin(),
BitcodeReader::decodeSignRotatedValue);

View File

@@ -1277,14 +1277,24 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
break;
}
case bitc::METADATA_ENUMERATOR: {
if (Record.size() != 3)
if (Record.size() < 3)
return error("Invalid record");
IsDistinct = Record[0] & 1;
bool IsUnsigned = Record[0] & 2;
bool IsBigInt = Record[0] & 4;
APInt Value;
if (IsBigInt) {
const uint64_t BitWidth = Record[1];
const size_t NumWords = Record.size() - 3;
Value = readWideAPInt(makeArrayRef(&Record[3], NumWords), BitWidth);
} else
Value = APInt(64, unrotateSign(Record[1]), !IsUnsigned);
MetadataList.assignValue(
GET_OR_DISTINCT(DIEnumerator, (Context, unrotateSign(Record[1]),
IsUnsigned, getMDString(Record[2]))),
GET_OR_DISTINCT(DIEnumerator,
(Context, Value, IsUnsigned, getMDString(Record[2]))),
NextMetadataNo);
NextMetadataNo++;
break;