[DebugInfo][DAG] Avoid re-ordering of DBG_VALUEs
authorJeremy Morse <jeremy.morse.llvm@gmail.com>
Mon, 28 Jan 2019 12:08:31 +0000 (12:08 +0000)
committerJeremy Morse <jeremy.morse.llvm@gmail.com>
Mon, 28 Jan 2019 12:08:31 +0000 (12:08 +0000)
commit8ebffb4b82ef5b4ae230fc3893e56314c3dede95
treeaec98f9eacbb713c7e544d3a81d6c048070d8d0d
parentc61eaa5920161789f273256a718b9d47a97d00cd
[DebugInfo][DAG] Avoid re-ordering of DBG_VALUEs

This patch improves the placement of DBG_VALUEs when by SelectionDAG, which
as documented in PR40427 can go very wrong. At the core of this is
ProcessSourceNode, which assumes the last instruction in a BB is the start
of the last processed IR instruction, which isn't always true.

Instead, use a helper function to call InstrEmitter::EmitNode, that records
before-and-after iterators and determines the first of any new instruction
created during emission. This is passed to ProcessSourceNode, which can
then make more elightened decisions about ordering for DBG_VALUE placement.

Differential revision: https://reviews.llvm.org/D57163

llvm-svn: 352350
llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
llvm/test/DebugInfo/NVPTX/debug-info.ll
llvm/test/DebugInfo/X86/pr40427.ll [new file with mode: 0644]
llvm/test/DebugInfo/X86/sdag-dbgvalue-phi-use-2.ll