]> Cypherpunks repositories - gostls13.git/commit
[dev.regabi] cmd/compile: don't promote Byval CaptureVars if Addrtaken
authorMatthew Dempsky <mdempsky@google.com>
Fri, 15 Jan 2021 08:39:24 +0000 (00:39 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 15 Jan 2021 16:13:04 +0000 (16:13 +0000)
commitab523fc510aadb82dc39dec89741fcbb90093ff0
tree2e1c0a72a4659a85300e9599fab2f72def54d856
parentb7a698c73fc61bf60e2e61db0c98f16b0bfc8652
[dev.regabi] cmd/compile: don't promote Byval CaptureVars if Addrtaken

We decide during escape analysis whether to pass closure variables by
value or reference. One of the factors that's considered is whether a
variable has had its address taken.

However, this analysis is based only on the user-written source code,
whereas order+walk may introduce rewrites that take the address of a
variable (e.g., passing a uint16 key by reference to the size-generic
map runtime builtins).

Typically this would be harmless, albeit suboptimal. But in #43701 it
manifested as needing a stack object for a function where we didn't
realize we needed one up front when we generate symbols.

Probably we should just generate symbols on demand, now that those
routines are all concurrent-safe, but this is a first fix.

Thanks to Alberto Donizetti for reporting the issue, and Cuong Manh Le
for initial investigation.

Fixes #43701.

Change-Id: I16d87e9150723dcb16de7b43f2a8f3cd807a9437
Reviewed-on: https://go-review.googlesource.com/c/go/+/284075
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/ssagen/ssa.go
test/fixedbugs/issue43701.go [new file with mode: 0644]