[llvm] dd7297e - DebugInfo: Fix bug in addr+offset exprloc to use DWARFv5 addrx op instead of DWARFv4 GNU extension
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 27 18:40:14 PST 2021
Author: David Blaikie
Date: 2021-01-27T18:39:44-08:00
New Revision: dd7297e1bffeaea533a2353489ead3b388ceed14
URL: https://github.com/llvm/llvm-project/commit/dd7297e1bffeaea533a2353489ead3b388ceed14
DIFF: https://github.com/llvm/llvm-project/commit/dd7297e1bffeaea533a2353489ead3b388ceed14.diff
LOG: DebugInfo: Fix bug in addr+offset exprloc to use DWARFv5 addrx op instead of DWARFv4 GNU extension
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/test/DebugInfo/X86/ranges_always.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 6267c3e5a828..bc45a78daf7d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -319,22 +319,18 @@ void DwarfUnit::addPoolOpAddress(DIEValueList &Die, const MCSymbol *Label) {
const MCSymbol *Base = nullptr;
if (Label->isInSection() && DD->useAddrOffsetExpressions())
Base = DD->getSectionLabel(&Label->getSection());
- if (!Base) {
- uint32_t Index = DD->getAddressPool().getIndex(Label);
- if (DD->getDwarfVersion() >= 5) {
- addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addrx);
- addUInt(Die, dwarf::DW_FORM_addrx, Index);
- } else {
- addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_addr_index);
- addUInt(Die, dwarf::DW_FORM_GNU_addr_index, Index);
- }
- return;
+
+ uint32_t Index = DD->getAddressPool().getIndex(Base ? Base : Label);
+
+ if (DD->getDwarfVersion() >= 5) {
+ addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addrx);
+ addUInt(Die, dwarf::DW_FORM_addrx, Index);
+ } else {
+ addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_addr_index);
+ addUInt(Die, dwarf::DW_FORM_GNU_addr_index, Index);
}
- addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_addr_index);
- addUInt(Die, dwarf::DW_FORM_GNU_addr_index,
- DD->getAddressPool().getIndex(Base));
- if (Base != Label) {
+ if (Base && Base != Label) {
addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_const4u);
addLabelDelta(Die, (dwarf::Attribute)0, Label, Base);
addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
diff --git a/llvm/test/DebugInfo/X86/ranges_always.ll b/llvm/test/DebugInfo/X86/ranges_always.ll
index 9d1498cb0390..4a60e9d8418e 100644
--- a/llvm/test/DebugInfo/X86/ranges_always.ll
+++ b/llvm/test/DebugInfo/X86/ranges_always.ll
@@ -51,20 +51,20 @@
; CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000000000 ".text")
; CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000010)
; CHECK: DW_TAG_inlined_subroutine
-; EXPR: DW_AT_low_pc [DW_FORM_exprloc] (DW_OP_GNU_addr_index 0x0, DW_OP_const4u 0x9, DW_OP_plus)
+; EXPR: DW_AT_low_pc [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0x9, DW_OP_plus)
; EXPR: DW_AT_high_pc [DW_FORM_data4] (0x00000005)
; RNG: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = [[INL_RANGE:.*]]
; CHECK: DW_TAG_call_site
; RNG: DW_AT_call_return_pc [DW_FORM_addrx] (indexed (00000001) address = 0x0000000000000009 ".text")
-; EXPR: DW_AT_call_return_pc [DW_FORM_exprloc] (DW_OP_GNU_addr_index 0x0, DW_OP_const4u 0x9, DW_OP_plus)
+; EXPR: DW_AT_call_return_pc [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0x9, DW_OP_plus)
; CHECK: DW_TAG_call_site
; RNG: DW_AT_call_return_pc [DW_FORM_addrx] (indexed (00000002) address = 0x000000000000000e ".text")
-; EXPR: DW_AT_call_return_pc [DW_FORM_exprloc] (DW_OP_GNU_addr_index 0x0, DW_OP_const4u 0xe, DW_OP_plus)
+; EXPR: DW_AT_call_return_pc [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0xe, DW_OP_plus)
; CHECK: NULL
; CHECK: DW_TAG_subprogram
; CHECK: DW_AT_name {{.*}} "f1"
; CHECK: DW_TAG_subprogram
-; EXPR: DW_AT_low_pc [DW_FORM_exprloc] (DW_OP_GNU_addr_index 0x0, DW_OP_const4u 0x20, DW_OP_plus)
+; EXPR: DW_AT_low_pc [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0x20, DW_OP_plus)
; EXPR: DW_AT_high_pc [DW_FORM_data4] (0x00000006)
; RNG: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = [[F5_RANGE:.*]]
; CHECK: DW_TAG_subprogram
More information about the llvm-commits
mailing list