mirror of
https://github.com/golang/go
synced 2024-11-23 01:30:02 -07:00
cmd/compile: mark generated eq/hash functions as //go:noinline
Instead of having the inliner specially recognize that eq/hash functions can't be inlined, change the geneq and genhash to mark them as //go:noinline. This is a prereq for a subsequent CL that will move more logic for handling rtypes from package types to package reflectdata. Change-Id: I091a9ededcc083fe8305cf5443a9af7d3a9053b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/518955 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
133cea5cba
commit
f123f5c768
@ -438,13 +438,6 @@ func InlineImpossible(fn *ir.Func) string {
|
||||
return reason
|
||||
}
|
||||
|
||||
// If fn is synthetic hash or eq function, cannot inline it.
|
||||
// The function is not generated in Unified IR frontend at this moment.
|
||||
if ir.IsEqOrHashFunc(fn) {
|
||||
reason = "type eq/hash function"
|
||||
return reason
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -301,14 +301,6 @@ func LinkFuncName(f *Func) string {
|
||||
return objabi.PathToPrefix(pkg.Path) + "." + s.Name
|
||||
}
|
||||
|
||||
// IsEqOrHashFunc reports whether f is type eq/hash function.
|
||||
func IsEqOrHashFunc(f *Func) bool {
|
||||
if f == nil || f.Nname == nil {
|
||||
return false
|
||||
}
|
||||
return types.IsTypePkg(f.Sym().Pkg)
|
||||
}
|
||||
|
||||
var CurFunc *Func
|
||||
|
||||
// WithFunc invokes do with CurFunc and base.Pos set to curfn and
|
||||
|
@ -152,6 +152,8 @@ func hashFunc(t *types.Type) *ir.Func {
|
||||
|
||||
fn := typecheck.DeclFunc(sym, nil, args, results)
|
||||
sym.Def = fn.Nname
|
||||
fn.Pragma |= ir.Noinline // TODO(mdempsky): We need to emit this during the unified frontend instead, to allow inlining.
|
||||
|
||||
np := ir.AsNode(fn.Type().Params().Field(0).Nname)
|
||||
nh := ir.AsNode(fn.Type().Params().Field(1).Nname)
|
||||
|
||||
@ -375,6 +377,8 @@ func eqFunc(t *types.Type) *ir.Func {
|
||||
[]*ir.Field{ir.NewField(base.Pos, typecheck.Lookup("r"), types.Types[types.TBOOL])},
|
||||
)
|
||||
sym.Def = fn.Nname
|
||||
fn.Pragma |= ir.Noinline // TODO(mdempsky): We need to emit this during the unified frontend instead, to allow inlining.
|
||||
|
||||
np := ir.AsNode(fn.Type().Params().Field(0).Nname)
|
||||
nq := ir.AsNode(fn.Type().Params().Field(1).Nname)
|
||||
nr := ir.AsNode(fn.Type().Results().Field(0).Nname)
|
||||
|
@ -1858,11 +1858,6 @@ func IsReflectPkg(p *Pkg) bool {
|
||||
return p.Path == "reflect"
|
||||
}
|
||||
|
||||
// IsTypePkg reports whether p is pesudo package type.
|
||||
func IsTypePkg(p *Pkg) bool {
|
||||
return p == typepkg
|
||||
}
|
||||
|
||||
// IsNoInstrumentPkg reports whether p is a package that
|
||||
// should not be instrumented.
|
||||
func IsNoInstrumentPkg(p *Pkg) bool {
|
||||
|
Loading…
Reference in New Issue
Block a user