]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/devirtualize: do not select a zero-weight edge as the hottest one
authorJulia Lapenko <julia.lapenko@gmail.com>
Thu, 6 Mar 2025 14:54:17 +0000 (17:54 +0300)
committerKeith Randall <khr@golang.org>
Wed, 2 Apr 2025 23:39:13 +0000 (16:39 -0700)
commit13b1261175efde5aac7c4c7f6f66ae3b2c609a2d
tree039846d213ad5481596ec84055bd6396bdf226a6
parent116b82354ce53dea7b139039adbda3231689b02d
cmd/compile/internal/devirtualize: do not select a zero-weight edge as the hottest one

When both a direct call and an interface call appear on the same line,
PGO devirtualization may make a suboptimal decision. In some cases,
the directly called function becomes a candidate for devirtualization
if no other relevant outgoing edges with non-zero weight exist for the
caller's IRNode in the WeightedCG. The edge to this candidate is
considered the hottest. Despite having zero weight, this edge still
causes the interface call to be devirtualized.

This CL prevents devirtualization when the weight of the hottest edge
is 0.

Fixes #72092

Change-Id: I06c0c5e080398d86f832e09244aceaa4aeb98721
Reviewed-on: https://go-review.googlesource.com/c/go/+/655475
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/compile/internal/devirtualize/pgo.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_test.go