]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fail noder.LookupFunc gracefully if function generic
authorMichael Pratt <mpratt@google.com>
Thu, 8 Feb 2024 18:07:33 +0000 (13:07 -0500)
committerMichael Pratt <mpratt@google.com>
Fri, 9 Feb 2024 20:03:18 +0000 (20:03 +0000)
commit532c6f1c8d724975f578c8ec519f1f5b07d949da
treec38b431b178c8b34fc39188ffc4a0b97f0fa87e5
parentd94ab597af9b3f8e8ba371023314d80f6b3be5a5
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.

Fixes #65615.

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>
src/cmd/compile/internal/noder/reader.go
src/cmd/compile/internal/noder/unified.go
src/cmd/compile/internal/test/pgo_devirtualize_test.go