[LiveDebugValues] Omit entry values for DBG_VALUEs with pre-existing expressions
authorDavid Stenberg <david.stenberg@ericsson.com>
Fri, 13 Dec 2019 09:37:53 +0000 (10:37 +0100)
committerDavid Stenberg <david.stenberg@ericsson.com>
Fri, 13 Dec 2019 09:49:46 +0000 (10:49 +0100)
commit5c7cc6f83d1f3ea2016d94e1c9cc25f814d2671b
tree9c51a84d1e2961b0acfe61d7eb23f022f6bd23e3
parent6b8ff5e43b405d255259196b6a53a3b5671aa5c7
[LiveDebugValues] Omit entry values for DBG_VALUEs with pre-existing expressions

Summary:
This is a quickfix for PR44275. An assertion that checks that the
DIExpression is valid failed due to attempting to create an entry value
for an indirect parameter. This started appearing after D69028, as the
indirect parameter started being represented using an DW_OP_deref,
rather than with the DBG_VALUE's second operand, meaning that the
isIndirectDebugValue() check in LiveDebugValues did not exclude such
parameters. A DIExpression that has an entry value operation can
currently not have any other operation, leading to the failed isValid()
check.

This patch simply makes us stop considering emitting entry values
for such parameters. To support such cases I think we at least need
to do the following changes:

 * In DIExpression::isValid(): Remove the limitation that a
   DW_OP_LLVM_entry_value operation can be the only operation in a
   DIExpression.

 * In LiveDebugValues::emitEntryValues(): Create an entry value of size
   1, so that it only wraps the register operand, and not the whole
   pre-existing expression (the DW_OP_deref).

 * In LiveDebugValues::removeEntryValue(): Check that the new debug
   value has the same debug expression as the original, rather than
   checking that the debug expression is empty.

 * In DwarfExpression::addMachineRegExpression(): Modify the logic so
   that a DW_OP_reg* expression is emitted for the entry value.
   That is how GCC emits entry values for indirect parameters. That will
   currently not happen to due the DW_OP_deref causing the
   !HasComplexExpression to fail. The LocationKind needs to be changed
   also, rather than always emitting a DW_OP_stack_value for entry values.

There are probably more things I have missed, but that could hopefully
be a good starting point for emitting such entry values.

Reviewers: djtodoro, aprantl, jmorse, vsk

Reviewed By: aprantl, vsk

Subscribers: hiraditya, llvm-commits

Tags: #debug-info, #llvm

Differential Revision: https://reviews.llvm.org/D71416
llvm/lib/CodeGen/LiveDebugValues.cpp
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir [new file with mode: 0644]