[cfe-users] DWARF bit field offset wrong values in LLVM

Trevor Harrison via cfe-users cfe-users at lists.llvm.org
Mon Jul 1 11:24:03 PDT 2019

Yeah, ignore my ramblings.  LLVM is fine, I was visually confusing the
pre-dwarf4 bit_offset attribute value with new hotness of data_bit_offset.
Thanks Matthew for the cfe-dev suggestion.

On Mon, Jul 1, 2019 at 12:17 PM Trevor Harrison <tharrison at eci-usa.net>

> I'm trying to extract information about bitfields in a structure using
> DWARF info.
> The info generated by LLVM seems to be incorrect and not following the
> DWARF standard.
> If this isn't the right mailing list, please let me know.
> If you look at DwarfUnit.cpp in the current LLVM src, it is using
> DIDerivedType.getOffsetInBits() for the value of DW_AT_data_bit_offset.
> The DWARF standard states that the bit offset: "is the offset in bits from
> the beginning of the containing storage to the beginning of the value",
> meaning the field the bitfield is packed in, not the structure holding the
> field.
> As a result of this, the values that LLVM emit are completely out of line
> with the values that I'm seeing come from gcc.
> (Of course, you can't use a naive example where the bitfields are at the
> beginning of the struct to test this, they need to occur later in the
> struct).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20190701/0b762e51/attachment.html>

More information about the cfe-users mailing list