[DebugInfo][InstrRef] Describe value sizes when spilt to stack
authorJeremy Morse <jeremy.morse@sony.com>
Wed, 27 Apr 2022 08:40:31 +0000 (09:40 +0100)
committerJeremy Morse <jeremy.morse@sony.com>
Wed, 27 Apr 2022 08:54:50 +0000 (09:54 +0100)
commita15b66e76d1ecff625a4bbb4a46ff83a43138f49
tree9fa88d232504a616028cea89f22b35449d3383d4
parent4a8c13a6f42e9c58af64421790509cc58208859b
[DebugInfo][InstrRef] Describe value sizes when spilt to stack

InstrRefBasedLDV can track and describe variable values that are spilt to
the stack -- however it does not current describe the size of the value on
the stack. This can cause uninitialized bytes to be read from the stack if
a small register is spilt for a larger variable, or theoretically on
big-endian machines if a large value on the stack is used for a small
variable.

Fix this by using DW_OP_deref_size to specify the amount of data to load
from the stack, if there's any possibility for ambiguity. There are a few
scenarios where this can be omitted (such as when using DW_OP_piece and a
non-DW_OP_stack_value location), see deref-spills-with-size.mir for an
explicit table of inputs flavours and output expressions.

Differential Revision: https://reviews.llvm.org/D123599
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
llvm/test/DebugInfo/MIR/InstrRef/deref-spills-with-size.mir [new file with mode: 0644]
llvm/test/DebugInfo/MIR/X86/live-debug-values-restore.mir
llvm/test/DebugInfo/MIR/X86/livedebugvalues_load_in_loop.mir