[PATCH] D142654: [LiveDebugValues] Allow EntryValue with OP_deref expressions

Felipe de Azevedo Piovezan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 30 14:30:48 PST 2023


fdeazeve updated this revision to Diff 493422.
fdeazeve added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142654/new/

https://reviews.llvm.org/D142654

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


Index: llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
===================================================================
--- llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
+++ 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")
 
 --- |
Index: llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
===================================================================
--- llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
+++ llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
@@ -2151,7 +2151,9 @@
 
   // 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;
Index: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
===================================================================
--- llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -601,7 +601,7 @@
     if (Var.getInlinedAt())
       return false;
 
-    if (Expr->getNumElements() > 0)
+    if (Expr->getNumElements() > 0 && !Expr->isDeref())
       return false;
 
     return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142654.493422.patch
Type: text/x-patch
Size: 2639 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230130/4e04627f/attachment.bin>


More information about the llvm-commits mailing list