]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: improve debug locations for partially live in-params
authorThan McIntosh <thanm@google.com>
Mon, 10 May 2021 11:31:57 +0000 (07:31 -0400)
committerThan McIntosh <thanm@google.com>
Thu, 27 May 2021 18:49:23 +0000 (18:49 +0000)
commit8bf5bf51738a198902e03bbec7e6ff220f4cb002
tree863acc8ba80eb8e9a74aeb9472cdd609c27912c9
parent56af34f875f55485b4ebc521fe0c695dafb9bc23
cmd/compile: improve debug locations for partially live in-params

During DWARF debug location generation, as a preamble to the main data
flow analysis, examine the function entry block to look for in-params
arriving in registers that are partially or completely dead, and
insert new OpArg{Int,Float}Reg values for the dead or partially-dead
pieces. In addition, add entries to the f.NamedValues table for
incoming live register-resident params that don't already have
entries. This helps create better/saner DWARF location expressions for
params. Example:

  func foo(s string, used int, notused int) int {
      return len(s) + used
  }

When optimization is complete for this function, the parameter
"notused" is completely dead, meaning that there is no entry for it in
the f.NamedValues table (which then means we don't emit a DWARF
variable location expression for it in the function enty block). In
addition, since only the length field of "s" is used, there is no
DWARF location expression for the other component of "s", leading to
degraded DWARF.

There are still problems/issues with DWARF location generation, but
this does improve things with respect to being able to print the
values of incoming parameters when stopped in the debugger at the
entry point of a function (when optimization is enabled).

Updates #40724.

Change-Id: I5bb5253648942f9fd33b081fe1a5a36208e75785
Reviewed-on: https://go-review.googlesource.com/c/go/+/322631
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/ssa/debug.go