cmd/compile: remove ir.Name.Ntype

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>
This commit is contained in:
Matthew Dempsky 2022-05-02 17:49:32 -07:00
parent e94fe09c33
commit a6a49d128b
8 changed files with 11 additions and 41 deletions

View file

@ -483,10 +483,6 @@ func inlcopy(n ir.Node) ir.Node {
newfn.Nname = ir.NewNameAt(oldfn.Nname.Pos(), oldfn.Nname.Sym()) newfn.Nname = ir.NewNameAt(oldfn.Nname.Pos(), oldfn.Nname.Sym())
// XXX OK to share fn.Type() ?? // XXX OK to share fn.Type() ??
newfn.Nname.SetType(oldfn.Nname.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) newfn.Body = inlcopylist(oldfn.Body)
// Make shallow copy of the Dcl and ClosureVar slices // Make shallow copy of the Dcl and ClosureVar slices
newfn.Dcl = append([]*ir.Name(nil), oldfn.Dcl...) newfn.Dcl = append([]*ir.Name(nil), oldfn.Dcl...)
@ -1133,11 +1129,6 @@ func (subst *inlsubst) closure(n *ir.ClosureExpr) ir.Node {
oldfn := n.Func oldfn := n.Func
newfn := ir.NewClosureFunc(oldfn.Pos(), true) 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 { if subst.newclofn != nil {
//fmt.Printf("Inlining a closure with a nested closure\n") //fmt.Printf("Inlining a closure with a nested closure\n")
} }

View file

@ -1138,11 +1138,6 @@ func dumpNode(w io.Writer, n Node, depth int) {
fmt.Fprintf(w, "%+v", n.Op()) fmt.Fprintf(w, "%+v", n.Op())
} }
dumpNodeHeader(w, n) 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 return
case OASOP: case OASOP:
@ -1153,11 +1148,6 @@ func dumpNode(w io.Writer, n Node, depth int) {
case OTYPE: case OTYPE:
fmt.Fprintf(w, "%+v %+v", n.Op(), n.Sym()) fmt.Fprintf(w, "%+v %+v", n.Op(), n.Sym())
dumpNodeHeader(w, n) 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 return
case OCLOSURE: case OCLOSURE:

View file

@ -59,7 +59,6 @@ type Name struct {
// The function, method, or closure in which local variable or param is declared. // The function, method, or closure in which local variable or param is declared.
Curfn *Func Curfn *Func
Ntype Ntype
Heapaddr *Name // temp holding heap address of param Heapaddr *Name // temp holding heap address of param
// ONAME closure linkage // ONAME closure linkage

View file

@ -21,7 +21,7 @@ func TestSizeof(t *testing.T) {
_64bit uintptr // size on 64bit platforms _64bit uintptr // size on 64bit platforms
}{ }{
{Func{}, 184, 320}, {Func{}, 184, 320},
{Name{}, 108, 192}, {Name{}, 100, 176},
} }
for _, tt := range tests { for _, tt := range tests {

View file

@ -153,10 +153,6 @@ type itabInfo2 struct {
func setType(n ir.Node, typ *types.Type) { func setType(n ir.Node, typ *types.Type) {
n.SetType(typ) n.SetType(typ)
n.SetTypecheck(1) n.SetTypecheck(1)
if name, ok := n.(*ir.Name); ok {
name.Ntype = ir.TypeNode(name.Type())
}
} }
func setValue(name *ir.Name, val constant.Value) { func setValue(name *ir.Name, val constant.Value) {

View file

@ -16,7 +16,7 @@ import (
var DeclContext ir.Class = ir.PEXTERN // PEXTERN/PAUTO 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 { if tfn.Op() != ir.OTFUNC {
base.Fatalf("expected OTFUNC node, got %v", tfn) 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 = ir.NewNameAt(base.Pos, sym)
fn.Nname.Func = fn fn.Nname.Func = fn
fn.Nname.Defn = fn fn.Nname.Defn = fn
fn.Nname.Ntype = tfn
ir.MarkFunc(fn.Nname) ir.MarkFunc(fn.Nname)
StartFuncBody(fn) StartFuncBody(fn, tfn)
fn.Nname.Ntype = typecheckNtype(fn.Nname.Ntype)
return fn return fn
} }
@ -97,7 +95,7 @@ func Export(n *ir.Name) {
// and declare the arguments. // and declare the arguments.
// called in extern-declaration context // called in extern-declaration context
// returns in auto-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 // change the declaration context from extern to auto
funcStack = append(funcStack, funcStackEnt{ir.CurFunc, DeclContext}) funcStack = append(funcStack, funcStackEnt{ir.CurFunc, DeclContext})
ir.CurFunc = fn ir.CurFunc = fn
@ -105,11 +103,11 @@ func StartFuncBody(fn *ir.Func) {
types.Markdcl() types.Markdcl()
if fn.Nname.Ntype != nil { funcargs(tfn)
funcargs(fn.Nname.Ntype.(*ir.FuncType))
} else { tfn = tcFuncType(tfn)
funcargs2(fn.Type()) fn.Nname.SetType(tfn.Type())
} fn.Nname.SetTypecheck(1)
} }
// finish the body. // finish the body.
@ -202,7 +200,6 @@ func funcarg(n *ir.Field, ctxt ir.Class) {
name := ir.NewNameAt(n.Pos, n.Sym) name := ir.NewNameAt(n.Pos, n.Sym)
n.Decl = name n.Decl = name
name.Ntype = nil
Declare(name, ctxt) Declare(name, ctxt)
} }

View file

@ -270,10 +270,7 @@ func tcFunc(n *ir.Func) {
} }
if name := n.Nname; name.Typecheck() == 0 { if name := n.Nname; name.Typecheck() == 0 {
if name.Ntype != nil { base.AssertfAt(name.Type() != nil, n.Pos(), "missing type: %v", name)
name.Ntype = typecheckNtype(name.Ntype)
name.SetType(name.Ntype.Type())
}
name.SetTypecheck(1) name.SetTypecheck(1)
} }
} }

View file

@ -11,7 +11,7 @@ import (
) )
// tcFuncType typechecks an OTFUNC node. // 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) { misc := func(f *types.Field, nf *ir.Field) {
f.SetIsDDD(nf.IsDDD) f.SetIsDDD(nf.IsDDD)
if nf.Decl != nil { if nf.Decl != nil {