[PATCH] D135583: [LLVM] Use DWARFv4 bitfields when tuning for GDB

David Spickett via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 26 03:12:43 PDT 2022


DavidSpickett updated this revision to Diff 470766.
DavidSpickett added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Test that linux DWARFv4 uses data_bit_offset and that adding GDB tuning does not change that.
- Add release notes for clang and llvm.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135583/new/

https://reviews.llvm.org/D135583

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/test/DebugInfo/X86/bitfields-dwarf4.ll
  llvm/test/DebugInfo/X86/packed_bitfields.ll


Index: llvm/test/DebugInfo/X86/packed_bitfields.ll
===================================================================
--- llvm/test/DebugInfo/X86/packed_bitfields.ll
+++ llvm/test/DebugInfo/X86/packed_bitfields.ll
@@ -1,7 +1,5 @@
 ; RUN: llc -dwarf-version=2 -mtriple x86_64-apple-macosx -O0 -filetype=obj -o %t_2_le.o %s
 ; RUN: llvm-dwarfdump -v -debug-info %t_2_le.o | FileCheck %s
-; RUN: llc -dwarf-version=4 -debugger-tune=gdb -mtriple x86_64-apple-macosx -O0 -filetype=obj -o %t_4_le.o %s
-; RUN: llvm-dwarfdump -v -debug-info %t_4_le.o | FileCheck %s
 
 ; Produced at -O0 from:
 ; struct {
Index: llvm/test/DebugInfo/X86/bitfields-dwarf4.ll
===================================================================
--- llvm/test/DebugInfo/X86/bitfields-dwarf4.ll
+++ llvm/test/DebugInfo/X86/bitfields-dwarf4.ll
@@ -1,8 +1,9 @@
 ; RUN: llc -mtriple x86_64-apple-macosx -O0 -filetype=obj -o - %s \
 ; RUN: | llvm-dwarfdump -v -debug-info - | FileCheck %s
 ; RUN: llc -mtriple x86_64-gnu-linux -O0 -filetype=obj -o - %s \
-; RUN: | llvm-dwarfdump -v -debug-info - | FileCheck %s --check-prefix=LINUX
-; LINUX-NOT: DW_AT_data_bit_offset
+; RUN: | llvm-dwarfdump -v -debug-info - | FileCheck %s
+; RUN: llc -mtriple x86_64-gnu-linux -O0 -debugger-tune=gdb -filetype=obj -o - %s \
+; RUN: | llvm-dwarfdump -v -debug-info - | FileCheck %s
 ;
 ; Generated from:
 ;   #include <stdint.h>
Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -428,8 +428,7 @@
   // 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();
+  UseDWARF2Bitfields = (DwarfVersion < 4);
 
   // The DWARF v5 string offsets table has - possibly shared - contributions
   // from each compile and type unit each preceded by a header. The string
Index: llvm/docs/ReleaseNotes.rst
===================================================================
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -177,7 +177,12 @@
 Changes to the Debug Info
 ---------------------------------
 
-During this release ...
+Previously when emitting DWARFv4 and tuning for GDB, llc would use DWARFv2's
+``DW_AT_bit_offset`` and ``DW_AT_data_member_location``. llc now uses DWARFv4's
+``DW_AT_data_bit_offset`` regardless of tuning.
+
+Support for ``DW_AT_data_bit_offset`` was added in GDB 8.0. For earlier versions,
+you can use llc's ``-dwarf-version=3`` option to emit compatible DWARF.
 
 Changes to the LLVM tools
 ---------------------------------
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -616,6 +616,13 @@
 DWARF Support in Clang
 ----------------------
 
+Previously when emitting DWARFv4 and tuning for GDB, Clang would use DWARFv2's
+``DW_AT_bit_offset`` and ``DW_AT_data_member_location``. Clang now uses DWARFv4's
+``DW_AT_data_bit_offset`` regardless of tuning.
+
+Support for ``DW_AT_data_bit_offset`` was added in GDB 8.0. For earlier versions,
+you can use the ``-gdwarf-3`` option to emit compatible DWARF.
+
 Arm and AArch64 Support in Clang
 --------------------------------
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135583.470766.patch
Type: text/x-patch
Size: 3441 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221026/a78a26bc/attachment.bin>


More information about the cfe-commits mailing list