[llvm] r269840 - Debug Info: Introduce a DwarfDebug::UseDWARF2Bitfields flag

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Tue May 17 14:07:16 PDT 2016


Author: adrian
Date: Tue May 17 16:07:16 2016
New Revision: 269840

URL: http://llvm.org/viewvc/llvm-project?rev=269840&view=rev
Log:
Debug Info: Introduce a DwarfDebug::UseDWARF2Bitfields flag
instead of having DwarfUnit query the debugger tuning options.

Follow-up commmit to r269827.
Thanks to Paul Robinson for pointing this out!

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=269840&r1=269839&r2=269840&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue May 17 16:07:16 2016
@@ -264,6 +264,9 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Mo
   // https://sourceware.org/bugzilla/show_bug.cgi?id=11616
   UseGNUTLSOpcode = tuneForGDB() || DwarfVersion < 3;
 
+  // GDB does not fully support the DWARF 4 representation for bitfields.
+  UseDWARF2Bitfields = (DwarfVersion < 4) || tuneForGDB();
+
   Asm->OutStreamer->getContext().setDwarfVersion(DwarfVersion);
 
   {

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=269840&r1=269839&r2=269840&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue May 17 16:07:16 2016
@@ -248,6 +248,9 @@ class DwarfDebug : public DebugHandlerBa
   /// Whether to use the GNU TLS opcode (instead of the standard opcode).
   bool UseGNUTLSOpcode;
 
+  /// Whether to use DWARF 2 bitfields (instead of the DWARF 4 format).
+  bool UseDWARF2Bitfields;
+
   /// Whether to emit all linkage names, or just abstract subprograms.
   bool UseAllLinkageNames;
 
@@ -482,6 +485,10 @@ public:
   /// standard DW_OP_form_tls_address opcode
   bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
 
+  /// Returns whether to use the DWARF2 format for bitfields instyead of the
+  /// DWARF4 format.
+  bool useDWARF2Bitfields() const { return UseDWARF2Bitfields; }
+
   /// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger.
   ///
   /// Returns whether we are "tuning" for a given debugger.

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=269840&r1=269839&r2=269840&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Tue May 17 16:07:16 2016
@@ -1391,13 +1391,10 @@ void DwarfUnit::constructMemberDIE(DIE &
     uint64_t FieldSize = getBaseTypeSize(DD, DT);
     uint64_t OffsetInBytes;
 
-    // GDB does not fully support the DWARF 4 representation for bitfields.
-    bool EmitDWARF2Bitfields = (DD->getDwarfVersion() < 4) || (DD->tuneForGDB());
     bool IsBitfield = FieldSize && Size != FieldSize;
-
     if (IsBitfield) {
       // Handle bitfield, assume bytes are 8 bits.
-      if (EmitDWARF2Bitfields)
+      if (DD->useDWARF2Bitfields())
         addUInt(MemberDie, dwarf::DW_AT_byte_size, None, FieldSize/8);
       addUInt(MemberDie, dwarf::DW_AT_bit_size, None, Size);
 
@@ -1409,7 +1406,7 @@ void DwarfUnit::constructMemberDIE(DIE &
       // The byte offset of the field's aligned storage unit inside the struct.
       OffsetInBytes = (Offset - StartBitOffset) / 8;
 
-      if (EmitDWARF2Bitfields) {
+      if (DD->useDWARF2Bitfields()) {
         uint64_t HiMark = (Offset + FieldSize) & AlignMask;
         uint64_t FieldOffset = (HiMark - FieldSize);
         Offset -= FieldOffset;
@@ -1433,7 +1430,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 if (!IsBitfield || EmitDWARF2Bitfields)
+    } else if (!IsBitfield || DD->useDWARF2Bitfields())
       addUInt(MemberDie, dwarf::DW_AT_data_member_location, None,
               OffsetInBytes);
   }




More information about the llvm-commits mailing list