]> Cypherpunks.ru repositories - gostls13.git/commit
[release-branch.go1.22] cmd/compile: fail noder.LookupFunc gracefully if function...
authorMichael Pratt <mpratt@google.com>
Thu, 8 Feb 2024 18:07:33 +0000 (13:07 -0500)
committerThan McIntosh <thanm@google.com>
Fri, 16 Feb 2024 15:54:58 +0000 (15:54 +0000)
commit6cbe522fe1db19bb7d404d613bb9f2f46ca40655
tree1899d3135fd2c0089aa6b237ea6bdf2b2ef2470b
parentfb86598cd31ce6010aea91122bbe277b9e03b52d
[release-branch.go1.22] cmd/compile: fail noder.LookupFunc gracefully if function generic

PGO uses noder.LookupFunc to look for devirtualization targets in
export data.  LookupFunc does not support type-parameterized
functions, and will currently fail the build when attempting to lookup
a type-parameterized function because objIdx is passed the wrong
number of type arguments.

This doesn't usually come up, as a PGO profile will report a generic
function with a symbol name like Func[.go.shape.foo]. In export data,
this is just Func, so when we do LookupFunc("Func[.go.shape.foo]")
lookup simply fails because the name doesn't exist.

However, if Func is not generic when the profile is collected, but the
source has since changed to make Func generic, then LookupFunc("Func")
will find the object successfully, only to fail the build because we
failed to provide type arguments.

Handle this with a objIdxMayFail, which allows graceful failure if the
object requires type arguments.

Bumping the language version to 1.21 in pgo_devirtualize_test.go is
required for type inference of the uses of mult.MultFn in
cmd/compile/internal/test/testdata/pgo/devirtualize/devirt_test.go.

For #65615.
Fixes #65618.

Change-Id: I84d9344840b851182f5321b8f7a29a591221b29f
Reviewed-on: https://go-review.googlesource.com/c/go/+/562737
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 532c6f1c8d724975f578c8ec519f1f5b07d949da)
Reviewed-on: https://go-review.googlesource.com/c/go/+/563016
src/cmd/compile/internal/noder/reader.go
src/cmd/compile/internal/noder/unified.go
src/cmd/compile/internal/test/pgo_devirtualize_test.go