[llvm] r269731 - Debug Info: Don't emit a DW_AT_data_member_location for DWARF bitfields.
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Mon May 16 19:37:54 PDT 2016
Author: adrian
Date: Mon May 16 21:37:53 2016
New Revision: 269731
URL: http://llvm.org/viewvc/llvm-project?rev=269731&view=rev
Log:
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.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/trunk/test/DebugInfo/ARM/big-endian-bitfield.ll
llvm/trunk/test/DebugInfo/X86/bitfields-dwarf4.ll
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=269731&r1=269730&r2=269731&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Mon May 16 21:37:53 2016
@@ -1390,8 +1390,8 @@ void DwarfUnit::constructMemberDIE(DIE &
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 &
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);
}
Modified: llvm/trunk/test/DebugInfo/ARM/big-endian-bitfield.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/ARM/big-endian-bitfield.ll?rev=269731&r1=269730&r2=269731&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/ARM/big-endian-bitfield.ll (original)
+++ llvm/trunk/test/DebugInfo/ARM/big-endian-bitfield.ll Mon May 16 21:37:53 2016
@@ -29,26 +29,22 @@ target datalayout = "E-m:e-p:32:32-i64:6
; 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}
Modified: llvm/trunk/test/DebugInfo/X86/bitfields-dwarf4.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/bitfields-dwarf4.ll?rev=269731&r1=269730&r2=269731&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/bitfields-dwarf4.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/bitfields-dwarf4.ll Mon May 16 21:37:53 2016
@@ -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}
More information about the llvm-commits
mailing list