]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: rewrite Aux uses of ir.Node to *ir.Name [generated]
authorMatthew Dempsky <mdempsky@google.com>
Mon, 7 Dec 2020 02:13:43 +0000 (18:13 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 8 Dec 2020 01:46:57 +0000 (01:46 +0000)
Now that the only remaining ir.Node implementation that is stored
(directly) into ssa.Aux, we can rewrite all of the conversions between
ir.Node and ssa.Aux to use *ir.Name instead.

rf doesn't have a way to rewrite the type switch case clauses, so we
just use sed instead. There's only a handful, and they're the only
times that "case ir.Node" appears anyway.

The next CL will move the tag method declarations so that ir.Node no
longer implements ssa.Aux.

Passes buildall w/ toolstash -cmp.

Updates #42982.

[git-generate]
cd src/cmd/compile/internal
sed -i -e 's/case ir.Node/case *ir.Name/' gc/plive.go */ssa.go

cd ssa
rf '
ex . ../gc {
  import "cmd/compile/internal/ir"

  var v *Value
  v.Aux.(ir.Node) -> v.Aux.(*ir.Name)

  var n ir.Node
  var asAux func(Aux)
  strict n        # only match ir.Node-typed expressions; not *ir.Name
  implicit asAux  # match implicit assignments to ssa.Aux
  asAux(n)        -> n.(*ir.Name)
}
'

Change-Id: I3206ef5f12a7cfa37c5fecc67a1ca02ea4d52b32
Reviewed-on: https://go-review.googlesource.com/c/go/+/275789
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
13 files changed:
src/cmd/compile/internal/arm/ssa.go
src/cmd/compile/internal/arm64/ssa.go
src/cmd/compile/internal/gc/pgen.go
src/cmd/compile/internal/gc/plive.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/mips/ssa.go
src/cmd/compile/internal/mips64/ssa.go
src/cmd/compile/internal/riscv64/ssa.go
src/cmd/compile/internal/ssa/deadstore.go
src/cmd/compile/internal/ssa/debug.go
src/cmd/compile/internal/ssa/nilcheck.go
src/cmd/compile/internal/ssa/regalloc.go
src/cmd/compile/internal/wasm/ssa.go

index b34e2973b24d87cd892ee774f91b04f861f6f23c..8b155712aa80abdf72743b074309ed3cfa10e163 100644 (file)
@@ -546,7 +546,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                case *obj.LSym:
                        wantreg = "SB"
                        gc.AddAux(&p.From, v)
-               case ir.Node:
+               case *ir.Name:
                        wantreg = "SP"
                        gc.AddAux(&p.From, v)
                case nil:
index d5bd9687cfa7b694ce4d9bf88cb7d0d0b6d2f973..3eb0ae65573b308dbade3a8014480e660afa2d92 100644 (file)
@@ -396,7 +396,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                case *obj.LSym:
                        wantreg = "SB"
                        gc.AddAux(&p.From, v)
-               case ir.Node:
+               case *ir.Name:
                        wantreg = "SP"
                        gc.AddAux(&p.From, v)
                case nil:
index 1da09292906263288f193ed71c7416d7d0e71d24..a7b19953ba8974a5e68a37d018dac445c1d97cf6 100644 (file)
@@ -128,7 +128,7 @@ func (s *ssafn) AllocFrame(f *ssa.Func) {
        scratchUsed := false
        for _, b := range f.Blocks {
                for _, v := range b.Values {
-                       if n, ok := v.Aux.(ir.Node); ok {
+                       if n, ok := v.Aux.(*ir.Name); ok {
                                switch n.Class() {
                                case ir.PPARAM, ir.PPARAMOUT:
                                        // Don't modify nodfp; it is a global.
index 06e423daa1b6317bc3a34358242fb96eb4323336..9952bfcf366776362c067b9d17563ea7dfd237fa 100644 (file)
@@ -324,9 +324,9 @@ func affectedNode(v *ssa.Value) (ir.Node, ssa.SymEffect) {
                return n, ssa.SymWrite
 
        case ssa.OpVarLive:
-               return v.Aux.(ir.Node), ssa.SymRead
+               return v.Aux.(*ir.Name), ssa.SymRead
        case ssa.OpVarDef, ssa.OpVarKill:
-               return v.Aux.(ir.Node), ssa.SymWrite
+               return v.Aux.(*ir.Name), ssa.SymWrite
        case ssa.OpKeepAlive:
                n, _ := AutoVar(v.Args[0])
                return n, ssa.SymRead
@@ -341,7 +341,7 @@ func affectedNode(v *ssa.Value) (ir.Node, ssa.SymEffect) {
        case nil, *obj.LSym:
                // ok, but no node
                return nil, e
-       case ir.Node:
+       case *ir.Name:
                return a, e
        default:
                base.Fatalf("weird aux: %s", v.LongString())
index 90c754604299c528407d3cb5e9475eed7a5b187c..e8f345d8f686c314cfd3150adf044fc81a118280 100644 (file)
@@ -1504,7 +1504,7 @@ func (s *state) stmt(n ir.Node) {
 
        case ir.OVARDEF:
                if !s.canSSA(n.Left()) {
-                       s.vars[memVar] = s.newValue1Apos(ssa.OpVarDef, types.TypeMem, n.Left(), s.mem(), false)
+                       s.vars[memVar] = s.newValue1Apos(ssa.OpVarDef, types.TypeMem, n.Left().(*ir.Name), s.mem(), false)
                }
        case ir.OVARKILL:
                // Insert a varkill op to record that a variable is no longer live.
@@ -1512,7 +1512,7 @@ func (s *state) stmt(n ir.Node) {
                // varkill in the store chain is enough to keep it correctly ordered
                // with respect to call ops.
                if !s.canSSA(n.Left()) {
-                       s.vars[memVar] = s.newValue1Apos(ssa.OpVarKill, types.TypeMem, n.Left(), s.mem(), false)
+                       s.vars[memVar] = s.newValue1Apos(ssa.OpVarKill, types.TypeMem, n.Left().(*ir.Name), s.mem(), false)
                }
 
        case ir.OVARLIVE:
@@ -1525,7 +1525,7 @@ func (s *state) stmt(n ir.Node) {
                default:
                        s.Fatalf("VARLIVE variable %v must be Auto or Arg", n.Left())
                }
-               s.vars[memVar] = s.newValue1A(ssa.OpVarLive, types.TypeMem, n.Left(), s.mem())
+               s.vars[memVar] = s.newValue1A(ssa.OpVarLive, types.TypeMem, n.Left().(*ir.Name), s.mem())
 
        case ir.OCHECKNIL:
                p := s.expr(n.Left())
@@ -1571,7 +1571,7 @@ func (s *state) exit() *ssa.Block {
        for _, n := range s.returns {
                addr := s.decladdrs[n]
                val := s.variable(n, n.Type())
-               s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, n, s.mem())
+               s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, n.(*ir.Name), s.mem())
                s.store(n.Type(), addr, val)
                // TODO: if val is ever spilled, we'd like to use the
                // PPARAMOUT slot for spilling it. That won't happen
@@ -2866,7 +2866,7 @@ func (s *state) append(n ir.Node, inplace bool) *ssa.Value {
        if inplace {
                if sn.Op() == ir.ONAME && sn.Class() != ir.PEXTERN {
                        // Tell liveness we're about to build a new slice
-                       s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, sn, s.mem())
+                       s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, sn.(*ir.Name), s.mem())
                }
                capaddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, sliceCapOffset, addr)
                s.store(types.Types[types.TINT], capaddr, r[2])
@@ -3076,7 +3076,7 @@ func (s *state) assign(left ir.Node, right *ssa.Value, deref bool, skip skipMask
        // If this assignment clobbers an entire local variable, then emit
        // OpVarDef so liveness analysis knows the variable is redefined.
        if base := clobberBase(left); base.Op() == ir.ONAME && base.Class() != ir.PEXTERN && skip == 0 {
-               s.vars[memVar] = s.newValue1Apos(ssa.OpVarDef, types.TypeMem, base, s.mem(), !ir.IsAutoTmp(base))
+               s.vars[memVar] = s.newValue1Apos(ssa.OpVarDef, types.TypeMem, base.(*ir.Name), s.mem(), !ir.IsAutoTmp(base))
        }
 
        // Left is not ssa-able. Compute its address.
@@ -4236,7 +4236,7 @@ func (s *state) openDeferRecord(n ir.Node) {
                // call the function directly if it is a static function.
                closureVal := s.expr(fn)
                closure := s.openDeferSave(nil, fn.Type(), closureVal)
-               opendefer.closureNode = closure.Aux.(ir.Node)
+               opendefer.closureNode = closure.Aux.(*ir.Name)
                if !(fn.Op() == ir.ONAME && fn.Class() == ir.PFUNC) {
                        opendefer.closure = closure
                }
@@ -4249,7 +4249,7 @@ func (s *state) openDeferRecord(n ir.Node) {
                // runtime panic code to use. But in the defer exit code, we will
                // call the method directly.
                closure := s.openDeferSave(nil, fn.Type(), closureVal)
-               opendefer.closureNode = closure.Aux.(ir.Node)
+               opendefer.closureNode = closure.Aux.(*ir.Name)
        } else {
                if fn.Op() != ir.ODOTINTER {
                        base.Fatalf("OCALLINTER: n.Left not an ODOTINTER: %v", fn.Op())
@@ -4259,8 +4259,8 @@ func (s *state) openDeferRecord(n ir.Node) {
                // Important to get the receiver type correct, so it is recognized
                // as a pointer for GC purposes.
                opendefer.rcvr = s.openDeferSave(nil, fn.Type().Recv().Type, rcvr)
-               opendefer.closureNode = opendefer.closure.Aux.(ir.Node)
-               opendefer.rcvrNode = opendefer.rcvr.Aux.(ir.Node)
+               opendefer.closureNode = opendefer.closure.Aux.(*ir.Name)
+               opendefer.rcvrNode = opendefer.rcvr.Aux.(*ir.Name)
        }
        for _, argn := range n.Rlist().Slice() {
                var v *ssa.Value
@@ -4270,7 +4270,7 @@ func (s *state) openDeferRecord(n ir.Node) {
                        v = s.openDeferSave(argn, argn.Type(), nil)
                }
                args = append(args, v)
-               argNodes = append(argNodes, v.Aux.(ir.Node))
+               argNodes = append(argNodes, v.Aux.(*ir.Name))
        }
        opendefer.argVals = args
        opendefer.argNodes = argNodes
@@ -4458,16 +4458,16 @@ func (s *state) openDeferExit() {
                // use the first call of the last defer exit to compute liveness
                // for the deferreturn, so we want all stack slots to be live.
                if r.closureNode != nil {
-                       s.vars[memVar] = s.newValue1Apos(ssa.OpVarLive, types.TypeMem, r.closureNode, s.mem(), false)
+                       s.vars[memVar] = s.newValue1Apos(ssa.OpVarLive, types.TypeMem, r.closureNode.(*ir.Name), s.mem(), false)
                }
                if r.rcvrNode != nil {
                        if r.rcvrNode.Type().HasPointers() {
-                               s.vars[memVar] = s.newValue1Apos(ssa.OpVarLive, types.TypeMem, r.rcvrNode, s.mem(), false)
+                               s.vars[memVar] = s.newValue1Apos(ssa.OpVarLive, types.TypeMem, r.rcvrNode.(*ir.Name), s.mem(), false)
                        }
                }
                for _, argNode := range r.argNodes {
                        if argNode.Type().HasPointers() {
-                               s.vars[memVar] = s.newValue1Apos(ssa.OpVarLive, types.TypeMem, argNode, s.mem(), false)
+                               s.vars[memVar] = s.newValue1Apos(ssa.OpVarLive, types.TypeMem, argNode.(*ir.Name), s.mem(), false)
                        }
                }
 
@@ -4855,17 +4855,17 @@ func (s *state) addr(n ir.Node) *ssa.Value {
                        }
                        if n == nodfp {
                                // Special arg that points to the frame pointer (Used by ORECOVER).
-                               return s.entryNewValue2A(ssa.OpLocalAddr, t, n, s.sp, s.startmem)
+                               return s.entryNewValue2A(ssa.OpLocalAddr, t, n.(*ir.Name), s.sp, s.startmem)
                        }
                        s.Fatalf("addr of undeclared ONAME %v. declared: %v", n, s.decladdrs)
                        return nil
                case ir.PAUTO:
-                       return s.newValue2Apos(ssa.OpLocalAddr, t, n, s.sp, s.mem(), !ir.IsAutoTmp(n))
+                       return s.newValue2Apos(ssa.OpLocalAddr, t, n.(*ir.Name), s.sp, s.mem(), !ir.IsAutoTmp(n))
 
                case ir.PPARAMOUT: // Same as PAUTO -- cannot generate LEA early.
                        // ensure that we reuse symbols for out parameters so
                        // that cse works on their addresses
-                       return s.newValue2Apos(ssa.OpLocalAddr, t, n, s.sp, s.mem(), true)
+                       return s.newValue2Apos(ssa.OpLocalAddr, t, n.(*ir.Name), s.sp, s.mem(), true)
                default:
                        s.Fatalf("variable address class %v not implemented", n.Class())
                        return nil
@@ -5951,7 +5951,7 @@ func (s *state) dottype(n ir.Node, commaok bool) (res, resok *ssa.Value) {
                // unSSAable type, use temporary.
                // TODO: get rid of some of these temporaries.
                tmp = tempAt(n.Pos(), s.curfn, n.Type())
-               s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, tmp, s.mem())
+               s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, tmp.(*ir.Name), s.mem())
                addr = s.addr(tmp)
        }
 
@@ -6027,7 +6027,7 @@ func (s *state) dottype(n ir.Node, commaok bool) (res, resok *ssa.Value) {
                delete(s.vars, valVar)
        } else {
                res = s.load(n.Type(), addr)
-               s.vars[memVar] = s.newValue1A(ssa.OpVarKill, types.TypeMem, tmp, s.mem())
+               s.vars[memVar] = s.newValue1A(ssa.OpVarKill, types.TypeMem, tmp.(*ir.Name), s.mem())
        }
        resok = s.variable(okVar, types.Types[types.TBOOL])
        delete(s.vars, okVar)
@@ -6680,7 +6680,7 @@ func AddAux2(a *obj.Addr, v *ssa.Value, offset int64) {
        case *obj.LSym:
                a.Name = obj.NAME_EXTERN
                a.Sym = n
-       case ir.Node:
+       case *ir.Name:
                if n.Class() == ir.PPARAM || n.Class() == ir.PPARAMOUT {
                        a.Name = obj.NAME_PARAM
                        a.Sym = ir.Orig(n).Sym().Linksym()
index bd71b2fcd874f1ea443bf921dde6cc1593979e92..10453c27d5f83b227a86b9d0d2606d52f55836f1 100644 (file)
@@ -289,7 +289,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                case *obj.LSym:
                        wantreg = "SB"
                        gc.AddAux(&p.From, v)
-               case ir.Node:
+               case *ir.Name:
                        wantreg = "SP"
                        gc.AddAux(&p.From, v)
                case nil:
index bcadebde4e7cb8c12f5e4e6d64afa183572e2b07..9aaf8715de3f76ce2f0e4aaf291b320e7013c90f 100644 (file)
@@ -263,7 +263,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                case *obj.LSym:
                        wantreg = "SB"
                        gc.AddAux(&p.From, v)
-               case ir.Node:
+               case *ir.Name:
                        wantreg = "SP"
                        gc.AddAux(&p.From, v)
                case nil:
index c81b6897a6bf6389c717fe1a1629bfb2bd1bd6fa..d382304d72e79dc28c4f8b48532c2d7370c873e4 100644 (file)
@@ -324,7 +324,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                case *obj.LSym:
                        wantreg = "SB"
                        gc.AddAux(&p.From, v)
-               case ir.Node:
+               case *ir.Name:
                        wantreg = "SP"
                        gc.AddAux(&p.From, v)
                case nil:
index f3ef33d67040e1a4094168b6ba0b3b831550753a..d0446a0311b5273a563b1a953e3c641df1828364 100644 (file)
@@ -147,7 +147,7 @@ func elimDeadAutosGeneric(f *Func) {
                switch v.Op {
                case OpAddr, OpLocalAddr:
                        // Propagate the address if it points to an auto.
-                       n, ok := v.Aux.(ir.Node)
+                       n, ok := v.Aux.(*ir.Name)
                        if !ok || n.Class() != ir.PAUTO {
                                return
                        }
@@ -158,7 +158,7 @@ func elimDeadAutosGeneric(f *Func) {
                        return
                case OpVarDef, OpVarKill:
                        // v should be eliminated if we eliminate the auto.
-                       n, ok := v.Aux.(ir.Node)
+                       n, ok := v.Aux.(*ir.Name)
                        if !ok || n.Class() != ir.PAUTO {
                                return
                        }
@@ -174,7 +174,7 @@ func elimDeadAutosGeneric(f *Func) {
                        // for open-coded defers from being removed (since they
                        // may not be used by the inline code, but will be used by
                        // panic processing).
-                       n, ok := v.Aux.(ir.Node)
+                       n, ok := v.Aux.(*ir.Name)
                        if !ok || n.Class() != ir.PAUTO {
                                return
                        }
@@ -303,7 +303,7 @@ func elimUnreadAutos(f *Func) {
        var stores []*Value
        for _, b := range f.Blocks {
                for _, v := range b.Values {
-                       n, ok := v.Aux.(ir.Node)
+                       n, ok := v.Aux.(*ir.Name)
                        if !ok {
                                continue
                        }
@@ -335,7 +335,7 @@ func elimUnreadAutos(f *Func) {
 
        // Eliminate stores to unread autos.
        for _, store := range stores {
-               n, _ := store.Aux.(ir.Node)
+               n, _ := store.Aux.(*ir.Name)
                if seen[n] {
                        continue
                }
index 6123978e55ca94ac2214727a96cc439f1ed918ce..405817dbe15290b9359aebcccb5ad803a6316491 100644 (file)
@@ -718,7 +718,7 @@ func (state *debugState) processValue(v *Value, vSlots []SlotID, vReg *Register)
 
        switch {
        case v.Op == OpVarDef, v.Op == OpVarKill:
-               n := v.Aux.(ir.Node)
+               n := v.Aux.(*ir.Name)
                if ir.IsSynthetic(n) {
                        break
                }
index b36f6b97e18c75160c30e80a0ca5a5575a6a72f9..bae50657c9adc08311759abe4eb37e2a617c7a3e 100644 (file)
@@ -236,7 +236,7 @@ func nilcheckelim2(f *Func) {
                                continue
                        }
                        if v.Type.IsMemory() || v.Type.IsTuple() && v.Type.FieldType(1).IsMemory() {
-                               if v.Op == OpVarKill || v.Op == OpVarLive || (v.Op == OpVarDef && !v.Aux.(ir.Node).Type().HasPointers()) {
+                               if v.Op == OpVarKill || v.Op == OpVarLive || (v.Op == OpVarDef && !v.Aux.(*ir.Name).Type().HasPointers()) {
                                        // These ops don't really change memory.
                                        continue
                                        // Note: OpVarDef requires that the defined variable not have pointers.
index 376ca975123c904ebcf8b40a99f158cf5938c53c..8c25b1c81dc0c45bafd1d480b697171b7cd17340 100644 (file)
@@ -1249,7 +1249,7 @@ func (s *regAllocState) regalloc(f *Func) {
                                        // This forces later liveness analysis to make the
                                        // value live at this point.
                                        v.SetArg(0, s.makeSpill(a, b))
-                               } else if _, ok := a.Aux.(ir.Node); ok && vi.rematerializeable {
+                               } else if _, ok := a.Aux.(*ir.Name); ok && vi.rematerializeable {
                                        // Rematerializeable value with a gc.Node. This is the address of
                                        // a stack object (e.g. an LEAQ). Keep the object live.
                                        // Change it to VarLive, which is what plive expects for locals.
index e7451381b4abea83fcd409de1e183a82cc7246c1..01ba721556d73d0ea336ef2b533607f948930aff 100644 (file)
@@ -237,7 +237,7 @@ func ssaGenValueOnStack(s *gc.SSAGenState, v *ssa.Value, extend bool) {
                switch v.Aux.(type) {
                case *obj.LSym:
                        gc.AddAux(&p.From, v)
-               case ir.Node:
+               case *ir.Name:
                        p.From.Reg = v.Args[0].Reg()
                        gc.AddAux(&p.From, v)
                default: