[llvm] f753e5b - [LiveDebugValues] Allow EntryValue with OP_deref expressions

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 31 06:43:17 PST 2023


Author: Felipe de Azevedo Piovezan
Date: 2023-01-31T09:39:08-05:00
New Revision: f753e5be823925cf7c04cc51f519624415c995c4

URL: https://github.com/llvm/llvm-project/commit/f753e5be823925cf7c04cc51f519624415c995c4
DIFF: https://github.com/llvm/llvm-project/commit/f753e5be823925cf7c04cc51f519624415c995c4.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
    llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
    llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index ba417322d4f6f..26aca0345dfd4 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -601,7 +601,7 @@ class TransferTracker {
     if (Var.getInlinedAt())
       return false;
 
-    if (Expr->getNumElements() > 0)
+    if (Expr->getNumElements() > 0 && !Expr->isDeref())
       return false;
 
     return true;

diff  --git a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
index b78757b855f46..eec3de9ca33ae 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
@@ -2151,7 +2151,9 @@ bool VarLocBasedLDV::isEntryValueCandidate(
 
   // TODO: Add support for parameters that have a pre-existing debug expressions
   // (e.g. fragments).
-  if (MI.getDebugExpression()->getNumElements() > 0)
+  // A simple deref expression is equivalent to an indirect debug value.
+  const DIExpression *Expr = MI.getDebugExpression();
+  if (Expr->getNumElements() > 0 && !Expr->isDeref())
     return false;
 
   return true;

diff  --git a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
index a915a4826ed74..6b753bf11f160 100644
--- a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
+++ b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
@@ -1,4 +1,5 @@
 # RUN: llc -start-before=livedebugvalues -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
+# RUN: llc --force-instr-ref-livedebugvalues -start-before=livedebugvalues -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
 
 # Based on the following C++ code:
 # struct A { A(A &) {} };
@@ -7,11 +8,7 @@
 # struct D : C { D(B); };
 # D::D(B b) : C(b) {}
 
-# Reproducer for PR44275. Ideally we should get an entry value location list
-# entry for the reference parameter b, but we are currently not able to do that
-# due to limitations in the DWARF emission code, which puts restrictions on the
-# DIExpression. For now verify that we don't crash when trying to add such an
-# entry value.
+# Reproducer for PR44275.
 
 # CHECK: DW_AT_location
 # CHECK-NEXT: [{{0x[0-9a-f]+}}, {{0x[0-9a-f]+}}): DW_OP_reg5 RDI
@@ -19,8 +16,8 @@
 # CHECK-NEXT: DW_AT_name    ("this")
 
 # CHECK: DW_AT_location
-# CHECK-NEXT: [0x0000000000000000, 0x0000000000000004): DW_OP_breg4 RSI+0)
-# TODO: Here we should ideally get a location list entry using an entry value.
+# CHECK-NEXT: [0x0000000000000000, 0x0000000000000004): DW_OP_breg4 RSI+0
+# CHECK-NEXT: [0x0000000000000004, 0x000000000000000b): DW_OP_GNU_entry_value(DW_OP_reg4 RSI))
 # CHECK-NEXT: DW_AT_name    ("b")
 
 --- |


        


More information about the llvm-commits mailing list