From: Matthew Dempsky Date: Mon, 20 Nov 2023 16:19:49 +0000 (-0800) Subject: cmd/compile/internal/devirtualize: use CallExpr.GoDefer for PGO X-Git-Tag: go1.22rc1~242 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ddb38c3f540c17a0437132532f49f6f0061d82af;p=gostls13.git 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Pratt --- diff --git a/src/cmd/compile/internal/devirtualize/pgo.go b/src/cmd/compile/internal/devirtualize/pgo.go index 05b37d6be6..170bf74673 100644 --- a/src/cmd/compile/internal/devirtualize/pgo.go +++ b/src/cmd/compile/internal/devirtualize/pgo.go @@ -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) }