[llvm] r269714 - Debug info: Don't emit a DW_AT_byte_size when emitting a DWARF4 bit field.
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Mon May 16 15:45:11 PDT 2016
Author: adrian
Date: Mon May 16 17:45:10 2016
New Revision: 269714
URL: http://llvm.org/viewvc/llvm-project?rev=269714&view=rev
Log:
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.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
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=269714&r1=269713&r2=269714&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Mon May 16 17:45:10 2016
@@ -1393,7 +1393,8 @@ void DwarfUnit::constructMemberDIE(DIE &
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();
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=269714&r1=269713&r2=269714&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/bitfields-dwarf4.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/bitfields-dwarf4.ll Mon May 16 17:45:10 2016
@@ -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)
More information about the llvm-commits
mailing list