[llvm] 93b09a2 - [LiveDebugValues] Handle spills of indirect debug values correctly

Evgeny Leviant via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 8 04:07:53 PDT 2021


Author: Evgeny Leviant
Date: 2021-09-08T14:06:08+03:00
New Revision: 93b09a2a5d787beda3252a8c2662d19a44527881

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

LOG: [LiveDebugValues] Handle spills of indirect debug values correctly

When handling register spill for indirect debug value LiveDebugValues pass doesn't add
DW_OP_deref operator which may in some cases cause debugger to return value address, instead
of value while machine register holding that address is spilled.

Differential revision: https://reviews.llvm.org/D109142

Added: 
    

Modified: 
    llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
    llvm/test/DebugInfo/MIR/X86/live-debug-values-restore.mir

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
index 2566907c384c0..99a57b50fb3b1 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
@@ -556,9 +556,10 @@ class VarLocBasedLDV : public LDVImpl {
           unsigned Base = Loc.SpillLocation.SpillBase;
           auto *TRI = MF.getSubtarget().getRegisterInfo();
           if (MI.isNonListDebugValue()) {
-            DIExpr =
-                TRI->prependOffsetExpression(DIExpr, DIExpression::ApplyOffset,
-                                             Loc.SpillLocation.SpillOffset);
+            auto Deref = Indirect ? DIExpression::DerefAfter : 0;
+            DIExpr = TRI->prependOffsetExpression(
+                DIExpr, DIExpression::ApplyOffset | Deref,
+                Loc.SpillLocation.SpillOffset);
             Indirect = true;
           } else {
             SmallVector<uint64_t, 4> Ops;

diff  --git a/llvm/test/DebugInfo/MIR/X86/live-debug-values-restore.mir b/llvm/test/DebugInfo/MIR/X86/live-debug-values-restore.mir
index a897d644b6bb1..ef0d4d4797b80 100644
--- a/llvm/test/DebugInfo/MIR/X86/live-debug-values-restore.mir
+++ b/llvm/test/DebugInfo/MIR/X86/live-debug-values-restore.mir
@@ -641,7 +641,7 @@ body:             |
 # CHECK-LABEL: bb.0.entry:
 # CHECK:       DBG_VALUE $rdi, 0, ![[TVAR]], !DIExpression()
 # CHECK-LABEL: bb.1.if.then:
-# CHECK:       DBG_VALUE $rsp, 0, ![[TVAR]], !DIExpression(DW_OP_constu, 8, DW_OP_minus)
+# CHECK:       DBG_VALUE $rsp, 0, ![[TVAR]], !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref)
 # CHECK:       INLINEASM
 # CHECK:       DBG_VALUE ${{[a-zA-Z0-9]+}}, 0, ![[TVAR]], !DIExpression()
 # CHECK-LABEL: bb.2.if.end


        


More information about the llvm-commits mailing list