From: Matthew Dempsky Date: Sat, 9 Jan 2021 04:46:03 +0000 (-0800) Subject: [dev.typeparams] cmd/compile: calculate variable sizes in walk X-Git-Tag: go1.17beta1~1473^2~114 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8c5aa42c798cac76cab67f85521c68e9dbff70b0;p=gostls13.git [dev.typeparams] cmd/compile: calculate variable sizes in walk Walk already explicitly calculates the size of all expression types, to make sure they're known before SSA generation (which is concurrent, and thus not safe to modify shared state like types). Might as well compute all local variable sizes too, to be consistent. Reduces the burden of the frontend to make sure it's calculated the size of types that only the backend cares about. Passes toolstash -cmp. Change-Id: I68bcca67b4640bfc875467e4ed4d47104b1932f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/282912 Trust: Matthew Dempsky Trust: Robert Griesemer Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- diff --git a/src/cmd/compile/internal/walk/walk.go b/src/cmd/compile/internal/walk/walk.go index 928b673752..4a89d2201d 100644 --- a/src/cmd/compile/internal/walk/walk.go +++ b/src/cmd/compile/internal/walk/walk.go @@ -57,6 +57,11 @@ func Walk(fn *ir.Func) { if base.Flag.Cfg.Instrumenting { instrument(fn) } + + // Eagerly compute sizes of all variables for SSA. + for _, n := range fn.Dcl { + types.CalcSize(n.Type()) + } } func paramoutheap(fn *ir.Func) bool {