llvm.org GIT mirror llvm / ee1e043
Debug Info: Restore the pre-r240853 behavior for DWARF2 bitfields. The DWARF2 specification of DW_AT_bit_offset is ambiguous for little-endian machines, but by restoring to the old behavior we match what debuggers expect and what other popular compilers generate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267896 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 4 years ago
2 changed file(s) with 11 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
14061406 if (DD->getDwarfVersion() >= 4)
14071407 addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, None, Offset);
14081408 else {
1409 //
1410 // The DWARF 2 DW_AT_bit_offset is counting the bits between the most
1411 // significant bit of the aligned storage unit containing the bit field
1412 // to
1413 // the most significan bit of the bit field.
1414 //
1415 // Struct Align Align Align
1416 // v v v v
1417 // +-----------+-----*-----+-----*-----+--
1418 // | ... |b1|b2|b3|b4|
1419 // +-----------+-----*-----+-----*-----+--
1420 // | | |<-- Size ->| |
1421 // |<---- Offset --->| |<--->|
1422 // | | | \_ DW_AT_bit_offset (little endian)
1423 // | |<--->|
1424 // |<--------->| \_ StartBitOffset = DW_AT_bit_offset (big endian)
1425 // \ = DW_AT_data_bit_offset (biendian)
1426 // \_ OffsetInBytes
1427 // The endian-dependent DWARF 2 offset.
1428 uint64_t DwarfBitOffset = Asm->getDataLayout().isLittleEndian()
1429 ? OffsetToAlignment(Offset + Size, Align)
1430 : StartBitOffset;
1431
1432 addUInt(MemberDie, dwarf::DW_AT_bit_offset, None, DwarfBitOffset);
1409 uint64_t HiMark = (Offset + FieldSize) & AlignMask;
1410 uint64_t FieldOffset = (HiMark - FieldSize);
1411 Offset -= FieldOffset;
1412
1413 // Maybe we need to work from the other end.
1414 if (Asm->getDataLayout().isLittleEndian())
1415 Offset = FieldSize - (Offset + Size);
1416
1417 addUInt(MemberDie, dwarf::DW_AT_bit_offset, None, Offset);
1418 OffsetInBytes = FieldOffset >> 3;
14331419 }
14341420 } else
14351421 // This is not a bitfield.
1212 ; CHECK: DW_AT_name {{.*}} "reserved"
1313 ; CHECK: DW_AT_byte_size {{.*}} (0x04)
1414 ; CHECK: DW_AT_bit_size {{.*}} (0x1c)
15 ; CHECK: DW_AT_bit_offset {{.*}} (0x18)
15 ; CHECK: DW_AT_bit_offset {{.*}} (0xfffffffffffffff8)
1616 ; CHECK: DW_AT_data_member_location {{.*}}00
1717 target datalayout = "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
1818 target triple = "thumbv7-apple-ios"