From 1f5735e21b717a41e35e3d8fb711e641af9a3614 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Tue, 19 Nov 2019 11:58:14 -0800 Subject: [PATCH] [DebugInfo] Describe size of spilled values in call site params A call site parameter description of a memory operand needs to unambiguously convey the size of the operand to prevent incorrect entry value evaluation. Thanks for David Stenberg for pointing this issue out! --- lib/CodeGen/TargetInstrInfo.cpp | 6 +++++- test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/TargetInstrInfo.cpp b/lib/CodeGen/TargetInstrInfo.cpp index 2b987dabd24..d7a02eb61a2 100644 --- a/lib/CodeGen/TargetInstrInfo.cpp +++ b/lib/CodeGen/TargetInstrInfo.cpp @@ -1150,7 +1150,11 @@ TargetInstrInfo::describeLoadedValue(const MachineInstr &MI) const { if (!TII->getMemOperandWithOffset(MI, BaseOp, Offset, TRI)) return None; - Expr = DIExpression::prepend(Expr, DIExpression::DerefAfter, Offset); + SmallVector Ops; + DIExpression::appendOffset(Ops, Offset); + Ops.push_back(dwarf::DW_OP_deref_size); + Ops.push_back(MMO->getSize()); + Expr = DIExpression::prependOpcodes(Expr, Ops); return ParamLoadedValue(*BaseOp, Expr); } diff --git a/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir b/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir index 26ea062c499..373b484850a 100644 --- a/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir +++ b/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir @@ -22,7 +22,7 @@ # CHECK-LABEL: DW_TAG_call_site_parameter # CHECK-NEXT: DW_AT_location (DW_OP_reg5 RDI) -# CHECK-NEXT: DW_AT_call_value (DW_OP_fbreg -44, DW_OP_deref) +# CHECK-NEXT: DW_AT_call_value (DW_OP_fbreg -44, DW_OP_deref_size 0x4) --- | ; ModuleID = 'spill.cc'