diff options
author | Keith Randall <khr@golang.org> | 2021-08-04 22:18:23 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2021-08-09 16:10:20 +0000 |
commit | 57668b84ff43b15746a25e9653c278d174ea483f (patch) | |
tree | 1c1c3ddfbb6618f5a5f9ed57d1874e78b2bf374b /src/cmd/compile/internal/walk/order.go | |
parent | d10a90471275bf2d91c4c853d7d1f75f23a70a32 (diff) | |
download | go-57668b84ff43b15746a25e9653c278d174ea483f.tar.gz go-57668b84ff43b15746a25e9653c278d174ea483f.zip |
[dev.typeparams] cmd/compile: simplify interface conversions
Simplify the implementation of interface conversions in the compiler.
Don't pass fields that aren't needed (the data word, usually) to the runtime.
For generics, we need to put a dynamic type in an interface. The new
dataWord function is exactly what we need (the type word will come
from a dictionary).
Change-Id: Iade5de5c174854b65ad248f35c7893c603f7be3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/340029
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/walk/order.go')
-rw-r--r-- | src/cmd/compile/internal/walk/order.go | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/walk/order.go b/src/cmd/compile/internal/walk/order.go index c5fd0c1e1d..6e336f565c 100644 --- a/src/cmd/compile/internal/walk/order.go +++ b/src/cmd/compile/internal/walk/order.go @@ -1166,11 +1166,7 @@ func (o *orderState) expr1(n, lhs ir.Node) ir.Node { if n.X.Type().IsInterface() { return n } - to := n.Type() - if n.Op() == ir.OCONVIDATA { - to = types.NewInterface(types.LocalPkg, nil) - } - if _, _, needsaddr := convFuncName(n.X.Type(), to); needsaddr || isStaticCompositeLiteral(n.X) { + if _, _, needsaddr := dataWordFuncName(n.X.Type()); needsaddr || isStaticCompositeLiteral(n.X) { // Need a temp if we need to pass the address to the conversion function. // We also process static composite literal node here, making a named static global // whose address we can put directly in an interface (see OCONVIFACE/OCONVIDATA case in walk). |