]> granicus.if.org Git - llvm/commit
[DebugInfo] Add a DW_OP_LLVM_entry_value operation
authorDavid Stenberg <david.stenberg@ericsson.com>
Tue, 15 Oct 2019 11:31:21 +0000 (11:31 +0000)
committerDavid Stenberg <david.stenberg@ericsson.com>
Tue, 15 Oct 2019 11:31:21 +0000 (11:31 +0000)
commit633cd24e8784d18ad44efde67c1c8bf7297aa5d9
tree99f94ed88563f2fe85c0fbc2a12e16398f48b779
parent3ae2d8fa736a2e279b6cf55d5ab2fdcbe4d86fb6
[DebugInfo] Add a DW_OP_LLVM_entry_value operation

Summary:
Internally in LLVM's metadata we use DW_OP_entry_value operations with
the same semantics as DWARF; that is, its operand specifies the number
of bytes that the entry value covers.

At the time of emitting entry values we don't know the emitted size of
the DWARF expression that the entry value will cover. Currently the size
is hardcoded to 1 in DIExpression, and other values causes the verifier
to fail. As the size is 1, that effectively means that we can only have
valid entry values for registers that can be encoded in one byte, which
are the registers with DWARF numbers 0 to 31 (as they can be encoded as
single-byte DW_OP_reg0..DW_OP_reg31 rather than a multi-byte
DW_OP_regx). It is a bit confusing, but it seems like llvm-dwarfdump
will print an operation "correctly", even if the byte size is less than
that, which may make it seem that we emit correct DWARF for registers
with DWARF numbers > 31. If you instead use readelf for such cases, it
will interpret the number of specified bytes as a DWARF expression. This
seems like a limitation in llvm-dwarfdump.

As suggested in D66746, a way forward would be to add an internal
variant of DW_OP_entry_value, DW_OP_LLVM_entry_value, whose operand
instead specifies the number of operations that the entry value covers,
and we then translate that into the byte size at the time of emission.

In this patch that internal operation is added. This patch keeps the
limitation that a entry value can only be applied to simple register
locations, but it will fix the issue with the size operand being
incorrect for DWARF numbers > 31.

Reviewers: aprantl, vsk, djtodoro, NikolaPrica

Reviewed By: aprantl

Subscribers: jyknight, fedor.sergeev, hiraditya, llvm-commits

Tags: #debug-info, #llvm

Differential Revision: https://reviews.llvm.org/D67492

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374881 91177308-0d34-0410-b5e6-96231b3b80d8
23 files changed:
docs/LangRef.rst
include/llvm/BinaryFormat/Dwarf.h
include/llvm/CodeGen/MachineInstr.h
include/llvm/IR/DebugInfoMetadata.h
lib/BinaryFormat/Dwarf.cpp
lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfExpression.cpp
lib/CodeGen/AsmPrinter/DwarfExpression.h
lib/IR/DebugInfoMetadata.cpp
lib/IR/Verifier.cpp
test/DebugInfo/ARM/entry-value-multi-byte-expr.ll [new file with mode: 0644]
test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
test/DebugInfo/MIR/X86/avoid-single-entry-value-location.mir
test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
test/DebugInfo/MIR/X86/multiple-param-dbg-value-entry.mir
test/DebugInfo/Sparc/entry-value-complex-reg-expr.ll [new file with mode: 0644]
test/Verifier/diexpression-dwarf-entry-value.ll [new file with mode: 0644]
test/Verifier/diexpression-entry-value-llvm-ir.ll [new file with mode: 0644]
test/Verifier/diexpression-entry-value.ll
test/Verifier/diexpression-valid-entry-value.ll