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

2019-07-01 Thread Trevor Harrison via cfe-users
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).
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


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

2019-07-01 Thread Trevor Harrison via cfe-users
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 
wrote:

> 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).
>
>
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users