]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: don't set Ntype in noder2 anymore
authorDan Scales <danscales@google.com>
Fri, 9 Apr 2021 13:30:20 +0000 (06:30 -0700)
committerDan Scales <danscales@google.com>
Fri, 9 Apr 2021 22:57:48 +0000 (22:57 +0000)
Now that we are no longer calling the old typechecker at all during the
noder2 pass, we don't need to create and set an Ntype node ((which is
just a node representation of the type which we already know) for the
Name and Closure nodes. This should reduce memory usage a bit for -G=3.

Change-Id: I6b1345007ce067a89ee64955a53f25645c303f4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/308909
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/inline/inl.go
src/cmd/compile/internal/noder/expr.go
src/cmd/compile/internal/noder/object.go
src/cmd/compile/internal/noder/stencil.go

index 1d049298d724b2090e89e4e30b26d490ddbb28fc..1941dc44bca30feb82f16b0ce4604d76e13a81b9 100644 (file)
@@ -506,7 +506,10 @@ func inlcopy(n ir.Node) ir.Node {
                        newfn.Nname = ir.NewNameAt(oldfn.Nname.Pos(), oldfn.Nname.Sym())
                        // XXX OK to share fn.Type() ??
                        newfn.Nname.SetType(oldfn.Nname.Type())
-                       newfn.Nname.Ntype = inlcopy(oldfn.Nname.Ntype).(ir.Ntype)
+                       // Ntype can be nil for -G=3 mode.
+                       if oldfn.Nname.Ntype != nil {
+                               newfn.Nname.Ntype = inlcopy(oldfn.Nname.Ntype).(ir.Ntype)
+                       }
                        newfn.Body = inlcopylist(oldfn.Body)
                        // Make shallow copy of the Dcl and ClosureVar slices
                        newfn.Dcl = append([]*ir.Name(nil), oldfn.Dcl...)
@@ -1213,7 +1216,10 @@ func (subst *inlsubst) closure(n *ir.ClosureExpr) ir.Node {
        newfn.SetIsHiddenClosure(true)
        newfn.Nname = ir.NewNameAt(n.Pos(), ir.BlankNode.Sym())
        newfn.Nname.Func = newfn
-       newfn.Nname.Ntype = subst.node(oldfn.Nname.Ntype).(ir.Ntype)
+       // Ntype can be nil for -G=3 mode.
+       if oldfn.Nname.Ntype != nil {
+               newfn.Nname.Ntype = subst.node(oldfn.Nname.Ntype).(ir.Ntype)
+       }
        newfn.Nname.Defn = newfn
 
        m.(*ir.ClosureExpr).Func = newfn
index fc97df7197ffe957c9da9dda4e64f3ba9ff14a91..b2c2616b3532bc8245d352fdab014cad957cc7d0 100644 (file)
@@ -360,8 +360,6 @@ func (g *irgen) funcLit(typ2 types2.Type, expr *syntax.FuncLit) ir.Node {
        typ := g.typ(typ2)
        fn.Nname.Func = fn
        fn.Nname.Defn = fn
-       // Set Ntype for now to be compatible with later parts of compile, remove later.
-       fn.Nname.Ntype = ir.TypeNode(typ)
        typed(typ, fn.Nname)
        fn.SetTypecheck(1)
 
index 6c8ed4af97299bc43eef6d4f8caa8b5f55659e12..82cce1ace0fcff81856f1751498f009c2d5fa84b 100644 (file)
@@ -147,9 +147,6 @@ func (g *irgen) objFinish(name *ir.Name, class ir.Class, typ *types.Type) {
                sym.SetFunc(true)
        }
 
-       // We already know name's type, but typecheck is really eager to try
-       // recomputing it later. This appears to prevent that at least.
-       name.Ntype = ir.TypeNode(typ)
        name.SetTypecheck(1)
        name.SetWalkdef(1)
 
index 0d84db999395015822670852c6224f14d47b7ce0..329c80098a34e7d2daab79bef4a44cdd2ce0d073 100644 (file)
@@ -298,7 +298,6 @@ func (g *irgen) genericSubst(newsym *types.Sym, nameNode *ir.Name, targs []ir.No
                subst.fields(ir.PPARAM, append(oldt.Recvs().FieldSlice(), oldt.Params().FieldSlice()...), newf.Dcl),
                subst.fields(ir.PPARAMOUT, oldt.Results().FieldSlice(), newf.Dcl))
 
-       newf.Nname.Ntype = ir.TypeNode(newt)
        newf.Nname.SetType(newt)
        ir.MarkFunc(newf.Nname)
        newf.SetTypecheck(1)
@@ -497,8 +496,7 @@ func (subst *subster) node(n ir.Node) ir.Node {
 
                case ir.OCLOSURE:
                        x := x.(*ir.ClosureExpr)
-                       // Need to save/duplicate x.Func.Nname,
-                       // x.Func.Nname.Ntype, x.Func.Dcl, x.Func.ClosureVars, and
+                       // Need to duplicate x.Func.Nname, x.Func.Dcl, x.Func.ClosureVars, and
                        // x.Func.Body.
                        oldfn := x.Func
                        newfn := ir.NewFunc(oldfn.Pos())
@@ -522,8 +520,6 @@ func (subst *subster) node(n ir.Node) ir.Node {
                        newfn.Dcl = subst.namelist(oldfn.Dcl)
                        newfn.ClosureVars = subst.namelist(oldfn.ClosureVars)
 
-                       // Set Ntype for now to be compatible with later parts of compiler
-                       newfn.Nname.Ntype = subst.node(oldfn.Nname.Ntype).(ir.Ntype)
                        typed(subst.typ(oldfn.Nname.Type()), newfn.Nname)
                        typed(newfn.Nname.Type(), m)
                        newfn.SetTypecheck(1)