compiler: for package-scope "a = b; b = x" just set "a = x"
authorIan Lance Taylor <iant@golang.org>
Mon, 27 Jul 2020 21:22:55 +0000 (14:22 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 28 Jul 2020 00:02:58 +0000 (17:02 -0700)
commite1d3a86fd3e91ccdbc702fc99595116adeded0d5
tree085acf33e61ea6e37dfa594bc383b507961fbda9
parent1b024c9a29701fce8c6aa0d2a321829a07b39123
compiler: for package-scope "a = b; b = x" just set "a = x"

This avoids requiring an init function to initialize the variable.
This can only be done if x is a static initializer.

The go1.15rc1 runtime package relies on this optimization.
The package has a variable "var maxSearchAddr = maxOffAddr".
The maxSearchAddr variable is used by code that runs before package
initialization is complete.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/245098
gcc/go/gofrontend/MERGE
gcc/go/gofrontend/gogo.cc