[clang] [llvm] [DebugInfo] Emit DW_AT_bit_size for _BitInt types and others (PR #164372)
Vladislav Dzhidzhoev via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 21 03:57:07 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);
+ addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, SizeInBytes);
+ if (BTy->getTag() == dwarf::Tag::DW_TAG_base_type) {
+ // DW_TAG_base_type:
+ // 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 [...] attribute.
----------------
dzhidzhoev wrote:
The paragraph above says:
> A base type entry has a DW_AT_byte_size attribute or a
DW_AT_bit_size attribute whose integer constant value (see Section 2.21 on
page 62) is the amount of storage needed to hold a value of the type.
I might be misreading this, but it sounds like the spec implies a base type should have either DW_AT_byte_size or DW_AT_bit_size, not both. Is there a reason we need to emit both in this case?
https://github.com/llvm/llvm-project/pull/164372
More information about the llvm-commits
mailing list