llvm-project/llvm/test/DebugInfo/MIR/InstrRef
Jeremy Morse b1b2c6ab66 [DebugInstrRef] Handle DBG_INSTR_REFs use-before-defs in LiveDebugValues
Deciding where to place debugging instructions when normal instructions
sink between blocks is difficult -- see PR44117. Dealing with this with
instruction-referencing variable locations is simple: we just tolerate
DBG_INSTR_REFs referring to values that haven't been computed yet. This
patch adds support into InstrRefBasedLDV to record when a variable value
appears in the middle of a block, and should have a DBG_VALUE added when it
appears (a debug use before def).

While described simply, this relies heavily on the value-propagation
algorithm in InstrRefBasedLDV. The implementation doesn't attempt to verify
the location of a value unless something non-trivial occurs to merge
variable values in vlocJoin. This means that a variable with a value that
has no location can retain it across all control flow (including loops).
It's only when another debug instruction specifies a different variable
value that we have to check, and find there's no location.

This property means that if a machine value is defined in a block dominated
by a DBG_INSTR_REF that refers to it, all the successor blocks can
automatically find a location for that value (if it's not clobbered). Thus
in a sense, InstrRefBasedLDV is already supporting and implementing
use-before-defs. This patch allows us to specify a variable location in the
block where it's defined.

When loading live-in variable locations, TransferTracker currently discards
those where it can't find a location for the variable value. However, we
can tell from the machine value number whether the value is defined in this
block. If it is, add it to a set of use-before-def records. Then, once the
relevant instruction has been processed, emit a DBG_VALUE immediately after
it.

Differential Revision: https://reviews.llvm.org/D85775
2020-10-23 16:33:23 +01:00
..
instr-ref-roundtrip.mir Add x86 REQUIRES to tests from 2c5f3d54c5 / D85746 2020-10-14 11:37:51 +01:00
lit.local.cfg Limit debug instr-referencing tests to X86 2020-10-22 15:04:19 +01:00
livedebugvalues_instrref_tolocs.mir [DebugInstrRef] Handle DBG_INSTR_REFs use-before-defs in LiveDebugValues 2020-10-23 16:33:23 +01:00
no-duplicates.mir Add x86 REQUIRES to tests from 2c5f3d54c5 / D85746 2020-10-14 11:37:51 +01:00
no-metainstrs.mir Add x86 REQUIRES to tests from 2c5f3d54c5 / D85746 2020-10-14 11:37:51 +01:00
substitusions-roundtrip.mir [DebugInstrRef] Support recording of instruction reference substitutions 2020-10-15 11:30:14 +01:00
survives-livedebugvars.mir [DebugInstrRef] Pass DBG_INSTR_REFs through register allocation 2020-10-22 15:51:22 +01:00
twoaddr-to-threeaddr-sub.mir Test I added requires X86 to be built. 2020-10-22 13:18:55 +01:00