]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix DWARF inline debug issue with dead local vars
authorThan McIntosh <thanm@google.com>
Wed, 23 May 2018 19:31:52 +0000 (15:31 -0400)
committerThan McIntosh <thanm@google.com>
Fri, 25 May 2018 19:37:35 +0000 (19:37 +0000)
commit1ba26a33ceef7600e9801bbccf529b1112013c1a
treeb9c8ca39c3e56c9f94a868cfe72ae4f68a81782b
parent88756931d0a6e23aeaf61caa6a7363ac04be2063
cmd/compile: fix DWARF inline debug issue with dead local vars

Fix a problem in DWARF inline debug generation relating to handling of
statically unreachable local variables. For a function such as:

    const always = true

    func HasDeadLocal() int {
      if always {
        return 9
      }
      x := new(Something)
      ...
      return x.y
    }

the variable "x" is placed onto the Dcl list for the function during
parsing, but the actual declaration node is deleted later on when
gc.Main invokes "deadcode". Later in the compile the DWARF code emits
an abstract function with "x" (since "x" was on the Dcl list at the
point of the inline), but the export data emitted does not contain
"x". This then creates clashing/inconsistant DWARF abstract function
DIEs later on if HasDeadLocal is inlined in somewhere else.

As a fix, the inliner now pruned away variables such as "x" when
creating a copy of the Dcl list as part of the inlining; this means
that both the export data generator and the DWARF emitter wind up
seeing a consistent picture.

Fixes #25459

Change-Id: I753dc4e9f9ec694340adba5f43c907ba8cc9badc
Reviewed-on: https://go-review.googlesource.com/114090
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
src/cmd/compile/internal/gc/inl.go
src/cmd/link/internal/ld/dwarf_test.go
src/cmd/link/internal/ld/testdata/httptest/src/main/main.go [new file with mode: 0644]
src/cmd/link/internal/ld/testdata/issue25459/src/a/a.go [new file with mode: 0644]
src/cmd/link/internal/ld/testdata/issue25459/src/main/main.go [new file with mode: 0644]