[clang] c6e2de6 - [LLVM] Use DWARFv4 bitfields when tuning for GDB
David Spickett via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 27 01:51:12 PDT 2022
Author: David Spickett
Date: 2022-10-27T08:51:07Z
New Revision: c6e2de60423ae98b1a7a175bab98c3c3c578b284
URL: https://github.com/llvm/llvm-project/commit/c6e2de60423ae98b1a7a175bab98c3c3c578b284
DIFF: https://github.com/llvm/llvm-project/commit/c6e2de60423ae98b1a7a175bab98c3c3c578b284.diff
LOG: [LLVM] Use DWARFv4 bitfields when tuning for GDB
GDB implemented data_bit_offset in https://sourceware.org/bugzilla/show_bug.cgi?id=12616
which has been present since GDB 8.0.
GCC started using it at GCC 11.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D135583
Added:
Modified:
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
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d73e58acbccd1..fa5154649095c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -624,6 +624,13 @@ proposals are standardized and available in all major engines.
DWARF Support in Clang
----------------------
+Previously when emitting DWARFv4 and tuning for GDB, Clang would use DWARF v2's
+``DW_AT_bit_offset`` and ``DW_AT_data_member_location``. Clang now uses DWARF v4'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
--------------------------------
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index dfdae3ca1dc2b..3918899d72229 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -177,7 +177,12 @@ Changes to the Metadata Info
Changes to the Debug Info
---------------------------------
-During this release ...
+Previously when emitting DWARF v4 and tuning for GDB, llc would use DWARF v2's
+``DW_AT_bit_offset`` and ``DW_AT_data_member_location``. llc now uses DWARF v4'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
---------------------------------
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 54af144299077..d3e2befbd23e4 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -428,8 +428,7 @@ DwarfDebug::DwarfDebug(AsmPrinter *A)
// 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
diff --git a/llvm/test/DebugInfo/X86/bitfields-dwarf4.ll b/llvm/test/DebugInfo/X86/bitfields-dwarf4.ll
index 018653751961a..23ddee459abbc 100644
--- a/llvm/test/DebugInfo/X86/bitfields-dwarf4.ll
+++ b/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>
diff --git a/llvm/test/DebugInfo/X86/packed_bitfields.ll b/llvm/test/DebugInfo/X86/packed_bitfields.ll
index c36df72439ebb..0e541f09d2270 100644
--- a/llvm/test/DebugInfo/X86/packed_bitfields.ll
+++ b/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 {
More information about the cfe-commits
mailing list