[PATCH] D57702: [SelectionDAGBuilder] Add restrictions to EmitFuncArgumentDbgValue

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 4 11:42:21 PST 2019


bjope created this revision.
bjope added reviewers: jmorse, aprantl.
Herald added subscribers: fedor.sergeev, hiraditya, jyknight.
Herald added a project: LLVM.

This patch fixes PR40587.

When a dbg.value instrinsic is emitted to the DAG
by using EmitFuncArgumentDbgValue the resulting
DBG_VALUE is hoisted to the beginning of the entry
block. I think the idea is to be able to locate
a formal argument already from the start of the
function.
However, EmitFuncArgumentDbgValue only checked that
the value that was used to describe a variable was
originating from a function parameter, not that the
variable itself actually was an argument to the
function. So when for example assigning a local
variable "local" the value from an argument "a",
the DBG_VALUE instruction describing that "local"
had the value of "a" would be hoisted to the
beginning of the function, even if the scope for
"local" started somewhere else (or if "local"
had other values earlier in the function).

This patch adds some logic to EmitFuncArgumentDbgValue
to check that the variable being described actually
is an argument to the function. And that the dbg.value
being lowered already is in the entry block. Otherwise
we bail out, and the dbg.value will be handled as an
ordinary dbg.value (not as a "FuncArgumentDbgValue").

A tricky situation is when both the variable and
the value is related to function arguments, but not
the same argument. This is kind of hard to check.
Instead we verify that we do not describe the same
argument more than once as a "FuncArgumentDbgValue".
This solution works as long as opt has injected a
"first" dbg.value that corresponds to the formal
argument.

The Sparc/subreg.ll test case was updated to make
sure that %b is alive at the dbg.value, to still
make the test case valid.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D57702

Files:
  llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
  llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/test/DebugInfo/Sparc/subreg.ll
  llvm/test/DebugInfo/X86/dbg-value-funcarg.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57702.185110.patch
Type: text/x-patch
Size: 11732 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190204/ac6fb53e/attachment.bin>


More information about the llvm-commits mailing list