[PATCH] D88898: [DebugInfo][InstrRef][4/4] Support using DBG_INSTR_REF through all* backend passes

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 6 06:45:58 PDT 2020


jmorse created this revision.
jmorse added a reviewer: debug-info.
Herald added subscribers: llvm-commits, pengfei, hiraditya, qcolombet, MatzeB.
Herald added a project: LLVM.
jmorse requested review of this revision.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88898

Files:
  llvm/lib/CodeGen/LiveDebugVariables.cpp
  llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/test/DebugInfo/MIR/InstrRef/phi-coalesce-subreg.mir
  llvm/test/DebugInfo/MIR/InstrRef/phi-coalescing.mir
  llvm/test/DebugInfo/MIR/InstrRef/phi-regallocd-to-stack.mir
  llvm/test/DebugInfo/MIR/InstrRef/phi-through-regalloc.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88898.296442.patch
Type: text/x-patch
Size: 22356 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201006/18918ed7/attachment.bin>


More information about the llvm-commits mailing list