]> Cypherpunks repositories - gostls13.git/commit
[dev.regabi] cmd/compile: fix ICE when initializing blank vars
authorMatthew Dempsky <mdempsky@google.com>
Wed, 13 Jan 2021 23:02:16 +0000 (15:02 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 14 Jan 2021 00:14:28 +0000 (00:14 +0000)
commit983ac4b08663ea9655abe99ca30faf47e54fdc16
tree2cb12eef9c9767a6733d8d4fc225c992aee13828
parentd6d467372854124795cdd11429244ef1e28b809c
[dev.regabi] cmd/compile: fix ICE when initializing blank vars

CL 278914 introduced NameOffsetExpr to avoid copying ONAME nodes and
hacking up their offsets, but evidently staticinit subtly depended on
the prior behavior to allow dynamic initialization of blank variables.

This CL refactors the code somewhat to avoid using NameOffsetExpr with
blank variables, and to instead create dynamic assignments directly to
the global blank node. It also adds a check to NewNameOffsetExpr to
guard against misuse like this, since I suspect there could be other
cases still lurking within staticinit. (This code is overdue for an
makeover anyway.)

Thanks to thanm@ for bisect and test case minimization.

Fixes #43677.

Change-Id: Ic71cb5d6698382feb9548dc3bb9fd606b207a172
Reviewed-on: https://go-review.googlesource.com/c/go/+/283537
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/compile/internal/ir/expr.go
src/cmd/compile/internal/staticinit/sched.go
test/fixedbugs/issue43677.go [new file with mode: 0644]