llvm.org GIT mirror llvm / 94a19b6
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269731 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 4 years ago
3 changed file(s) with 6 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
13891389 uint64_t Size = DT->getSizeInBits();
13901390 uint64_t FieldSize = getBaseTypeSize(DD, DT);
13911391 uint64_t OffsetInBytes;
1392
1393 if (FieldSize && Size != FieldSize) {
1392 bool IsBitfield = FieldSize && Size != FieldSize;
1393 if (IsBitfield) {
13941394 // Handle bitfield, assume bytes are 8 bits.
13951395 if (DD->getDwarfVersion() < 4)
13961396 addUInt(MemberDie, dwarf::DW_AT_byte_size, None, FieldSize/8);
14271427 addUInt(*MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
14281428 addUInt(*MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
14291429 addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
1430 } else
1430 } else if (!IsBitfield || DD->getDwarfVersion() < 4)
14311431 addUInt(MemberDie, dwarf::DW_AT_data_member_location, None,
14321432 OffsetInBytes);
14331433 }
2828 ; CHECK-NEXT: DW_AT_name{{.*}}"j"
2929 ; CHECK-NOT: DW_TAG
3030 ; CHECK: DW_AT_data_bit_offset [DW_FORM_data1] (0x00)
31 ; CHECK: DW_AT_data_member_location [DW_FORM_data1] (0x00)
3231 !7 = !DIDerivedType(tag: DW_TAG_member, name: "j", scope: !5, file: !1, line: 2, baseType: !8, size: 5, align: 32)
3332 !8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
3433 ; CHECK: DW_TAG_member
3534 ; CHECK-NEXT: DW_AT_name{{.*}}"k"
3635 ; CHECK-NOT: DW_TAG
3736 ; CHECK: DW_AT_data_bit_offset [DW_FORM_data1] (0x05)
38 ; CHECK: DW_AT_data_member_location [DW_FORM_data1] (0x00)
3937 !9 = !DIDerivedType(tag: DW_TAG_member, name: "k", scope: !5, file: !1, line: 3, baseType: !8, size: 6, align: 32, offset: 5)
4038 ; CHECK: DW_TAG_member
4139 ; CHECK-NEXT: DW_AT_name{{.*}}"m"
4240 ; CHECK-NOT: DW_TAG
4341 ; CHECK: DW_AT_data_bit_offset [DW_FORM_data1] (0x0b)
44 ; CHECK: DW_AT_data_member_location [DW_FORM_data1] (0x00)
4542 !10 = !DIDerivedType(tag: DW_TAG_member, name: "m", scope: !5, file: !1, line: 4, baseType: !8, size: 5, align: 32, offset: 11)
4643 ; CHECK: DW_TAG_member
4744 ; CHECK-NEXT: DW_AT_name{{.*}}"n"
4845 ; CHECK-NOT: DW_TAG
4946 ; CHECK: DW_AT_data_bit_offset [DW_FORM_data1] (0x10)
50 ; CHECK: DW_AT_data_member_location [DW_FORM_data1] (0x00)
5147 !11 = !DIDerivedType(tag: DW_TAG_member, name: "n", scope: !5, file: !1, line: 5, baseType: !8, size: 8, align: 32, offset: 16)
5248 !12 = !{i32 2, !"Dwarf Version", i32 4}
5349 !13 = !{i32 2, !"Debug Info Version", i32 3}
4949 ; CHECK: DW_AT_bit_size [DW_FORM_data1] (0x05)
5050 ; CHECK-NOT: DW_AT_byte_size
5151 ; CHECK-NEXT: DW_AT_data_bit_offset [DW_FORM_data1] (0x08)
52 ; CHECK-NEXT: DW_AT_data_member_location [DW_FORM_data1] (0x00)
52 ; CHECK-NOT: DW_AT_data_member_location
5353 !9 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !5, file: !1, line: 6, baseType: !10, size: 5, align: 32, offset: 8)
5454
5555 !10 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint32_t", file: !11, line: 183, baseType: !12)
6363 ; CHECK-NOT: DW_AT_byte_size
6464 ; CHECK: DW_AT_bit_size [DW_FORM_data1] (0x1b)
6565 ; CHECK-NEXT: DW_AT_data_bit_offset [DW_FORM_data1] (0x0d)
66 ; CHECK-NEXT: DW_AT_data_member_location [DW_FORM_data1] (0x00)
66 ; CHECK-NOT: DW_AT_data_member_location
67 ; CHECK: DW_TAG
6768 !13 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !5, file: !1, line: 7, baseType: !10, size: 27, align: 32, offset: 13)
6869
6970 !14 = !{i32 2, !"Dwarf Version", i32 4}