diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2025-01-23 10:47:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-23 10:47:15 +0000 |
commit | cb714e74cc0efd5bfdb3e5e80978239425bd83d4 (patch) | |
tree | c43d26d0919e1125a53e1b8c074d1a10d59ba773 /llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | |
parent | 2e6cc79f816d942ab09d6a310cd925c1da148aa9 (diff) | |
download | llvm-cb714e74cc0efd5bfdb3e5e80978239425bd83d4.zip llvm-cb714e74cc0efd5bfdb3e5e80978239425bd83d4.tar.gz llvm-cb714e74cc0efd5bfdb3e5e80978239425bd83d4.tar.bz2 |
[DebugInfo][InstrRef] Avoid producing broken DW_OP_deref_sizes (#123967)
We use variable locations such as DBG_VALUE $xmm0 as shorthand to refer
to "the low lane of $xmm0", and this is reflected in how DWARF is
interpreted too. However InstrRefBasedLDV tries to be smart and
interprets such a DBG_VALUE as a 128-bit reference. We then issue a
DW_OP_deref_size of 128 bits to the stack, which isn't permitted by
DWARF (it's larger than a pointer).
Solve this for now by not using DW_OP_deref_size if it would be illegal.
Instead we'll use DW_OP_deref, and the consumer will load the variable
type from the stack, which should be correct.
There's still a risk of imprecision when LLVM decides to use smaller or
larger value types than the source-variable type, which manifests as
too-little or too-much memory being read from the stack. However we
can't solve that without putting more type information in debug-info.
fixes #64093
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp index 012bc37..2510b77 100644 --- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp @@ -1290,6 +1290,27 @@ MLocTracker::emitLoc(const SmallVectorImpl<ResolvedDbgOp> &DbgOps, } } + // https://github.com/llvm/llvm-project/issues/64093 + // in particular #issuecomment-2531264124. We use variable locations + // such as DBG_VALUE $xmm0 as shorthand to refer to "the low lane of + // $xmm0", and this is reflected in how DWARF is interpreted too. + // However InstrRefBasedLDV tries to be smart and interprets such a + // DBG_VALUE as a 128-bit reference. We then issue a DW_OP_deref_size + // of 128 bits to the stack, which isn't permitted by DWARF (it's + // larger than a pointer). + // + // Solve this for now by not using DW_OP_deref_size if it would be + // illegal. Instead we'll use DW_OP_deref, and the consumer will load + // the variable type from the stack, which should be correct. + // + // There's still a risk of imprecision when LLVM decides to use + // smaller or larger value types than the source-variable type, which + // manifests as too-little or too-much memory being read from the stack. + // However we can't solve that without putting more type information in + // debug-info. + if (ValueSizeInBits > MF.getTarget().getPointerSizeInBits(0)) + UseDerefSize = false; + SmallVector<uint64_t, 5> OffsetOps; TRI.getOffsetOpcodes(Spill.SpillOffset, OffsetOps); bool StackValue = false; |