[clang] [llvm] Non constant size and offset in DWARF (PR #141106)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 17 13:40:43 PDT 2025


================
@@ -1525,15 +1525,24 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
     if (Record.size() < 6 || Record.size() > 8)
       return error("Invalid record");
 
-    IsDistinct = Record[0];
+    IsDistinct = Record[0] & 1;
+    bool SizeIsMetadata = Record[0] & 2;
     DINode::DIFlags Flags = (Record.size() > 6)
                                 ? static_cast<DINode::DIFlags>(Record[6])
                                 : DINode::FlagZero;
     uint32_t NumExtraInhabitants = (Record.size() > 7) ? Record[7] : 0;
 
+    Metadata *SizeInBits;
+    if (SizeIsMetadata) {
+      SizeInBits = getMDOrNull(Record[3]);
+    } else {
+      SizeInBits = ConstantAsMetadata::get(
+          ConstantInt::get(Type::getInt64Ty(Context), Record[3]));
+    }
----------------
dwblaikie wrote:

Could use a conditional operator here (& similar places) - but I don't feel super strongly about it.

This appears a few times - might be worth a helper function?

https://github.com/llvm/llvm-project/pull/141106


More information about the llvm-commits mailing list