]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: cleanup some leftover cruft
authorMatthew Dempsky <mdempsky@google.com>
Tue, 1 Dec 2020 19:37:30 +0000 (11:37 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 1 Dec 2020 22:09:25 +0000 (22:09 +0000)
Just clearing away some scaffolding artifacts from previous
refactorings.

[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex {
  import "cmd/compile/internal/ir"
  import "cmd/compile/internal/types"

  var n *ir.Name; n.Name() -> n
  var f *ir.Func; f.Func() -> f

  var o types.Object
  ir.AsNode(o).Sym() -> o.Sym()
  ir.AsNode(o).Type() -> o.Type()
  ir.AsNode(o).(*ir.Name) -> o.(*ir.Name)
  ir.AsNode(o).(*ir.Func) -> o.(*ir.Func)

  var x ir.Node
  ir.AsNode(o) != x -> o != x
}
'

Change-Id: I946ec344bd7ee274900a392da53b95308ceaade4
Reviewed-on: https://go-review.googlesource.com/c/go/+/274592
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
14 files changed:
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/escape.go
src/cmd/compile/internal/gc/iexport.go
src/cmd/compile/internal/gc/init.go
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/gc/noder.go
src/cmd/compile/internal/gc/obj.go
src/cmd/compile/internal/gc/pgen.go
src/cmd/compile/internal/gc/reflect.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/typecheck.go
src/cmd/compile/internal/gc/universe.go
src/cmd/compile/internal/gc/walk.go

index 0ba2858b8b4e8df10e6ea0fbcaa2f9d38d179008..e33a561bd4bbdd5ae48258429476e29db432fdf8 100644 (file)
@@ -437,7 +437,7 @@ func makepartialcall(dot ir.Node, t0 *types.Type, meth *types.Sym) *ir.Func {
        sym := methodSymSuffix(rcvrtype, meth, "-fm")
 
        if sym.Uniq() {
-               return ir.AsNode(sym.Def).(*ir.Func)
+               return sym.Def.(*ir.Func)
        }
        sym.SetUniq(true)
 
index 3d0bdaec7a4a1d268ae91253d94219697ad0a76b..dd59d829fedf22d3fd29a7bd30d0e6eb68fde072 100644 (file)
@@ -95,7 +95,7 @@ func declare(n *ir.Name, ctxt ir.Class) {
                        gen = vargen
                }
                types.Pushdcl(s)
-               n.Name().Curfn = Curfn
+               n.Curfn = Curfn
        }
 
        if ctxt == ir.PAUTO {
@@ -113,7 +113,7 @@ func declare(n *ir.Name, ctxt ir.Class) {
        s.Block = types.Block
        s.Lastlineno = base.Pos
        s.Def = n
-       n.Name().Vargen = int32(gen)
+       n.Vargen = int32(gen)
        n.SetClass(ctxt)
        if ctxt == ir.PFUNC {
                n.Sym().SetFunc(true)
@@ -335,7 +335,7 @@ func colasdefn(left []ir.Node, defn ir.Node) {
                nnew++
                n := NewName(n.Sym())
                declare(n, dclcontext)
-               n.Name().Defn = defn
+               n.Defn = defn
                defn.PtrInit().Append(ir.Nod(ir.ODCL, n, nil))
                left[i] = n
        }
@@ -438,7 +438,7 @@ func funcarg(n *ir.Field, ctxt ir.Class) {
        declare(name, ctxt)
 
        vargen++
-       n.Decl.Name().Vargen = int32(vargen)
+       n.Decl.Vargen = int32(vargen)
 }
 
 // Same as funcargs, except run over an already constructed TFUNC.
@@ -837,7 +837,7 @@ func addmethod(n *ir.Func, msym *types.Sym, t *types.Type, local, nointerface bo
        }
 
        f := types.NewField(base.Pos, msym, t)
-       f.Nname = n.Func().Nname
+       f.Nname = n.Nname
        f.SetNointerface(nointerface)
 
        mt.Methods().Append(f)
index b29896e5a48b886bab7c67a799750a5ff1380069..c1397717302d2b3f6d588f6a6f2a7a3dbff3ef73 100644 (file)
@@ -1802,8 +1802,8 @@ func addrescapes(n ir.Node) {
                }
 
                // If a closure reference escapes, mark the outer variable as escaping.
-               if n.Name().IsClosureVar() {
-                       addrescapes(n.Name().Defn)
+               if n.IsClosureVar() {
+                       addrescapes(n.Defn)
                        break
                }
 
@@ -1824,7 +1824,7 @@ func addrescapes(n ir.Node) {
                // then we're analyzing the inner closure but we need to move x to the
                // heap in f, not in the inner closure. Flip over to f before calling moveToHeap.
                oldfn := Curfn
-               Curfn = n.Name().Curfn
+               Curfn = n.Curfn
                ln := base.Pos
                base.Pos = Curfn.Pos()
                moveToHeap(n)
@@ -1893,7 +1893,7 @@ func moveToHeap(n *ir.Name) {
                        // See issue 16095.
                        heapaddr.SetIsOutputParamHeapAddr(true)
                }
-               n.Name().Stackcopy = stackcopy
+               n.Stackcopy = stackcopy
 
                // Substitute the stackcopy into the function variable list so that
                // liveness and other analyses use the underlying stack slot
@@ -1920,7 +1920,7 @@ func moveToHeap(n *ir.Name) {
        // Modify n in place so that uses of n now mean indirection of the heapaddr.
        n.SetClass(ir.PAUTOHEAP)
        n.SetOffset(0)
-       n.Name().Heapaddr = heapaddr
+       n.Heapaddr = heapaddr
        n.SetEsc(EscHeap)
        if base.Flag.LowerM != 0 {
                base.WarnfAt(n.Pos(), "moved to heap: %v", n)
index 8f50868fc793e382972a0e0c462dc3a5ed47cf48..2231f493dd6ef40bc8e2f6329877f117552f6f7a 100644 (file)
@@ -395,7 +395,7 @@ func (p *iexporter) stringOff(s string) uint64 {
 
 // pushDecl adds n to the declaration work queue, if not already present.
 func (p *iexporter) pushDecl(n ir.Node) {
-       if n.Sym() == nil || ir.AsNode(n.Sym().Def) != n && n.Op() != ir.OTYPE {
+       if n.Sym() == nil || n.Sym().Def != n && n.Op() != ir.OTYPE {
                base.Fatalf("weird Sym: %v, %v", n, n.Sym())
        }
 
@@ -988,7 +988,7 @@ func (w *exportWriter) funcExt(n *ir.Name) {
 
 func (w *exportWriter) methExt(m *types.Field) {
        w.bool(m.Nointerface())
-       w.funcExt(ir.AsNode(m.Nname).(*ir.Name))
+       w.funcExt(m.Nname.(*ir.Name))
 }
 
 func (w *exportWriter) linkname(s *types.Sym) {
index b5fd2e7c758d20838765a7f9064247ed72b074ec..e67a032c5d6c64a23126f4721be79c4ea25117d9 100644 (file)
@@ -60,7 +60,7 @@ func fninit(n []ir.Node) {
                initializers := lookup("init")
                fn := dclfunc(initializers, ir.NewFuncType(base.Pos, nil, nil, nil))
                for _, dcl := range initTodo.Dcl {
-                       dcl.Name().Curfn = fn
+                       dcl.Curfn = fn
                }
                fn.Dcl = append(fn.Dcl, initTodo.Dcl...)
                initTodo.Dcl = nil
index 718239484b7c37f19514e7e1c22bb7025d0c1743..96031fe51149018f5baae8d88c8ead00cc9ffce0 100644 (file)
@@ -984,7 +984,7 @@ func clearImports() {
 }
 
 func IsAlias(sym *types.Sym) bool {
-       return sym.Def != nil && ir.AsNode(sym.Def).Sym() != sym
+       return sym.Def != nil && sym.Def.Sym() != sym
 }
 
 // recordFlags records the specified command-line flags to be placed
index 1340068c722c0d2d1d57253e6aa0b73c32a336bf..de7dcda15eaeb0296fdfbcdecac41defe20d97a0 100644 (file)
@@ -1071,7 +1071,7 @@ func (p *noder) stmtFall(stmt syntax.Stmt, fallOK bool) ir.Node {
                                if ln.Class() != ir.PPARAMOUT {
                                        break
                                }
-                               if ir.AsNode(ln.Sym().Def) != ln {
+                               if ln.Sym().Def != ln {
                                        base.Errorf("%s is shadowed during return", ln.Sym().Name)
                                }
                        }
index f65131417a38a9ddf9d0fa8dbafd4e137aa01905..21a50257b88a2cf1f659f314e4e00a37eb836977 100644 (file)
@@ -220,10 +220,10 @@ func addptabs() {
                }
                if n.Type().Kind() == types.TFUNC && n.Class() == ir.PFUNC {
                        // function
-                       ptabs = append(ptabs, ptabEntry{s: s, t: ir.AsNode(s.Def).Type()})
+                       ptabs = append(ptabs, ptabEntry{s: s, t: s.Def.Type()})
                } else {
                        // variable
-                       ptabs = append(ptabs, ptabEntry{s: s, t: types.NewPtr(ir.AsNode(s.Def).Type())})
+                       ptabs = append(ptabs, ptabEntry{s: s, t: types.NewPtr(s.Def.Type())})
                }
        }
 }
index ea294ed66d5f4d3f6f9491bba4b186bb11c823aa..1da09292906263288f193ed71c7416d7d0e71d24 100644 (file)
@@ -77,8 +77,8 @@ func cmpstackvarlt(a, b *ir.Name) bool {
                return a.Offset() < b.Offset()
        }
 
-       if a.Name().Used() != b.Name().Used() {
-               return a.Name().Used()
+       if a.Used() != b.Used() {
+               return a.Used()
        }
 
        ap := a.Type().HasPointers()
@@ -87,8 +87,8 @@ func cmpstackvarlt(a, b *ir.Name) bool {
                return ap
        }
 
-       ap = a.Name().Needzero()
-       bp = b.Name().Needzero()
+       ap = a.Needzero()
+       bp = b.Needzero()
        if ap != bp {
                return ap
        }
@@ -115,7 +115,7 @@ func (s *ssafn) AllocFrame(f *ssa.Func) {
        // Mark the PAUTO's unused.
        for _, ln := range fn.Dcl {
                if ln.Class() == ir.PAUTO {
-                       ln.Name().SetUsed(false)
+                       ln.SetUsed(false)
                }
        }
 
@@ -158,7 +158,7 @@ func (s *ssafn) AllocFrame(f *ssa.Func) {
                if n.Op() != ir.ONAME || n.Class() != ir.PAUTO {
                        continue
                }
-               if !n.Name().Used() {
+               if !n.Used() {
                        fn.Dcl = fn.Dcl[:i]
                        break
                }
@@ -260,7 +260,7 @@ func compile(fn *ir.Func) {
        for _, n := range fn.Dcl {
                switch n.Class() {
                case ir.PPARAM, ir.PPARAMOUT, ir.PAUTO:
-                       if livenessShouldTrack(n) && n.Name().Addrtaken() {
+                       if livenessShouldTrack(n) && n.Addrtaken() {
                                dtypesym(n.Type())
                                // Also make sure we allocate a linker symbol
                                // for the stack object data, for the same reason.
@@ -447,7 +447,7 @@ func debuginfo(fnsym *obj.LSym, infosym *obj.LSym, curfn interface{}) ([]dwarf.S
                        }
                        switch n.Class() {
                        case ir.PAUTO:
-                               if !n.Name().Used() {
+                               if !n.Used() {
                                        // Text == nil -> generating abstract function
                                        if fnsym.Func().Text != nil {
                                                base.Fatalf("debuginfo unused node (AllocFrame should truncate fn.Func.Dcl)")
index 4ab3005ce82115fcd3930de770b12631d9e4a2f6..06b91ddae64bc1f997c322e07bbc9ecf15df03b4 100644 (file)
@@ -1001,7 +1001,7 @@ func typename(t *types.Type) ir.Node {
        }
 
        n := ir.Nod(ir.OADDR, ir.AsNode(s.Def), nil)
-       n.SetType(types.NewPtr(ir.AsNode(s.Def).Type()))
+       n.SetType(types.NewPtr(s.Def.Type()))
        n.SetTypecheck(1)
        return n
 }
@@ -1021,7 +1021,7 @@ func itabname(t, itype *types.Type) ir.Node {
        }
 
        n := ir.Nod(ir.OADDR, ir.AsNode(s.Def), nil)
-       n.SetType(types.NewPtr(ir.AsNode(s.Def).Type()))
+       n.SetType(types.NewPtr(s.Def.Type()))
        n.SetTypecheck(1)
        return n
 }
index 3e020d7b9269bc1055e717b01ba9e6e127cf4223..60e65e4b11c922cb4cfa0c373cfaffa3080ba881 100644 (file)
@@ -6196,7 +6196,7 @@ func (s byXoffset) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
 func emitStackObjects(e *ssafn, pp *Progs) {
        var vars []ir.Node
        for _, n := range e.curfn.Dcl {
-               if livenessShouldTrack(n) && n.Name().Addrtaken() {
+               if livenessShouldTrack(n) && n.Addrtaken() {
                        vars = append(vars, n)
                }
        }
@@ -6583,7 +6583,7 @@ func defframe(s *SSAGenState, e *ssafn) {
 
        // Iterate through declarations. They are sorted in decreasing Xoffset order.
        for _, n := range e.curfn.Dcl {
-               if !n.Name().Needzero() {
+               if !n.Needzero() {
                        continue
                }
                if n.Class() != ir.PAUTO {
index f120b4441323f2698bfd28642badf08108a4924f..20ef3fc70a7dbfbb3e68463129bdacd8864a4b5a 100644 (file)
@@ -2493,7 +2493,7 @@ func lookdot(n ir.Node, t *types.Type, dostrcmp int) *types.Field {
                        pll = ll
                        ll = ll.Left()
                }
-               if pll.Implicit() && ll.Type().IsPtr() && ll.Type().Sym() != nil && ir.AsNode(ll.Type().Sym().Def) != nil && ir.AsNode(ll.Type().Sym().Def).Op() == ir.OTYPE {
+               if pll.Implicit() && ll.Type().IsPtr() && ll.Type().Sym() != nil && ll.Type().Sym().Def != nil && ir.AsNode(ll.Type().Sym().Def).Op() == ir.OTYPE {
                        // It is invalid to automatically dereference a named pointer type when selecting a method.
                        // Make n.Left == ll to clarify error message.
                        n.SetLeft(ll)
@@ -3369,7 +3369,7 @@ func typecheckfunc(n *ir.Func) {
 
        for _, ln := range n.Dcl {
                if ln.Op() == ir.ONAME && (ln.Class() == ir.PPARAM || ln.Class() == ir.PPARAMOUT) {
-                       ln.Name().Decldepth = 1
+                       ln.Decldepth = 1
                }
        }
 
@@ -3923,7 +3923,7 @@ func curpkg() *types.Pkg {
 // referenced by expression n, which must be a method selector,
 // method expression, or method value.
 func methodExprName(n ir.Node) *ir.Name {
-       name, _ := ir.AsNode(methodExprFunc(n).Nname).(*ir.Name)
+       name, _ := methodExprFunc(n).Nname.(*ir.Name)
        return name
 }
 
index 49e50734c6a66566dbe86a29cb9ef0c096004115..b554674fbc6865c1357c22d1762295fab6a3115e 100644 (file)
@@ -358,5 +358,5 @@ func finishUniverse() {
        nodfp = NewName(lookup(".fp"))
        nodfp.SetType(types.Types[types.TINT32])
        nodfp.SetClass(ir.PPARAM)
-       nodfp.Name().SetUsed(true)
+       nodfp.SetUsed(true)
 }
index b3af353c3fbce764c304ab5606531b1878f000b2..be6f1539b93cd4289ba78295cb0a6e9d59ab1382 100644 (file)
@@ -43,16 +43,16 @@ func walk(fn *ir.Func) {
 
        // Propagate the used flag for typeswitch variables up to the NONAME in its definition.
        for _, ln := range fn.Dcl {
-               if ln.Op() == ir.ONAME && (ln.Class() == ir.PAUTO || ln.Class() == ir.PAUTOHEAP) && ln.Name().Defn != nil && ln.Name().Defn.Op() == ir.OTYPESW && ln.Name().Used() {
-                       ln.Name().Defn.Left().Name().SetUsed(true)
+               if ln.Op() == ir.ONAME && (ln.Class() == ir.PAUTO || ln.Class() == ir.PAUTOHEAP) && ln.Defn != nil && ln.Defn.Op() == ir.OTYPESW && ln.Used() {
+                       ln.Defn.Left().Name().SetUsed(true)
                }
        }
 
        for _, ln := range fn.Dcl {
-               if ln.Op() != ir.ONAME || (ln.Class() != ir.PAUTO && ln.Class() != ir.PAUTOHEAP) || ln.Sym().Name[0] == '&' || ln.Name().Used() {
+               if ln.Op() != ir.ONAME || (ln.Class() != ir.PAUTO && ln.Class() != ir.PAUTOHEAP) || ln.Sym().Name[0] == '&' || ln.Used() {
                        continue
                }
-               if defn := ln.Name().Defn; defn != nil && defn.Op() == ir.OTYPESW {
+               if defn := ln.Defn; defn != nil && defn.Op() == ir.OTYPESW {
                        if defn.Left().Name().Used() {
                                continue
                        }
@@ -91,7 +91,7 @@ func paramoutheap(fn *ir.Func) bool {
        for _, ln := range fn.Dcl {
                switch ln.Class() {
                case ir.PPARAMOUT:
-                       if isParamStackCopy(ln) || ln.Name().Addrtaken() {
+                       if isParamStackCopy(ln) || ln.Addrtaken() {
                                return true
                        }