cmd/compile/internal/devirtualize: use CallExpr.GoDefer for PGO

CL 543657 dedup'd the go/defer statement recognition between the
inliner and static devirtualizer. This CL extends that for PGO-based
devirtualization too.

Change-Id: I998753132af1ef17329676f4e17515f16e0acb03
Reviewed-on: https://go-review.googlesource.com/c/go/+/543775
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
Matthew Dempsky 2023-11-20 08:19:49 -08:00 committed by Gopher Robot
parent 82fc03f9c9
commit ddb38c3f54

View File

@ -107,9 +107,6 @@ func ProfileGuided(fn *ir.Func, p *pgo.Profile) {
name := ir.LinkFuncName(fn)
// Can't devirtualize go/defer calls. See comment in Static.
goDeferCall := make(map[*ir.CallExpr]bool)
var jsonW *json.Encoder
if base.Debug.PGODebug >= 3 {
jsonW = json.NewEncoder(os.Stdout)
@ -121,12 +118,6 @@ func ProfileGuided(fn *ir.Func, p *pgo.Profile) {
return n
}
if gds, ok := n.(*ir.GoDeferStmt); ok {
if call, ok := gds.Call.(*ir.CallExpr); ok {
goDeferCall[call] = true
}
}
ir.EditChildren(n, edit)
call, ok := n.(*ir.CallExpr)
@ -156,7 +147,7 @@ func ProfileGuided(fn *ir.Func, p *pgo.Profile) {
fmt.Printf("%v: PGO devirtualize considering call %v\n", ir.Line(call), call)
}
if goDeferCall[call] {
if call.GoDefer {
if base.Debug.PGODebug >= 2 {
fmt.Printf("%v: can't PGO devirtualize go/defer call %v\n", ir.Line(call), call)
}