[clang] [llvm] [DebugInfo] Emit DW_AT_bit_size for _BitInt types and others (PR #164372)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 21 10:11:10 PDT 2025


================
@@ -766,8 +766,17 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIBasicType *BTy) {
     addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
             BTy->getEncoding());
 
-  uint64_t Size = BTy->getSizeInBits() >> 3;
-  addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, Size);
+  uint64_t SizeInBytes = divideCeil(BTy->getSizeInBits(), 8);
----------------
dwblaikie wrote:

I assume this thing has a byte storage size, even if the arithmetic is done exactly to the number of bits specified? So I'd imagine we could want both - though it'd be a bit out-of-DWARF-spec which says a base type should have only one or the other. I guess really the thing has a byte_size, and a "number of bits used for arithmetic" - it's not really the size of the object, it's to do with the encoding/how the bits are used.

But I don't especially mind if we use the bit_size to encode "number of bits used for arithmetic", especially if GCC's already doing it.

Maybe file a DWARF issue as well.

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


More information about the llvm-commits mailing list