]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile/internal/devirtualize: devirtualize methods in other packages if current...
authorthepudds <thepudds@users.noreply.github.com>
Sat, 3 Jun 2023 00:56:31 +0000 (00:56 +0000)
committerCherry Mui <cherryyz@google.com>
Sat, 3 Jun 2023 01:13:08 +0000 (01:13 +0000)
commit363713223385476b87dc5f26d267df8c67d13006
treedff37ab5aafe60af5618fd95d2a2befbec89e3b0
parent3fd867cecc2b31c767f8a60f49ac4138dea69d0f
cmd/compile/internal/devirtualize: devirtualize  methods in other packages if current package has a concrete reference

The new PGO-driven indirect call specialization from CL 492436
in theory should allow for devirtualization on methods
in another package when those methods are directly referenced
in the current package.

However, inline.InlineImpossible was checking for a zero-length
fn.Body and would cause devirtualization to fail
with a debug log message like:

 "should not PGO devirtualize (*Speaker1).Speak: no function body"

Previously, the logic in inline.InlineImpossible was only
called on local functions, but with PGO-based devirtualization,
it can now be called on imported functions, where inlinable
imported functions will have a zero-length fn.Body but a
non-nil fn.Inl.

We update inline.InlineImpossible to handle imported functions
by adding a call to typecheck.HaveInlineBody in the check
that was previously failing.

For the test, we need to have a hopefully temporary workaround
of adding explicit references to the callees in another package
for devirtualization to work. CL 497175 or similar should
enable removing this workaround.

Fixes #60561
Updates #59959

Change-Id: I48449b7d8b329d84151bd3b506b8093c262eb2a3
GitHub-Last-Rev: 2d53c55fd895ad8fefd25510a6e6969e89d54a6d
GitHub-Pull-Request: golang/go#60565
Reviewed-on: https://go-review.googlesource.com/c/go/+/500155
Run-TryBot: thepudds <thepudds1460@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/compile/internal/devirtualize/pgo.go
src/cmd/compile/internal/inline/inl.go
src/cmd/compile/internal/test/pgo_devirtualize_test.go
src/cmd/compile/internal/test/testdata/pgo/devirtualize/devirt.go
src/cmd/compile/internal/test/testdata/pgo/devirtualize/devirt.pprof
src/cmd/compile/internal/test/testdata/pgo/devirtualize/devirt_test.go
src/cmd/compile/internal/test/testdata/pgo/devirtualize/mult/mult.go [new file with mode: 0644]