]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove ir.Name.Ntype
authorMatthew Dempsky <mdempsky@google.com>
Tue, 3 May 2022 00:49:32 +0000 (17:49 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 5 May 2022 18:48:25 +0000 (18:48 +0000)
No longer needed now that IR construction uses types2.

Change-Id: If8b7aff80cd8472be7d87fd3a36da911a5df163c
Reviewed-on: https://go-review.googlesource.com/c/go/+/403839
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/compile/internal/inline/inl.go
src/cmd/compile/internal/ir/fmt.go
src/cmd/compile/internal/ir/name.go
src/cmd/compile/internal/ir/sizeof_test.go
src/cmd/compile/internal/noder/reader.go
src/cmd/compile/internal/typecheck/dcl.go
src/cmd/compile/internal/typecheck/func.go
src/cmd/compile/internal/typecheck/type.go

index 1fbda92418d5ab1dc97370d233fc685c8301f7de..7ec007e9224877a0dd8ab2594021a5e674722e49 100644 (file)
@@ -483,10 +483,6 @@ 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())
-                       // 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...)
@@ -1133,11 +1129,6 @@ func (subst *inlsubst) closure(n *ir.ClosureExpr) ir.Node {
        oldfn := n.Func
        newfn := ir.NewClosureFunc(oldfn.Pos(), true)
 
-       // Ntype can be nil for -G=3 mode.
-       if oldfn.Nname.Ntype != nil {
-               newfn.Nname.Ntype = subst.node(oldfn.Nname.Ntype).(ir.Ntype)
-       }
-
        if subst.newclofn != nil {
                //fmt.Printf("Inlining a closure with a nested closure\n")
        }
index a00667b309c18d4bc912641be15779e9c5733475..004d698961d2fe221c3b2cab189a7ce9f4734372 100644 (file)
@@ -1138,11 +1138,6 @@ func dumpNode(w io.Writer, n Node, depth int) {
                        fmt.Fprintf(w, "%+v", n.Op())
                }
                dumpNodeHeader(w, n)
-               if n.Type() == nil && n.Name() != nil && n.Name().Ntype != nil {
-                       indent(w, depth)
-                       fmt.Fprintf(w, "%+v-ntype", n.Op())
-                       dumpNode(w, n.Name().Ntype, depth+1)
-               }
                return
 
        case OASOP:
@@ -1153,11 +1148,6 @@ func dumpNode(w io.Writer, n Node, depth int) {
        case OTYPE:
                fmt.Fprintf(w, "%+v %+v", n.Op(), n.Sym())
                dumpNodeHeader(w, n)
-               if n.Type() == nil && n.Name() != nil && n.Name().Ntype != nil {
-                       indent(w, depth)
-                       fmt.Fprintf(w, "%+v-ntype", n.Op())
-                       dumpNode(w, n.Name().Ntype, depth+1)
-               }
                return
 
        case OCLOSURE:
index d057b3eafa604d0e666f755e0e01fb899f3348c3..925994fe96fcebb8aba574d43659c2d09fa8b896 100644 (file)
@@ -59,7 +59,6 @@ type Name struct {
        // The function, method, or closure in which local variable or param is declared.
        Curfn *Func
 
-       Ntype    Ntype
        Heapaddr *Name // temp holding heap address of param
 
        // ONAME closure linkage
index c1167f23f8eaa1845d155915ae07889e3330e0f3..754d1a8de070bf1ad7ba5fba0871c0eae451ea6a 100644 (file)
@@ -21,7 +21,7 @@ func TestSizeof(t *testing.T) {
                _64bit uintptr     // size on 64bit platforms
        }{
                {Func{}, 184, 320},
-               {Name{}, 108, 192},
+               {Name{}, 100, 176},
        }
 
        for _, tt := range tests {
index 4e00dbdfd5117dac419cfc6b038a9eb7a10123d7..b95dc23edb6461cd853e8438d25d00897b95e9d4 100644 (file)
@@ -153,10 +153,6 @@ type itabInfo2 struct {
 func setType(n ir.Node, typ *types.Type) {
        n.SetType(typ)
        n.SetTypecheck(1)
-
-       if name, ok := n.(*ir.Name); ok {
-               name.Ntype = ir.TypeNode(name.Type())
-       }
 }
 
 func setValue(name *ir.Name, val constant.Value) {
index b92980194c1d04b5377fd847d72438f054062292..3b426a6d07ac214023d82a724aa19ff3dbf1cf3b 100644 (file)
@@ -16,7 +16,7 @@ import (
 
 var DeclContext ir.Class = ir.PEXTERN // PEXTERN/PAUTO
 
-func DeclFunc(sym *types.Sym, tfn ir.Ntype) *ir.Func {
+func DeclFunc(sym *types.Sym, tfn *ir.FuncType) *ir.Func {
        if tfn.Op() != ir.OTFUNC {
                base.Fatalf("expected OTFUNC node, got %v", tfn)
        }
@@ -25,10 +25,8 @@ func DeclFunc(sym *types.Sym, tfn ir.Ntype) *ir.Func {
        fn.Nname = ir.NewNameAt(base.Pos, sym)
        fn.Nname.Func = fn
        fn.Nname.Defn = fn
-       fn.Nname.Ntype = tfn
        ir.MarkFunc(fn.Nname)
-       StartFuncBody(fn)
-       fn.Nname.Ntype = typecheckNtype(fn.Nname.Ntype)
+       StartFuncBody(fn, tfn)
        return fn
 }
 
@@ -97,7 +95,7 @@ func Export(n *ir.Name) {
 // and declare the arguments.
 // called in extern-declaration context
 // returns in auto-declaration context.
-func StartFuncBody(fn *ir.Func) {
+func StartFuncBody(fn *ir.Func, tfn *ir.FuncType) {
        // change the declaration context from extern to auto
        funcStack = append(funcStack, funcStackEnt{ir.CurFunc, DeclContext})
        ir.CurFunc = fn
@@ -105,11 +103,11 @@ func StartFuncBody(fn *ir.Func) {
 
        types.Markdcl()
 
-       if fn.Nname.Ntype != nil {
-               funcargs(fn.Nname.Ntype.(*ir.FuncType))
-       } else {
-               funcargs2(fn.Type())
-       }
+       funcargs(tfn)
+
+       tfn = tcFuncType(tfn)
+       fn.Nname.SetType(tfn.Type())
+       fn.Nname.SetTypecheck(1)
 }
 
 // finish the body.
@@ -202,7 +200,6 @@ func funcarg(n *ir.Field, ctxt ir.Class) {
 
        name := ir.NewNameAt(n.Pos, n.Sym)
        n.Decl = name
-       name.Ntype = nil
        Declare(name, ctxt)
 }
 
index f407ab613329866977b119d51658bf215283ce09..0d9b18bc374f2742b2d1c0b5a9dbeaf097857f73 100644 (file)
@@ -270,10 +270,7 @@ func tcFunc(n *ir.Func) {
        }
 
        if name := n.Nname; name.Typecheck() == 0 {
-               if name.Ntype != nil {
-                       name.Ntype = typecheckNtype(name.Ntype)
-                       name.SetType(name.Ntype.Type())
-               }
+               base.AssertfAt(name.Type() != nil, n.Pos(), "missing type: %v", name)
                name.SetTypecheck(1)
        }
 }
index 04cac888fcd28a818b389992b950058b23db2c44..ceebf2ab2f82b36fef547cad71ac9372ae3dfe96 100644 (file)
@@ -11,7 +11,7 @@ import (
 )
 
 // tcFuncType typechecks an OTFUNC node.
-func tcFuncType(n *ir.FuncType) ir.Node {
+func tcFuncType(n *ir.FuncType) *ir.FuncType {
        misc := func(f *types.Field, nf *ir.Field) {
                f.SetIsDDD(nf.IsDDD)
                if nf.Decl != nil {