cmd/compile: add sizeCalculationDisabled flag

Use it to ensure that dowidth is not called
from the backend on a type whose size
has not yet been calculated.

This is an alternative to CL 42016.

Change-Id: I8c7b4410ee4c2a68573102f6b9b635f4fdcf392e
Reviewed-on: https://go-review.googlesource.com/42018
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Josh Bleecher Snyder 2017-04-27 16:37:25 -07:00
parent dae5389d3d
commit c51559813f
4 changed files with 22 additions and 15 deletions

View file

@ -254,6 +254,7 @@ func compileSSA(fn *Node, worker int) {
// and waits for them to complete.
func compileFunctions() {
if len(compilequeue) != 0 {
sizeCalculationDisabled = true // not safe to calculate sizes concurrently
if raceEnabled {
// Randomize compilation order to try to shake out races.
tmp := make([]*Node, len(compilequeue))
@ -287,6 +288,7 @@ func compileFunctions() {
close(c)
compilequeue = nil
wg.Wait()
sizeCalculationDisabled = false
}
}