• Than McIntosh's avatar
    cmd/compile: fix DWARF inline debug issue with dead local vars · 1ba26a33
    Than McIntosh authored
    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: 's avatarHeschi Kreinick <heschi@google.com>
    1ba26a33
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...