]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: mark generated eq/hash functions as //go:noinline
authorMatthew Dempsky <mdempsky@google.com>
Fri, 11 Aug 2023 21:22:56 +0000 (14:22 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 14 Aug 2023 18:39:18 +0000 (18:39 +0000)
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>

src/cmd/compile/internal/inline/inl.go
src/cmd/compile/internal/ir/func.go
src/cmd/compile/internal/reflectdata/alg.go
src/cmd/compile/internal/types/type.go

index 28cd870a54e55871c4ce57856cc36c9130172fa0..dfafd50dad5d70b183746b95afa84919839cb972 100644 (file)
@@ -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 ""
 }
 
index a232c0fb708b617ac27c5cba8432092b974161c9..dcd9e562896f3c1b267ace11a01b1f98f0577388 100644 (file)
@@ -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
index 4489f59c26c33518cad9261ec4c12e014c87b9ed..20b5b76265359da2af792894ae692792c46f8d1c 100644 (file)
@@ -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)
index c390b8194b895df892c155923a7eba5a238f7eb5..2b72a9cd24a0d1e146c42c5ac2060611a5941248 100644 (file)
@@ -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 {