HomePhabricator

[DebugInstrRef] Support recording of instruction reference substitutions

Authored by jmorse on Oct 15 2020, 3:20 AM.

Description

[DebugInstrRef] Support recording of instruction reference substitutions

Add a table recording "substitutions" between pairs of <instruction,
operand> numbers, from old pairs to new pairs. Post-isel optimizations are
able to record the outcome of an optimization in this way. For example, if
there were a divide instruction that generated the quotient and remainder,
and it were replaced by one that only generated the quotient:

$rax, $rcx = DIV-AND-REMAINDER $rdx, $rsi, debug-instr-num 1
DBG_INSTR_REF 1, 0
DBG_INSTR_REF 1, 1

Became:

$rax = DIV $rdx, $rsi, debug-instr-num 2
DBG_INSTR_REF 1, 0
DBG_INSTR_REF 1, 1

We could enter a substitution from <1, 0> to <2, 0>, and no substitution
for <1, 1> as it's no longer generated.

This approach means that if an instruction or value is deleted once we've
left SSA form, all variables that used the value implicitly become
"optimized out", something that isn't true of the current DBG_VALUE
approach.

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

Event Timeline

bkramer added inline comments.
/llvm/lib/CodeGen/MachineFunction.cpp
970

This sounds like it should've been New.getOperand(I);

jmorse added inline comments.Oct 15 2020, 6:03 AM
/llvm/lib/CodeGen/MachineFunction.cpp
970

Thanks for the heads-up, that's uncovered some unfortunate-ness, a revised version is in D85749 which I'll land in a couple of days.