diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2023-11-18 20:16:47 -0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-11-20 18:09:45 +0000 |
| commit | 4a90cdb03d9c103abb0d44ff42dde7121ac6cd34 (patch) | |
| tree | d6d50035f1aff3e9ed2fcf0fd2f371101d2ce9d3 /src/cmd/compile/internal/devirtualize | |
| parent | ee6b34797b66b957fdf9b7211ee3f0b80ac57758 (diff) | |
| download | go-4a90cdb03d9c103abb0d44ff42dde7121ac6cd34.tar.xz | |
cmd/compile: interleave devirtualization and inlining
This CL interleaves devirtualization and inlining, so that
devirtualized calls can be inlined.
Fixes #52193.
Change-Id: I681e7c55bdb90ebf6df315d334e7a58f05110d9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/528321
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/devirtualize')
| -rw-r--r-- | src/cmd/compile/internal/devirtualize/devirtualize.go | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/cmd/compile/internal/devirtualize/devirtualize.go b/src/cmd/compile/internal/devirtualize/devirtualize.go index 9e26f66a1c..5d1b952627 100644 --- a/src/cmd/compile/internal/devirtualize/devirtualize.go +++ b/src/cmd/compile/internal/devirtualize/devirtualize.go @@ -18,22 +18,9 @@ import ( "cmd/compile/internal/types" ) -// Static devirtualizes calls within fn where possible when the concrete callee +// StaticCall devirtualizes the given call if possible when the concrete callee // is available statically. -func Static(fn *ir.Func) { - ir.CurFunc = fn - - ir.VisitList(fn.Body, func(n ir.Node) { - switch n := n.(type) { - case *ir.CallExpr: - staticCall(n) - } - }) -} - -// staticCall devirtualizes the given call if possible when the concrete callee -// is available statically. -func staticCall(call *ir.CallExpr) { +func StaticCall(call *ir.CallExpr) { // For promoted methods (including value-receiver methods promoted // to pointer-receivers), the interface method wrapper may contain // expressions that can panic (e.g., ODEREF, ODOTPTR, @@ -51,6 +38,7 @@ func staticCall(call *ir.CallExpr) { if call.Op() != ir.OCALLINTER { return } + sel := call.Fun.(*ir.SelectorExpr) r := ir.StaticValue(sel.X) if r.Op() != ir.OCONVIFACE { |
