mirror of
https://github.com/golang/go
synced 2024-10-14 20:05:36 +00:00
cmd/compile: fix inline static init with derived types
CL 450136 added handling for simple calls in staticinit. If there's any derived types conversion in the body of generic function called, that conversion will require runtime dictionary, thus the optimization could not happen. Fixes #56923 Change-Id: I498cee9f8ab4397812ef79a6c2ab6c55e0ee4aef Reviewed-on: https://go-review.googlesource.com/c/go/+/453315 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Gabriel Morency (Amgc63spaming) <morencyvincent8@gmail.com>
This commit is contained in:
parent
8c0256b398
commit
c85848a4a6
|
@ -333,6 +333,11 @@ func (s *Schedule) StaticAssign(l *ir.Name, loff int64, r ir.Node, typ *types.Ty
|
|||
return val.Op() == ir.ONIL
|
||||
}
|
||||
|
||||
if base.Debug.Unified != 0 && val.Type().HasShape() {
|
||||
// See comment in cmd/compile/internal/walk/convert.go:walkConvInterface
|
||||
return false
|
||||
}
|
||||
|
||||
reflectdata.MarkTypeUsedInInterface(val.Type(), l.Linksym())
|
||||
|
||||
var itab *ir.AddrExpr
|
||||
|
|
28
test/fixedbugs/issue56923.go
Normal file
28
test/fixedbugs/issue56923.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
// compile
|
||||
|
||||
// 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 p
|
||||
|
||||
type Eq[T any] interface {
|
||||
Eqv(a T, b T) bool
|
||||
}
|
||||
|
||||
type EqFunc[T any] func(a, b T) bool
|
||||
|
||||
func (r EqFunc[T]) Eqv(a, b T) bool {
|
||||
return r(a, b)
|
||||
}
|
||||
|
||||
func New[T any](f func(a, b T) bool) Eq[T] {
|
||||
return EqFunc[T](f)
|
||||
|
||||
}
|
||||
|
||||
func Equal(a, b []byte) bool {
|
||||
return string(a) == string(b)
|
||||
}
|
||||
|
||||
var Bytes Eq[[]byte] = New(Equal)
|
Loading…
Reference in a new issue