[PATCH] D24425: DebugInfo: support for DWARFv5 DW_AT_alignment attribute
Victor Leschuk via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 10 02:54:41 PDT 2016
vleschuk marked 3 inline comments as done.
vleschuk added inline comments.
================
Comment at: lib/CodeGen/AsmPrinter/DwarfUnit.cpp:1415
// is non-zero if and only if alignment was forced (e.g. _Alignas()),
// which can't be done with bitfields. Thus we use FieldSize here.
uint64_t AlignInBits = FieldSize;
----------------
aprantl wrote:
> What about packed structs?
>
> Sorry, I'm just being very cautious about any changes here, because every single time I touched this code in that past I broke the either LLDB or GDB ;-)
>
> A couple of examples from the testsuite you can run through clang with both -gdwarf-2 and -gdwarf-4 and verify that the DWARF output didn't change:
>
> ```
> #pragma pack(1)
> struct PackedBits
> {
> char a;
> uint32_t b : 5,
> c : 27
> } s;
> #pragma pack()
>
> struct bitfield {
> int a : 2;
> int b : 32;
> int c : 1;
> int d : 28;
> }
>
> struct size8 {
> int i : 4;
> long long l : 60;
> };
>
>
> struct layout0 {
> char l0_ofs0;
> struct size8 l0_ofs8;
> int l0_ofs16 : 1;
> };
>
> struct size8_anon {
> int : 4;
> long long : 60;
> };
> struct layout1 {
> char l1_ofs0;
> struct size8_anon l1_ofs1;
> int l1_ofs9 : 1;
> };
>
> #pragma pack(1)
> struct size8_pack1 {
> int i : 4;
> long long l : 60;
> };
> struct layout2 {
> char l2_ofs0;
> struct size8_pack1 l2_ofs1;
> int l2_ofs9 : 1;
> };
> #pragma pack()
>
> #pragma pack(4)
> struct size8_pack4 {
> int i : 4;
> long long l : 60;
> };
> struct layout3 {
> char l3_ofs0;
> struct size8_pack4 l3_ofs4;
> int l3_ofs12 : 1;
> };
> #pragma pack()
>
> ```
>
We already have test for that: DebugInfo/X86/debug-info-packed-struct.ll - its based on debug-info-packed-struct.c from clang (the one you quoted). I also manually checked this both with dwarf-2 and dwarf-4, dwarf output is the same for clang 3.9 release and current build with my changes.
https://reviews.llvm.org/D24425
More information about the llvm-commits
mailing list