]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.regabi] cmd/compile: fix package-initialization order
authorMatthew Dempsky <mdempsky@google.com>
Fri, 1 Jan 2021 07:45:36 +0000 (23:45 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 1 Jan 2021 10:52:33 +0000 (10:52 +0000)
commit68e6fa4f6852b4ef0fe61789618c093f4e2185c9
tree0d05c5a184ef8a3e68c642e3bbb962c26f4499ef
parent3a4474cdfda0096b5d88c769f81ad81d6f0168c7
[dev.regabi] cmd/compile: fix package-initialization order

This CL fixes package initialization order by creating the init task
before the general deadcode-removal pass.

It also changes noder to emit zero-initialization assignments (i.e.,
OAS with nil RHS) for package-block variables, so that initOrder can
tell the variables still need initialization. To allow this, we need
to also extend the static-init code to recognize zero-initialization
assignments.

This doesn't pass toolstash -cmp, because it reorders some package
initialization routines.

Fixes #43444.

Change-Id: I0da7996a62c85e15e97ce965298127e075390a7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/280976
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/noder/noder.go
src/cmd/compile/internal/pkginit/init.go
src/cmd/compile/internal/staticinit/sched.go
test/fixedbugs/issue43444.go [new file with mode: 0644]
test/fixedbugs/issue43444.out [new file with mode: 0644]