[llvm] [DebugInfo] Emit negative DW_AT_bit_offset in explicit signed form (PR #87994)
Victor Campos via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 18 03:59:22 PDT 2024
================
@@ -1664,7 +1666,12 @@ DIE &DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) {
if (Asm->getDataLayout().isLittleEndian())
Offset = FieldSize - (Offset + Size);
- addUInt(MemberDie, dwarf::DW_AT_bit_offset, std::nullopt, Offset);
+ if (Offset < 0)
+ addSInt(MemberDie, dwarf::DW_AT_bit_offset, dwarf::DW_FORM_sdata,
----------------
vhscampos wrote:
Comparing the specifications for DWARF 2 and DWARF 3, I can see that the section about bit fields is semantically the same. In the [DWARF 2 spec](https://dwarfstd.org/doc/dwarf-2.0.0.pdf), it's on page 42.
Also my understanding is that `useDWARF2Bitfields` includes v3 as well. Presumably because bit field's semantics haven't changed between the two versions.
As an extra check, I confirmed that gcc produces the same debug info for v2 and v3 in this case.
https://github.com/llvm/llvm-project/pull/87994
More information about the llvm-commits
mailing list