]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: don't devirtualize calls to runtime.memhash_varlen
authorMichael Pratt <mpratt@google.com>
Thu, 16 Nov 2023 19:58:37 +0000 (14:58 -0500)
committerMichael Pratt <mpratt@google.com>
Thu, 16 Nov 2023 21:31:06 +0000 (21:31 +0000)
commit3fd5c357a3a763f70f3ed684caed878e732e6ebe
treeb9d9367b6bf0473407b4416affcd47f74cd43fcb
parente62bf150cc0802b3697da315ee41e19c0bbfb7eb
cmd/compile: don't devirtualize calls to runtime.memhash_varlen

runtime.memhash_varlen is defined as a normal function, but it is
actually a closure. All references are generated by
cmd/compile/internal/reflectdata.genhash, which creates a closure
containing the size of the type, which memhash_varlen accesses with
runtime.getclosureptr.

Since this doesn't look like a normal closure, ir.Func.OClosure is not
set, thus PGO function value devirtualization is willing to devirtualize
it, generating a call that completely ignores the closure context. This
causes memhash_varlen to either crash or generate incorrect results.

Skip this function, which is the only caller of getclosureptr.
Unfortunately there isn't a good way to detect these ineligible
functions more generally.

Fixes #64209.

Change-Id: Ibf509406667c6d4e5d431f10e5b1d1f926ecd7dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/543195
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/compile/internal/devirtualize/pgo.go
src/runtime/stubs.go