[SelectionDAG] Improve handling of dangling debug info
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Mon, 12 Mar 2018 18:02:39 +0000 (18:02 +0000)
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Mon, 12 Mar 2018 18:02:39 +0000 (18:02 +0000)
commita223f815dd8916462898b9bb302421359bcae957
treeddb5dd150d950cada8a3600ede7b257b280d4696
parent5d41cc19bd923f276ced246450e715e724349fa4
[SelectionDAG] Improve handling of dangling debug info

Summary:
1) Make sure to discard dangling debug info if the variable (or
variable fragment) is mapped to something new before we had a
chance to resolve the dangling debug info.

2) When resolving debug info, make sure to bump the associated
SDNodeOrder to ensure that the DBG_VALUE is emitted after the
instruction that defines the value used in the DBG_VALUE.
This will avoid a debug-use before def scenario as seen in
https://bugs.llvm.org/show_bug.cgi?id=36417.

The new test case, test/DebugInfo/X86/sdag-dangling-dbgvalue.ll,
show some other limitations in how dangling debug info is
handled in the SelectionDAG. Since we currently only support
having one dangling dbg.value per Value, we will end up dropping
debug info when there are more than one variable that is described
by the same "dangling value".

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: aprantl, eraman, llvm-commits, JDevlieghere

Tags: #debug-info

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

llvm-svn: 327303
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
llvm/test/DebugInfo/X86/dbg-value-inlined-parameter.ll
llvm/test/DebugInfo/X86/sdag-dangling-dbgvalue.ll [new file with mode: 0644]