summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2016-05-16 22:45:10 +0000
committerAdrian Prantl <aprantl@apple.com>2016-05-16 22:45:10 +0000
commite7d833defb62c1e4a1944cbad740f540c0ab44d2 (patch)
tree8879ad66559a854ebbeef2669ea2d6bf9cd55ade /llvm
parent85df931dea607ef0c411ce6c01fe60afb5aa8d6a (diff)
downloadbcm5719-llvm-e7d833defb62c1e4a1944cbad740f540c0ab44d2.tar.gz
bcm5719-llvm-e7d833defb62c1e4a1944cbad740f540c0ab44d2.zip
Debug info: Don't emit a DW_AT_byte_size when emitting a DWARF4 bit field.
The DWARF spec clearly states that a bit field member should have either a DW_AT_byte_size or a DW_AT_bit_size, but not both. Also the DW_AT_byte_size is redundant with the size of the type of the member. This fixes a bug found in PR 27758. llvm-svn: 269714
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp3
-rw-r--r--llvm/test/DebugInfo/X86/bitfields-dwarf4.ll9
2 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 51f25ec0fe6..4011934c26f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1393,7 +1393,8 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) {
if (FieldSize && Size != FieldSize) {
// Handle bitfield, assume bytes are 8 bits.
- addUInt(MemberDie, dwarf::DW_AT_byte_size, None, FieldSize/8);
+ if (DD->getDwarfVersion() < 4)
+ addUInt(MemberDie, dwarf::DW_AT_byte_size, None, FieldSize/8);
addUInt(MemberDie, dwarf::DW_AT_bit_size, None, Size);
uint64_t Offset = DT->getOffsetInBits();
diff --git a/llvm/test/DebugInfo/X86/bitfields-dwarf4.ll b/llvm/test/DebugInfo/X86/bitfields-dwarf4.ll
index f83980dacb1..23b8bca7580 100644
--- a/llvm/test/DebugInfo/X86/bitfields-dwarf4.ll
+++ b/llvm/test/DebugInfo/X86/bitfields-dwarf4.ll
@@ -46,7 +46,10 @@ target triple = "x86_64-apple-macosx"
; CHECK-NEXT: DW_AT_name{{.*}}"b"
; CHECK-NOT: DW_TAG
; CHECK-NOT: DW_AT_bit_offset
-; CHECK: DW_AT_data_bit_offset [DW_FORM_data1] (0x08)
+; CHECK-NOT: DW_AT_byte_size
+; 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)
!9 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !5, file: !1, line: 6, baseType: !10, size: 5, align: 32, offset: 8)
@@ -58,7 +61,9 @@ target triple = "x86_64-apple-macosx"
; CHECK-NEXT: DW_AT_name{{.*}}"c"
; CHECK-NOT: DW_TAG
; CHECK-NOT: DW_AT_bit_offset
-; CHECK: DW_AT_data_bit_offset [DW_FORM_data1] (0x0d)
+; 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)
!13 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !5, file: !1, line: 7, baseType: !10, size: 27, align: 32, offset: 13)
OpenPOWER on IntegriCloud