]> granicus.if.org Git - llvm/commit
Improve line debug info when translating a CaseBlock to SDNodes.
authorAdrian Prantl <aprantl@apple.com>
Thu, 17 Aug 2017 16:57:13 +0000 (16:57 +0000)
committerAdrian Prantl <aprantl@apple.com>
Thu, 17 Aug 2017 16:57:13 +0000 (16:57 +0000)
commitcb8c418e34152ca4cf3067f136796fe158a6019d
tree626c089e882a37ec9877904818d89acf038121ac
parente16912e0d0fc3e004565010d6bcf51112bd89227
Improve line debug info when translating a CaseBlock to SDNodes.

The SelectionDAGBuilder translates various conditional branches into
CaseBlocks which are then translated into SDNodes. If a conditional
branch results in multiple CaseBlocks only the first CaseBlock is
translated into SDNodes immediately, the rest of the CaseBlocks are
put in a queue and processed when all LLVM IR instructions in the
basic block have been processed.

When a CaseBlock is transformed into SDNodes the SelectionDAGBuilder
is queried for the current LLVM IR instruction and the resulting
SDNodes are annotated with the debug info of the current
instruction (if it exists and has debug metadata).

When the deferred CaseBlocks are processed, the SelectionDAGBuilder
does not have a current LLVM IR instruction, and the resulting SDNodes
will not have any debuginfo. As DwarfDebug::beginInstruction() outputs
a .loc directive for the first instruction in a labeled
block (typically the case for something coming from a CaseBlock) this
tends to produce a line-0 directive.

This patch changes the handling of CaseBlocks to store the current
instruction's debug info into the CaseBlock when it is created (and the
SelectionDAGBuilder knows the current instruction) and to always use
the stored debug info when translating a CaseBlock to SDNodes.

Patch by Frej Drejhammar!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311097 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
test/CodeGen/X86/debugloc-no-line-0.ll [new file with mode: 0644]