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

Orlando Cazalet-Hyams via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 21 10:19:12 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);
----------------
OCHyams wrote:

>  though it'd be a bit out-of-DWARF-spec which says a base type should have only one or the other.

My interpretation of the DWARF spec especially is it allows it for base types (chpt 5, page end of 103 to top of 104):

> A base type entry has a DW_AT_byte_size attribute or a DW_AT_bit_size attribute. [...] If the value of an object of the given type does not fully occupy the storage described by a byte size attribute, the base type entry may **also** have a DW_AT_bit_size and a DW_AT_data_bit_offset attribute

It says both "or" and "and" which is a bit ambiguous, but other types only say "or".

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


More information about the cfe-commits mailing list