diff options
author | Paul Robinson <paul.robinson@sony.com> | 2018-11-28 21:14:32 +0000 |
---|---|---|
committer | Paul Robinson <paul.robinson@sony.com> | 2018-11-28 21:14:32 +0000 |
commit | adcdc1bd0a8802f5260162b8b63762724bf1ff32 (patch) | |
tree | 28d822fb67ffaf3f2af2e8b7573a1a80d551a9f3 /llvm/lib/Bitcode/Reader | |
parent | 7304f0a66eef2951441af1f77aab3baf453825fe (diff) | |
download | bcm5719-llvm-adcdc1bd0a8802f5260162b8b63762724bf1ff32.tar.gz bcm5719-llvm-adcdc1bd0a8802f5260162b8b63762724bf1ff32.zip |
[DebugInfo] IR/Bitcode changes for DISubprogram flags.
Packing the flags into one bitcode word will save effort in
adding new flags in the future.
Differential Revision: https://reviews.llvm.org/D54755
llvm-svn: 347806
Diffstat (limited to 'llvm/lib/Bitcode/Reader')
-rw-r--r-- | llvm/lib/Bitcode/Reader/MetadataLoader.cpp | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp index 08a6ab5d847..3289aa0acdd 100644 --- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp @@ -1406,23 +1406,43 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( if (Record.size() < 18 || Record.size() > 21) return error("Invalid record"); - IsDistinct = - (Record[0] & 1) || Record[8]; // All definitions should be distinct. + bool HasSPFlags = Record[0] & 4; + DISubprogram::DISPFlags SPFlags = + HasSPFlags + ? static_cast<DISubprogram::DISPFlags>(Record[9]) + : DISubprogram::toSPFlags( + /*IsLocalToUnit=*/Record[7], /*IsDefinition=*/Record[8], + /*IsOptimized=*/Record[14], /*Virtuality=*/Record[11]); + + // All definitions should be distinct. + IsDistinct = (Record[0] & 1) || (SPFlags & DISubprogram::SPFlagDefinition); // Version 1 has a Function as Record[15]. // Version 2 has removed Record[15]. // Version 3 has the Unit as Record[15]. // Version 4 added thisAdjustment. - bool HasUnit = Record[0] >= 2; - if (HasUnit && Record.size() < 19) + // Version 5 repacked flags into DISPFlags, changing many element numbers. + bool HasUnit = Record[0] & 2; + if (!HasSPFlags && HasUnit && Record.size() < 19) return error("Invalid record"); - Metadata *CUorFn = getMDOrNull(Record[15]); - unsigned Offset = Record.size() >= 19 ? 1 : 0; - bool HasFn = Offset && !HasUnit; - bool HasThisAdj = Record.size() >= 20; - bool HasThrownTypes = Record.size() >= 21; - DISubprogram::DISPFlags SPFlags = DISubprogram::toSPFlags( - /*IsLocalToUnit=*/Record[7], /*IsDefinition=*/Record[8], - /*IsOptimized=*/Record[14], /*Virtuality=*/Record[11]); + if (HasSPFlags && !HasUnit) + return error("Invalid record"); + // Accommodate older formats. + bool HasFn = false; + bool HasThisAdj = true; + bool HasThrownTypes = true; + unsigned OffsetA = 0; + unsigned OffsetB = 0; + if (!HasSPFlags) { + OffsetA = 2; + OffsetB = 2; + if (Record.size() >= 19) { + HasFn = !HasUnit; + OffsetB++; + } + HasThisAdj = Record.size() >= 20; + HasThrownTypes = Record.size() >= 21; + } + Metadata *CUorFn = getMDOrNull(Record[12 + OffsetB]); DISubprogram *SP = GET_OR_DISTINCT( DISubprogram, (Context, @@ -1432,17 +1452,18 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( getMDOrNull(Record[4]), // file Record[5], // line getMDOrNull(Record[6]), // type - Record[9], // scopeLine - getDITypeRefOrNull(Record[10]), // containingType - Record[12], // virtualIndex - HasThisAdj ? Record[19] : 0, // thisAdjustment - static_cast<DINode::DIFlags>(Record[13]), // flags + Record[7 + OffsetA], // scopeLine + getDITypeRefOrNull(Record[8 + OffsetA]), // containingType + Record[10 + OffsetA], // virtualIndex + HasThisAdj ? Record[16 + OffsetB] : 0, // thisAdjustment + static_cast<DINode::DIFlags>(Record[11 + OffsetA]),// flags SPFlags, // SPFlags HasUnit ? CUorFn : nullptr, // unit - getMDOrNull(Record[15 + Offset]), // templateParams - getMDOrNull(Record[16 + Offset]), // declaration - getMDOrNull(Record[17 + Offset]), // retainedNodes - HasThrownTypes ? getMDOrNull(Record[20]) : nullptr // thrownTypes + getMDOrNull(Record[13 + OffsetB]), // templateParams + getMDOrNull(Record[14 + OffsetB]), // declaration + getMDOrNull(Record[15 + OffsetB]), // retainedNodes + HasThrownTypes ? getMDOrNull(Record[17 + OffsetB]) + : nullptr // thrownTypes )); MetadataList.assignValue(SP, NextMetadataNo); NextMetadataNo++; |