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.

Change-Id: Ied19a6d06f44c0c3e69632960a85f8d32139095c
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/245098
Reviewed-by: Cherry Zhang <cherryyz@google.com>
1 file changed