[llvm] [DebugInfo] Use DW_OP_deref_size for DW_OP_LLVM_extract_bits (PR #97609)
Stephen Tozer via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 11 06:13:53 PDT 2024
================
@@ -552,9 +552,13 @@ bool DwarfExpression::addExpression(
unsigned SizeInBits = Op->getArg(1);
unsigned BitOffset = Op->getArg(0);
- // If we have a memory location then dereference to get the value
- if (isMemoryLocation())
- emitOp(dwarf::DW_OP_deref);
+ // If we have a memory location then dereference to get the value, though
+ // we have to make sure we don't dereference any bytes past the end of the
+ // object.
+ if (isMemoryLocation()) {
+ emitOp(dwarf::DW_OP_deref_size);
+ emitUnsigned(alignTo(BitOffset + SizeInBits, 8) / 8);
+ }
----------------
SLTozer wrote:
I think ideally we'd only use `DW_OP_deref_size` if `DW_OP_deref` will actually dereference too many bytes, but that's a minor point.
https://github.com/llvm/llvm-project/pull/97609
More information about the llvm-commits
mailing list