1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Debug Info: Don't emit a DW_AT_data_member_location for DWARF bitfields.

The DWARF spec states that a member entry may have either a
DW_AT_data_member_location or a DW_AT_data_bit_offset, but not both.

This fixes a bug found in PR 27758.

llvm-svn: 269731
This commit is contained in:
Adrian Prantl 2016-05-17 02:37:53 +00:00
parent fdf7fd7ebc
commit 562624c39d
3 changed files with 6 additions and 9 deletions

View File

@ -1390,8 +1390,8 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) {
uint64_t Size = DT->getSizeInBits();
uint64_t FieldSize = getBaseTypeSize(DD, DT);
uint64_t OffsetInBytes;
if (FieldSize && Size != FieldSize) {
bool IsBitfield = FieldSize && Size != FieldSize;
if (IsBitfield) {
// Handle bitfield, assume bytes are 8 bits.
if (DD->getDwarfVersion() < 4)
addUInt(MemberDie, dwarf::DW_AT_byte_size, None, FieldSize/8);
@ -1428,7 +1428,7 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) {
addUInt(*MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
addUInt(*MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
} else
} else if (!IsBitfield || DD->getDwarfVersion() < 4)
addUInt(MemberDie, dwarf::DW_AT_data_member_location, None,
OffsetInBytes);
}

View File

@ -29,26 +29,22 @@ target datalayout = "E-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
; CHECK-NEXT: DW_AT_name{{.*}}"j"
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_data_bit_offset [DW_FORM_data1] (0x00)
; CHECK: DW_AT_data_member_location [DW_FORM_data1] (0x00)
!7 = !DIDerivedType(tag: DW_TAG_member, name: "j", scope: !5, file: !1, line: 2, baseType: !8, size: 5, align: 32)
!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
; CHECK: DW_TAG_member
; CHECK-NEXT: DW_AT_name{{.*}}"k"
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_data_bit_offset [DW_FORM_data1] (0x05)
; CHECK: DW_AT_data_member_location [DW_FORM_data1] (0x00)
!9 = !DIDerivedType(tag: DW_TAG_member, name: "k", scope: !5, file: !1, line: 3, baseType: !8, size: 6, align: 32, offset: 5)
; CHECK: DW_TAG_member
; CHECK-NEXT: DW_AT_name{{.*}}"m"
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_data_bit_offset [DW_FORM_data1] (0x0b)
; CHECK: DW_AT_data_member_location [DW_FORM_data1] (0x00)
!10 = !DIDerivedType(tag: DW_TAG_member, name: "m", scope: !5, file: !1, line: 4, baseType: !8, size: 5, align: 32, offset: 11)
; CHECK: DW_TAG_member
; CHECK-NEXT: DW_AT_name{{.*}}"n"
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_data_bit_offset [DW_FORM_data1] (0x10)
; CHECK: DW_AT_data_member_location [DW_FORM_data1] (0x00)
!11 = !DIDerivedType(tag: DW_TAG_member, name: "n", scope: !5, file: !1, line: 5, baseType: !8, size: 8, align: 32, offset: 16)
!12 = !{i32 2, !"Dwarf Version", i32 4}
!13 = !{i32 2, !"Debug Info Version", i32 3}

View File

@ -50,7 +50,7 @@ target triple = "x86_64-apple-macosx"
; CHECK: DW_AT_bit_size [DW_FORM_data1] (0x05)
; CHECK-NOT: DW_AT_byte_size
; CHECK-NEXT: DW_AT_data_bit_offset [DW_FORM_data1] (0x08)
; CHECK-NEXT: DW_AT_data_member_location [DW_FORM_data1] (0x00)
; CHECK-NOT: DW_AT_data_member_location
!9 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !5, file: !1, line: 6, baseType: !10, size: 5, align: 32, offset: 8)
!10 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint32_t", file: !11, line: 183, baseType: !12)
@ -64,7 +64,8 @@ target triple = "x86_64-apple-macosx"
; CHECK-NOT: DW_AT_byte_size
; CHECK: DW_AT_bit_size [DW_FORM_data1] (0x1b)
; CHECK-NEXT: DW_AT_data_bit_offset [DW_FORM_data1] (0x0d)
; CHECK-NEXT: DW_AT_data_member_location [DW_FORM_data1] (0x00)
; CHECK-NOT: DW_AT_data_member_location
; CHECK: DW_TAG
!13 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !5, file: !1, line: 7, baseType: !10, size: 27, align: 32, offset: 13)
!14 = !{i32 2, !"Dwarf Version", i32 4}