[llvm] r353928 - [DebugInfo] Stop changing labels for register-described parameter DBG_VALUEs
David Stenberg via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 13 01:34:08 PST 2019
Author: dstenb
Date: Wed Feb 13 01:34:07 2019
New Revision: 353928
URL: http://llvm.org/viewvc/llvm-project?rev=353928&view=rev
Log:
[DebugInfo] Stop changing labels for register-described parameter DBG_VALUEs
Summary:
This is a follow-up to D57510. This patch stops DebugHandlerBase from
changing the starting label for the first non-overlapping,
register-described parameter DBG_VALUEs to the beginning of the
function. That code did not consider what defined the registers, which
could result in the ranges for the debug values starting before their
defining instructions. We currently do not emit debug values for
constant values directly at the start of the function, so this code is
still useful for such values, but my intention is to remove the code
from DebugHandlerBase completely when we get there. One reason for
removing it is that the code violates the history map's ranges, which I
think can make it quite confusing when troubleshooting.
In D57510, PrologEpilogInserter was amended so that parameter DBG_VALUEs
now are kept at the start of the entry block, even after emission of
prologue code. That was done to reduce the degradation of debug
completeness from this patch. PR40638 is another example, where the
lexical-scope trimming that LDV does, in combination with scheduling,
results in instructions after the prologue being left without locations.
There might be other cases where the DBG_VALUEs are pushed further down,
for which the DebugHandlerBase code may be helpful, but as it now quite
often result in incorrect locations, even after the prologue, it seems
better to remove that code, and try to work our way up with accurate
locations.
In the long run we should maybe not aim to provide accurate locations
inside the prologue. Some single location descriptions, at least those
referring to stack values, generate inaccurate values inside the
epilogue, so we maybe should not aim to achieve accuracy for location
lists. However, it seems that we now emit line number programs that can
result in GDB and LLDB stopping inside the prologue when doing line
number stepping into functions. See PR40188 for more information.
A summary of some of the changed test cases is available in PR40188#c2.
Reviewers: aprantl, dblaikie, rnk, jmorse
Reviewed By: aprantl
Subscribers: jdoerfert, jholewinski, jvesely, javed.absar, llvm-commits
Tags: #debug-info, #llvm
Differential Revision: https://reviews.llvm.org/D57511
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
llvm/trunk/test/CodeGen/AMDGPU/llvm.dbg.value.ll
llvm/trunk/test/DebugInfo/AArch64/asan-stack-vars.mir
llvm/trunk/test/DebugInfo/ARM/partial-subreg.ll
llvm/trunk/test/DebugInfo/COFF/fp-stack.ll
llvm/trunk/test/DebugInfo/COFF/fpo-stack-protect.ll
llvm/trunk/test/DebugInfo/COFF/pieces.ll
llvm/trunk/test/DebugInfo/MIR/AArch64/clobber-sp.mir
llvm/trunk/test/DebugInfo/NVPTX/debug-info.ll
llvm/trunk/test/DebugInfo/X86/debug-loc-asan.mir
llvm/trunk/test/DebugInfo/X86/debug-loc-offset.mir
llvm/trunk/test/DebugInfo/X86/dw_op_minus_direct.ll
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp?rev=353928&r1=353927&r2=353928&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp Wed Feb 13 01:34:07 2019
@@ -215,24 +215,36 @@ void DebugHandlerBase::beginFunction(con
if (Ranges.empty())
continue;
- // The first mention of a function argument gets the CurrentFnBegin
- // label, so arguments are visible when breaking at function entry.
+ auto IsDescribedByReg = [](const MachineInstr *MI) {
+ return MI->getOperand(0).isReg() && MI->getOperand(0).getReg();
+ };
+
+ // The first mention of a function argument gets the CurrentFnBegin label,
+ // so arguments are visible when breaking at function entry.
+ //
+ // We do not change the label for values that are described by registers,
+ // as that could place them above their defining instructions. We should
+ // ideally not change the labels for constant debug values either, since
+ // doing that violates the ranges that are calculated in the history map.
+ // However, we currently do not emit debug values for constant arguments
+ // directly at the start of the function, so this code is still useful.
const DILocalVariable *DIVar = Ranges.front().first->getDebugVariable();
if (DIVar->isParameter() &&
getDISubprogram(DIVar->getScope())->describes(&MF->getFunction())) {
- LabelsBeforeInsn[Ranges.front().first] = Asm->getFunctionBegin();
+ if (!IsDescribedByReg(Ranges.front().first))
+ LabelsBeforeInsn[Ranges.front().first] = Asm->getFunctionBegin();
if (Ranges.front().first->getDebugExpression()->isFragment()) {
// Mark all non-overlapping initial fragments.
for (auto I = Ranges.begin(); I != Ranges.end(); ++I) {
const DIExpression *Fragment = I->first->getDebugExpression();
- if (std::all_of(Ranges.begin(), I,
+ if (std::any_of(Ranges.begin(), I,
[&](DbgValueHistoryMap::InstrRange Pred) {
- return !Fragment->fragmentsOverlap(
+ return Fragment->fragmentsOverlap(
Pred.first->getDebugExpression());
}))
- LabelsBeforeInsn[I->first] = Asm->getFunctionBegin();
- else
break;
+ if (!IsDescribedByReg(I->first))
+ LabelsBeforeInsn[I->first] = Asm->getFunctionBegin();
}
}
}
Modified: llvm/trunk/test/CodeGen/AMDGPU/llvm.dbg.value.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/llvm.dbg.value.ll?rev=353928&r1=353927&r2=353928&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/llvm.dbg.value.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/llvm.dbg.value.ll Wed Feb 13 01:34:07 2019
@@ -4,6 +4,7 @@
; GCN-LABEL: {{^}}test_debug_value:
; NOOPT: .loc 1 1 42 prologue_end ; /tmp/test_debug_value.cl:1:42
; NOOPT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0
+; NOOPT-NEXT: .Ltmp
; NOOPT-NEXT: ;DEBUG_VALUE: test_debug_value:globalptr_arg <- $sgpr4_sgpr5
; GCN: flat_store_dword
Modified: llvm/trunk/test/DebugInfo/AArch64/asan-stack-vars.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/AArch64/asan-stack-vars.mir?rev=353928&r1=353927&r2=353928&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/AArch64/asan-stack-vars.mir (original)
+++ llvm/trunk/test/DebugInfo/AArch64/asan-stack-vars.mir Wed Feb 13 01:34:07 2019
@@ -28,7 +28,7 @@
# CHECK: "_cmd"
# CHECK: DW_TAG_formal_parameter
# CHECK-NEXT: DW_AT_location
-# CHECK-NEXT: [0x{{0*}}, 0x{{.*}}):
+# CHECK-NEXT: [0x{{.*}}, 0x{{.*}}):
# CHECK-NOT: DW_AT_
# CHECK: [0x{{.*}}, [[FN_END]]):
# CHECK-NEXT: DW_AT_name {{.*}}"imageSize"
Modified: llvm/trunk/test/DebugInfo/ARM/partial-subreg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/ARM/partial-subreg.ll?rev=353928&r1=353927&r2=353928&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/ARM/partial-subreg.ll (original)
+++ llvm/trunk/test/DebugInfo/ARM/partial-subreg.ll Wed Feb 13 01:34:07 2019
@@ -9,6 +9,7 @@
; CHECK: DW_AT_name {{.*}}"subscript.get"
; CHECK: DW_TAG_formal_parameter
; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] ({{.*}}
+; CHECK-NEXT: [0x{{.*}}, 0x{{.*}}): DW_OP_regx D16, DW_OP_piece 0x8, DW_OP_regx D17, DW_OP_piece 0x4
; CHECK-NEXT: [0x{{.*}}, 0x{{.*}}): DW_OP_regx D16, DW_OP_piece 0x8, DW_OP_regx D17, DW_OP_piece 0x4, DW_OP_regx D16, DW_OP_piece 0x8, DW_OP_regx D17, DW_OP_piece 0x4
source_filename = "simd.ll"
Modified: llvm/trunk/test/DebugInfo/COFF/fp-stack.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/fp-stack.ll?rev=353928&r1=353927&r2=353928&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/fp-stack.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/fp-stack.ll Wed Feb 13 01:34:07 2019
@@ -10,14 +10,14 @@ entry:
ret double %sub
}
-; ASM: .cv_def_range Lfunc_begin0 Lfunc_end0, "A\021\200\000\000\000"
+; ASM: .cv_def_range Ltmp1 Lfunc_end0, "A\021\200\000\000\000"
; OBJ: DefRangeRegisterSym {
; OBJ: Register: ST0 (0x80)
; OBJ: MayHaveNoName: 0
; OBJ: LocalVariableAddrRange {
-; OBJ: OffsetStart: .text+0x0
+; OBJ: OffsetStart: .text+0x6
; OBJ: ISectStart: 0x0
-; OBJ: Range: 0x7
+; OBJ: Range: 0x1
; OBJ: }
; OBJ: }
Modified: llvm/trunk/test/DebugInfo/COFF/fpo-stack-protect.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/fpo-stack-protect.ll?rev=353928&r1=353927&r2=353928&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/fpo-stack-protect.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/fpo-stack-protect.ll Wed Feb 13 01:34:07 2019
@@ -30,7 +30,7 @@
; CHECK: addl $20, %esp
; CHECK: popl %esi
; CHECK: retl
-; CHECK: Ltmp2:
+; CHECK: Ltmp3:
; CHECK: .cv_fpo_endproc
; ModuleID = 't.c'
Modified: llvm/trunk/test/DebugInfo/COFF/pieces.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/pieces.ll?rev=353928&r1=353927&r2=353928&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/pieces.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/pieces.ll Wed Feb 13 01:34:07 2019
@@ -136,7 +136,7 @@
; ASM: .asciz "pad_right" # Function name
; ASM: .short 4414 # Record kind: S_LOCAL
; ASM: .asciz "o"
-; ASM: .cv_def_range .Lfunc_begin1 .Ltmp8, "C\021\021\000\000\000\004\000\000\000"
+; ASM: .cv_def_range .Ltmp8 .Ltmp8, "C\021\021\000\000\000\004\000\000\000"
; OBJ-LABEL: GlobalProcIdSym {
; OBJ: Kind: S_GPROC32_ID (0x1147)
@@ -159,7 +159,7 @@
; ASM: .asciz "pad_left" # Function name
; ASM: .short 4414 # Record kind: S_LOCAL
; ASM: .asciz "o"
-; ASM: .cv_def_range .Lfunc_begin2 .Ltmp10, "C\021\021\000\000\000\000\000\000\000"
+; ASM: .cv_def_range .Ltmp10 .Ltmp10, "C\021\021\000\000\000\000\000\000\000"
; OBJ-LABEL: GlobalProcIdSym {
; OBJ: Kind: S_GPROC32_ID (0x1147)
Modified: llvm/trunk/test/DebugInfo/MIR/AArch64/clobber-sp.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/MIR/AArch64/clobber-sp.mir?rev=353928&r1=353927&r2=353928&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/MIR/AArch64/clobber-sp.mir (original)
+++ llvm/trunk/test/DebugInfo/MIR/AArch64/clobber-sp.mir Wed Feb 13 01:34:07 2019
@@ -4,7 +4,7 @@
# CHECK: DW_TAG_formal_parameter
# CHECK: DW_TAG_formal_parameter
# CHECK-NEXT: DW_AT_location
-# CHECK-NEXT: [0x0000000000000000, 0x0000000000000014): DW_OP_reg1 W1
+# CHECK-NEXT: [0x0000000000000010, 0x0000000000000014): DW_OP_reg1 W1
# CHECK-NEXT: [0x0000000000000014, 0x0000000000000038): DW_OP_breg31 WSP+8
# CHECK-NEXT: DW_AT_name {{.*}}"y"
Modified: llvm/trunk/test/DebugInfo/NVPTX/debug-info.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/NVPTX/debug-info.ll?rev=353928&r1=353927&r2=353928&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/NVPTX/debug-info.ll (original)
+++ llvm/trunk/test/DebugInfo/NVPTX/debug-info.ll Wed Feb 13 01:34:07 2019
@@ -4781,8 +4781,8 @@ if.end:
; CHECK-NEXT: .b8 6 // DW_AT_call_line
; CHECK-NEXT: .b8 43 // Abbrev [43] 0x270e:0x22 DW_TAG_inlined_subroutine
; CHECK-NEXT: .b32 9791 // DW_AT_abstract_origin
-; CHECK-NEXT: .b64 Ltmp9 // DW_AT_low_pc
-; CHECK-NEXT: .b64 Ltmp10 // DW_AT_high_pc
+; CHECK-NEXT: .b64 Ltmp10 // DW_AT_low_pc
+; CHECK-NEXT: .b64 Ltmp11 // DW_AT_high_pc
; CHECK-NEXT: .b8 12 // DW_AT_call_file
; CHECK-NEXT: .b8 8 // DW_AT_call_line
; CHECK-NEXT: .b8 44 // Abbrev [44] 0x2725:0x5 DW_TAG_formal_parameter
Modified: llvm/trunk/test/DebugInfo/X86/debug-loc-asan.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/debug-loc-asan.mir?rev=353928&r1=353927&r2=353928&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/debug-loc-asan.mir (original)
+++ llvm/trunk/test/DebugInfo/X86/debug-loc-asan.mir Wed Feb 13 01:34:07 2019
@@ -27,7 +27,7 @@
# We expect two location ranges for the variable.
#
# First, its address is stored in %rcx:
-# CHECK: .quad .Lfunc_begin0-.Lfunc_begin0
+# CHECK: .quad .Ltmp0-.Lfunc_begin0
# CHECK-NEXT: .quad [[START_LABEL]]-.Lfunc_begin0
# CHECK: DW_OP_breg2
# DWARF: DW_TAG_formal_parameter
Modified: llvm/trunk/test/DebugInfo/X86/debug-loc-offset.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/debug-loc-offset.mir?rev=353928&r1=353927&r2=353928&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/debug-loc-offset.mir (original)
+++ llvm/trunk/test/DebugInfo/X86/debug-loc-offset.mir Wed Feb 13 01:34:07 2019
@@ -42,7 +42,7 @@
# CHECK: DW_TAG_formal_parameter
# CHECK-NOT: DW_TAG
# CHECK: DW_AT_location [DW_FORM_sec_offset] ({{.*}}
-# CHECK-NEXT: [0x00000020, 0x00000037): DW_OP_breg0 EAX+0, DW_OP_deref
+# CHECK-NEXT: [0x00000029, 0x00000037): DW_OP_breg0 EAX+0, DW_OP_deref
# CHECK-NEXT: [0x00000037, 0x00000063): DW_OP_breg5 EBP-8, DW_OP_deref, DW_OP_deref
# CHECK-NEXT: DW_AT_name [DW_FORM_strp]{{.*}}"a"
#
@@ -70,7 +70,7 @@
# CHECK-NEXT: [0x00000000, 0x0000000a): DW_OP_consts +0, DW_OP_stack_value
# CHECK-NEXT: [0x0000000a, 0x00000017): DW_OP_consts +1, DW_OP_stack_value
# CHECK: 0x00000022:
-# CHECK-NEXT: [0x00000000, 0x00000017): DW_OP_breg0 EAX+0, DW_OP_deref
+# CHECK-NEXT: [0x00000009, 0x00000017): DW_OP_breg0 EAX+0, DW_OP_deref
# CHECK-NEXT: [0x00000017, 0x00000043): DW_OP_breg5 EBP-8, DW_OP_deref, DW_OP_deref
--- |
target triple = "i386-unknown-linux-gnu"
Modified: llvm/trunk/test/DebugInfo/X86/dw_op_minus_direct.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dw_op_minus_direct.ll?rev=353928&r1=353927&r2=353928&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/dw_op_minus_direct.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/dw_op_minus_direct.ll Wed Feb 13 01:34:07 2019
@@ -17,7 +17,7 @@
; CHECK: .debug_loc contents:
; CHECK: 0x00000000:
-; CHECK-NEXT: [0x0000000000000000, 0x0000000000000004): DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_lit1, DW_OP_minus, DW_OP_stack_value
+; CHECK-NEXT: [0x0000000000000003, 0x0000000000000004): DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_lit1, DW_OP_minus, DW_OP_stack_value
; rax+0, constu 0xffffffff, and, constu 0x00000001, minus, stack-value
source_filename = "minus.c"
More information about the llvm-commits
mailing list