Skip to content

Commit 659de1c

Browse files
[LiveDebugValues] Allow EntryValue with OP_deref expressions
With D68945, more DBG_VALUEs were created without the indirect operand, instead relying on OP_deref to accomplish the same effect. At the time, however, we were not able to handle arbitrary expressions in combination with OP_LLVM_entry_value, so D71416 prevented the use of such operation in the presence of expressions. As per the comment in DIExpression::isValid, "we support only entry values of a simple register location." As such, a simple deref operation should be supported. In fact, D80345 added support for indirect DBG_VALUEs. Taken the patches above into consideration, this commit relaxes the restrictions on which expressions are allowed for entry value candidates: the expression must be either empty or a single dereference operator. This patch is useful for D141381, which adds support for storing the address of ABI-indirect parameters on the stack. Depends on D142160 Differential Revision: https://reviews.llvm.org/D142654 (cherry picked from commit f753e5b)
1 parent a9a7013 commit 659de1c

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ class TransferTracker {
587587
if (Var.getInlinedAt())
588588
return false;
589589

590-
if (Expr->getNumElements() > 0)
590+
if (Expr->getNumElements() > 0 && !Expr->isDeref())
591591
return false;
592592

593593
return true;

llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2050,7 +2050,9 @@ bool VarLocBasedLDV::isEntryValueCandidate(
20502050

20512051
// TODO: Add support for parameters that have a pre-existing debug expressions
20522052
// (e.g. fragments).
2053-
if (MI.getDebugExpression()->getNumElements() > 0)
2053+
// A simple deref expression is equivalent to an indirect debug value.
2054+
const DIExpression *Expr = MI.getDebugExpression();
2055+
if (Expr->getNumElements() > 0 && !Expr->isDeref())
20542056
return false;
20552057

20562058
return true;

llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: llc -start-before=livedebugvalues -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
2+
# RUN: llc --force-instr-ref-livedebugvalues -start-before=livedebugvalues -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
23

34
# Based on the following C++ code:
45
# struct A { A(A &) {} };
@@ -7,20 +8,16 @@
78
# struct D : C { D(B); };
89
# D::D(B b) : C(b) {}
910

10-
# Reproducer for PR44275. Ideally we should get an entry value location list
11-
# entry for the reference parameter b, but we are currently not able to do that
12-
# due to limitations in the DWARF emission code, which puts restrictions on the
13-
# DIExpression. For now verify that we don't crash when trying to add such an
14-
# entry value.
11+
# Reproducer for PR44275.
1512

1613
# CHECK: DW_AT_location
1714
# CHECK-NEXT: [{{0x[0-9a-f]+}}, {{0x[0-9a-f]+}}): DW_OP_reg5 RDI
1815
# CHECK-NEXT: [{{0x[0-9a-f]+}}, {{0x[0-9a-f]+}}): DW_OP_GNU_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value)
1916
# CHECK-NEXT: DW_AT_name ("this")
2017

2118
# CHECK: DW_AT_location
22-
# CHECK-NEXT: [0x0000000000000000, 0x0000000000000004): DW_OP_breg4 RSI+0)
23-
# TODO: Here we should ideally get a location list entry using an entry value.
19+
# CHECK-NEXT: [0x0000000000000000, 0x0000000000000004): DW_OP_breg4 RSI+0
20+
# CHECK-NEXT: [0x0000000000000004, 0x000000000000000b): DW_OP_GNU_entry_value(DW_OP_reg4 RSI))
2421
# CHECK-NEXT: DW_AT_name ("b")
2522

2623
--- |

0 commit comments

Comments
 (0)