Page MenuHomePhabricator

[DebugInfo][InstrRef][4/4] Support using DBG_INSTR_REF through all* backend passes
Needs ReviewPublic

Authored by jmorse on Oct 6 2020, 6:45 AM.

Details

Reviewers
None
Group Reviewers
debug-info
Summary

This patch does some cleanup to ensure that a clang stage2 build succeeds when using only DBG_INSTR_REF variable locations (plus the exceptions noted in the previous patch). There are still passes that will need updating, however most variable locations now survive most passes.

The most significant change is in LiveDebugVariables: because there are no DBG_VALUEs referring to virtual registers (which is now asserted), we can get away with just unlinking debug instructions from blocks, then linking them back in after regalloc finishes. This avoids the interval splitting and other operations. Debug instructions are stored with their slot and block, then re-inserted in the order they were removed.

Other passes need a tweak or two to correctly identify debug instructions now that DBG_PHIs can be generated during SelectionDAG.

Parameter variable locations are emitted by directly constructing a DBG_VALUE to be inserted later during SelectionDAGBuilder; I've added a helper lambda there to emit a DBG_INSTR_REF when we're using instruction referencing.

X86InstrInfo.cpp needs to un-set an instruction number: X86 usually creates subtract instructions instead of CMPs, then mutates them to be CMPs later on if no-one uses the result. That causes any debug users referring to the subs register def to now refer to a register use; which is an erronous behaviour.

Finally, I've deleted a bunch of DBG_VALUE %vreg's from the tests for other instruction referencing behaviour: they shouldn't be generated by SelectionDAG now, and shouldn't be in test cases for instruction referencing. None of them affect the tested behaviours, those all involve DBG_INSTR_REFs.

Diff Detail

Event Timeline

jmorse created this revision.Oct 6 2020, 6:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2020, 6:45 AM
djtodoro added inline comments.
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
5393

MIB.addReg(Reg, RegState::Debug);