]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: check method name in PGO devirtualization
authorCherry Mui <cherryyz@google.com>
Tue, 6 Jun 2023 02:28:48 +0000 (22:28 -0400)
committerCherry Mui <cherryyz@google.com>
Tue, 6 Jun 2023 14:45:44 +0000 (14:45 +0000)
commitfd03e6ebc91fb0b6f4dc721a323dc0b408e3b30b
tree30c30fab2375d53c0865f5474fe873ad451f7ad1
parentdb3f952b1f3c996085cb9bfe846590084f8fae2e
cmd/compile: check method name in PGO devirtualization

Currently, we devirtualize an interface call if the profile
indicates a concrete callee is hot on the same line, and the
concrete receiver implements the interface. But it is possible
that (likely due to another call on the same line, or possibly a
stale profile) the concrete call is to a different method.

With the current AST construction we generate correct code, as we
extract the method name from the interface call and use that to
create the concrete call. But the devirtualization decision is
based on an unrelated call in the profile.

Check the method name when finding the hottest callee, so we won't
use unrelated calls to different methods.

Change-Id: I75c026997926f21bd6cc5266d3ffe99649a9b2d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/500961
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/cmd/compile/internal/devirtualize/pgo.go