]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/devirtualize: use CallExpr.GoDefer for PGO
authorMatthew Dempsky <mdempsky@google.com>
Mon, 20 Nov 2023 16:19:49 +0000 (08:19 -0800)
committerGopher Robot <gobot@golang.org>
Mon, 20 Nov 2023 18:59:37 +0000 (18:59 +0000)
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>
src/cmd/compile/internal/devirtualize/pgo.go

index 05b37d6be62d778c370a39145ea4938558aeac4d..170bf746739e7ba6b9cd792fa538f712fb654a3e 100644 (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)
                        }