[DebugInfo] Use zero linenos for debug intrinsics when promoting dbg.declare
authorJeremy Morse <jeremy.morse.llvm@gmail.com>
Fri, 10 May 2019 10:03:41 +0000 (10:03 +0000)
committerJeremy Morse <jeremy.morse.llvm@gmail.com>
Fri, 10 May 2019 10:03:41 +0000 (10:03 +0000)
commita2b780b731969f63e2e9e9ea76e43cf86d47a5d3
treeca9f88b2ac5cc90e7aa22f322f46e916cb7c9556
parente357ca82311ff40a0be1a80c8513f37aff93a0a2
[DebugInfo] Use zero linenos for debug intrinsics when promoting dbg.declare

In certain circumstances, optimizations pick line numbers from debug
intrinsic instructions as the new location for altered instructions. This
is problematic because the line number of a debugging intrinsic is
meaningless (it doesn't produce any machine instruction), only the scope
information is valid. The result can be the line number of a variable
declaration "leaking" into real code from debugging intrinsics, making the
line table un-necessarily jumpy, and potentially different with / without
variable locations.

Fix this by using zero line numbers when promoting dbg.declare intrinsics
into dbg.values: this is safe for debug intrinsics as their line numbers
are meaningless, and reduces the scope for damage / misleading stepping
when optimizations pick locations from the wrong place.

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

llvm-svn: 360415
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/DebugInfo/Generic/dbg-value-lower-linenos.ll [new file with mode: 0644]
llvm/test/DebugInfo/X86/formal_parameter.ll