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

Michael Buch via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 22 04:16:47 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);
----------------
Michael137 wrote:

> The only difference between that and my patched Clang is that our name is _BitInt and GCC's is _BitInt(15)

At least for LLDB, I'd have to double check how the type-name ends up being displayed. If it just uses the `DW_AT_name` then that would be great! But if we eventually can just create a `clang::BitIntType` from this DIE and the bit-ness, I think Clang's `TypePrinter` is capable of printing the typename as we would expect: https://github.com/llvm/llvm-project/blob/15d11ebc84886e06127750ef5bea60ba1d36798a/clang/lib/AST/TypePrinter.cpp#L1483-L1488

Not opposed to aligning with GCC either though. And might be useful for other consumers 🤷‍♂️ But maybe best for a separate patch?

There was an LLDB issue around `_BitInt` a while ago where we talked about what would need to be done to support the type properly: https://github.com/llvm/llvm-project/issues/110273#issuecomment-2380091825

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


More information about the llvm-commits mailing list