]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: fix unstable selection of hottest edge
authorMichael Pratt <mpratt@google.com>
Thu, 2 Nov 2023 18:16:16 +0000 (14:16 -0400)
committerGopher Robot <gobot@golang.org>
Thu, 2 Nov 2023 20:37:16 +0000 (20:37 +0000)
commit2d428cfd85933cbe5c59a32498c82bda12ca5c96
treeecdac8f8dcd05f3691b93a47dc99afc2e1659f93
parent547eb8d699a63512cf58c7eeae5517ead7debf50
cmd/compile: fix unstable selection of hottest edge

When selecting the hottest edge to use for PGO-based devirtualization,
edges are order by:

1. Edge weight
2. If weights are equal, prefer the edge with IR available in the
   package.
3. Otherwise, simply sort lexicographically.

The existing logic for (2) is incomplete.

If the hottest edge so far is missing IR, but the new edge has IR, then
it works as expected and selects the new edge.

But if the hottest edge so far has IR and the new edge is missing IR, we
want to always keep the hottest edge so far, but this logic will fall
through and use lexicographical ordering instead.

Adjust the check to always make an explicit choice when IR availability
differs.

Change-Id: Ia7fcc286aa9a62ac209fd978cfce60463505f4cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/539475
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@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/devirtualize/pgo_test.go [new file with mode: 0644]