From: Adrian Prantl Date: Fri, 26 Jun 2015 21:27:30 +0000 (+0000) Subject: Debug Info: Clarify the documentation for bitfields emission. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=7cb828a34db7e7115fe9a03cd5435532599dbcb9;p=oota-llvm.git Debug Info: Clarify the documentation for bitfields emission. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240835 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 51a268a5f7e..f95f79d903c 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1346,6 +1346,13 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) { addUInt(MemberDie, dwarf::DW_AT_byte_size, None, FieldSize/8); addUInt(MemberDie, dwarf::DW_AT_bit_size, None, Size); + // The DWARF 2 DW_AT_bit_offset is counting the bits between + // the high end of the aligned storage unit containing the bit + // field to the high end of the bit field. + // + // FIXME: DWARF 4 states that DW_AT_data_bit_offset (which + // counts from the beginning, regardless of endianness) should + // be used instead. uint64_t Offset = DT->getOffsetInBits(); uint64_t AlignMask = ~(DT->getAlignInBits() - 1); uint64_t HiMark = (Offset + FieldSize) & AlignMask; @@ -1357,8 +1364,6 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) { Offset = FieldSize - (Offset + Size); addUInt(MemberDie, dwarf::DW_AT_bit_offset, None, Offset); - // Here DW_AT_data_member_location points to the anonymous - // field that includes this bit field. OffsetInBytes = FieldOffset >> 3; } else // This is not a bitfield.