cmd/compile: don't require Heapaddr for heap vars in dead code DWARF generation's createConservativeVar asserts that every variable marked ir.EscHeap has a non-nil Heapaddr. This assumption only holds for reachable declarations. Escape analysis runs before SSA generation and is not reachability-aware, so it can mark a variable declared in dead code as heap-escaped. During SSA generation the ODCL for such a variable lands in an unreachable block, where stmt() returns early and never calls newHeapaddr. The variable is therefore left with Esc()==EscHeap but Heapaddr==nil, a legitimate state: the allocation was never generated, so there is no heap address to point at. Only build the heap-deref location list when Heapaddr is present, and otherwise emit a conservative variable with no location list, as was done before CL 684377. A reachable heap-escaped variable always gets a Heapaddr via newHeapaddr, so a nil Heapaddr uniquely identifies the dead-code case. Fixes #80097. Change-Id: I91e475d0256c0f5e4d2dfabcacff92904469087a Reviewed-on: https://go-review.googlesource.com/c/go/+/792960 LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Official binary distributions are available at https://go.dev/dl/.
After downloading a binary release, visit https://go.dev/doc/install for installation instructions.
If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.