aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/devirtualize
diff options
context:
space:
mode:
authorJulia Lapenko <julia.lapenko@gmail.com>2025-03-06 17:54:17 +0300
committerKeith Randall <khr@golang.org>2025-04-02 16:39:13 -0700
commit13b1261175efde5aac7c4c7f6f66ae3b2c609a2d (patch)
tree039846d213ad5481596ec84055bd6396bdf226a6 /src/cmd/compile/internal/devirtualize
parent116b82354ce53dea7b139039adbda3231689b02d (diff)
downloadgo-13b1261175efde5aac7c4c7f6f66ae3b2c609a2d.tar.xz
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>
Diffstat (limited to 'src/cmd/compile/internal/devirtualize')
-rw-r--r--src/cmd/compile/internal/devirtualize/pgo.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/devirtualize/pgo.go b/src/cmd/compile/internal/devirtualize/pgo.go
index 96c9231be3..a8980bb86b 100644
--- a/src/cmd/compile/internal/devirtualize/pgo.go
+++ b/src/cmd/compile/internal/devirtualize/pgo.go
@@ -741,7 +741,7 @@ func findHotConcreteCallee(p *pgoir.Profile, caller *ir.Func, call *ir.CallExpr,
hottest = e
}
- if hottest == nil {
+ if hottest == nil || hottest.Weight == 0 {
if base.Debug.PGODebug >= 2 {
fmt.Printf("%v: call %s:%d: no hot callee\n", ir.Line(call), callerName, callOffset)
}