mirror of
https://github.com/golang/go
synced 2024-11-05 14:46:11 -07:00
34f0029a85
In go.dev/cl/421821, I included a hack to force OCONVNOP back to OCONVIFACE for conversions involving shape types and non-empty interfaces. The comment correctly noted that this was only needed for conversions between non-identical types, but the code was conservative and applied to even conversions between identical types. This CL adds an extra bool to record whether the conversion is between identical types, so we can keep OCONVNOP instead of forcing back to OCONVIFACE. This has a small improvement to generated code, because we no longer need a convI2I call (as demonstrated by codegen/ifaces.go). But more usefully, this is relevant to pruning unnecessary itab slots in runtime dictionaries (next CL). Change-Id: I94f89e961cd26629b925037fea58d283140766ff Reviewed-on: https://go-review.googlesource.com/c/go/+/427678 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
22 lines
450 B
Go
22 lines
450 B
Go
// asmcheck
|
|
|
|
// Copyright 2022 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package codegen
|
|
|
|
type I interface { M() }
|
|
|
|
func NopConvertIface(x I) I {
|
|
// amd64:-`.*runtime.convI2I`
|
|
return I(x)
|
|
}
|
|
|
|
func NopConvertGeneric[T any](x T) T {
|
|
// amd64:-`.*runtime.convI2I`
|
|
return T(x)
|
|
}
|
|
|
|
var NopConvertGenericIface = NopConvertGeneric[I]
|