]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: remove OVARDEF and OVARLIVE
authorKeith Randall <khr@golang.org>
Sun, 24 Jul 2022 19:50:07 +0000 (12:50 -0700)
committerKeith Randall <khr@golang.org>
Mon, 22 Aug 2022 18:51:32 +0000 (18:51 +0000)
Neither are currently used. These concepts only need to exist
in the ssa backend (as ssa.OpVarDef and ssa.OpVarLive).

Change-Id: I8d6bd14aa7967b2156e5e9a103b95146e5552f36
Reviewed-on: https://go-review.googlesource.com/c/go/+/419319
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>

src/cmd/compile/internal/ir/expr.go
src/cmd/compile/internal/ir/node.go
src/cmd/compile/internal/ir/op_string.go
src/cmd/compile/internal/ssagen/ssa.go
src/cmd/compile/internal/typecheck/typecheck.go
src/cmd/compile/internal/walk/order.go
src/cmd/compile/internal/walk/stmt.go

index c7bf296bf7ad5b24df3b8a01c41cb5914ed6551f..5171f8643482d3e3514e290c4861dfedb51e99a2 100644 (file)
@@ -734,7 +734,7 @@ func (n *UnaryExpr) SetOp(op Op) {
        case OBITNOT, ONEG, ONOT, OPLUS, ORECV,
                OALIGNOF, OCAP, OCLOSE, OIMAG, OLEN, ONEW,
                OOFFSETOF, OPANIC, OREAL, OSIZEOF,
-               OCHECKNIL, OCFUNC, OIDATA, OITAB, OSPTR, OVARDEF, OVARLIVE:
+               OCHECKNIL, OCFUNC, OIDATA, OITAB, OSPTR:
                n.op = op
        }
 }
index 4f2b66497c18294a8779b25723731ebe37c288dd..9d1c8cbb9be2452bd47d20a7b29886140c6942b0 100644 (file)
@@ -152,7 +152,7 @@ const (
        // Prior to walk, they are: X(Args), where Args is all regular arguments.
        // After walk, if any argument whose evaluation might requires temporary variable,
        // that temporary variable will be pushed to Init, Args will contains an updated
-       // set of arguments. KeepAlive is all OVARLIVE nodes that are attached to OCALLxxx.
+       // set of arguments.
        OCALLFUNC  // X(Args) (function call f(args))
        OCALLMETH  // X(Args) (direct method call x.Method(args))
        OCALLINTER // X(Args) (interface method call x.Method(args))
@@ -288,8 +288,6 @@ const (
        OSPTR          // base pointer of a slice or string.
        OCFUNC         // reference to c function pointer (not go func value)
        OCHECKNIL      // emit code to ensure pointer/interface not nil
-       OVARDEF        // variable is about to be fully initialized
-       OVARLIVE       // variable is alive
        ORESULT        // result of a function call; Xoffset is stack offset
        OINLMARK       // start of an inlined body, with file/line of caller. Xoffset is an index into the inline tree.
        OLINKSYMOFFSET // offset within a name
index 7304cb96b66bd8d53b299bf603a41ab088292081..8ba7c207ce4c8613059662b579e32de5d8f1b647 100644 (file)
@@ -146,25 +146,23 @@ func _() {
        _ = x[OSPTR-135]
        _ = x[OCFUNC-136]
        _ = x[OCHECKNIL-137]
-       _ = x[OVARDEF-138]
-       _ = x[OVARLIVE-139]
-       _ = x[ORESULT-140]
-       _ = x[OINLMARK-141]
-       _ = x[OLINKSYMOFFSET-142]
-       _ = x[OJUMPTABLE-143]
-       _ = x[ODYNAMICDOTTYPE-144]
-       _ = x[ODYNAMICDOTTYPE2-145]
-       _ = x[ODYNAMICTYPE-146]
-       _ = x[OTAILCALL-147]
-       _ = x[OGETG-148]
-       _ = x[OGETCALLERPC-149]
-       _ = x[OGETCALLERSP-150]
-       _ = x[OEND-151]
+       _ = x[ORESULT-138]
+       _ = x[OINLMARK-139]
+       _ = x[OLINKSYMOFFSET-140]
+       _ = x[OJUMPTABLE-141]
+       _ = x[ODYNAMICDOTTYPE-142]
+       _ = x[ODYNAMICDOTTYPE2-143]
+       _ = x[ODYNAMICTYPE-144]
+       _ = x[OTAILCALL-145]
+       _ = x[OGETG-146]
+       _ = x[OGETCALLERPC-147]
+       _ = x[OGETCALLERSP-148]
+       _ = x[OEND-149]
 }
 
-const _Op_name = "XXXNAMENONAMETYPELITERALNILADDSUBORXORADDSTRADDRANDANDAPPENDBYTES2STRBYTES2STRTMPRUNES2STRSTR2BYTESSTR2BYTESTMPSTR2RUNESSLICE2ARRPTRASAS2AS2DOTTYPEAS2FUNCAS2MAPRAS2RECVASOPCALLCALLFUNCCALLMETHCALLINTERCAPCLOSECLOSURECOMPLITMAPLITSTRUCTLITARRAYLITSLICELITPTRLITCONVCONVIFACECONVIDATACONVNOPCOPYDCLDCLFUNCDCLCONSTDCLTYPEDELETEDOTDOTPTRDOTMETHDOTINTERXDOTDOTTYPEDOTTYPE2EQNELTLEGEGTDEREFINDEXINDEXMAPKEYSTRUCTKEYLENMAKEMAKECHANMAKEMAPMAKESLICEMAKESLICECOPYMULDIVMODLSHRSHANDANDNOTNEWNOTBITNOTPLUSNEGORORPANICPRINTPRINTNPARENSENDSLICESLICEARRSLICESTRSLICE3SLICE3ARRSLICEHEADERRECOVERRECOVERFPRECVRUNESTRSELRECV2REALIMAGCOMPLEXALIGNOFOFFSETOFSIZEOFUNSAFEADDUNSAFESLICEMETHEXPRMETHVALUEBLOCKBREAKCASECONTINUEDEFERFALLFORGOTOIFLABELGORANGERETURNSELECTSWITCHTYPESWFUNCINSTINLCALLEFACEITABIDATASPTRCFUNCCHECKNILVARDEFVARLIVERESULTINLMARKLINKSYMOFFSETJUMPTABLEDYNAMICDOTTYPEDYNAMICDOTTYPE2DYNAMICTYPETAILCALLGETGGETCALLERPCGETCALLERSPEND"
+const _Op_name = "XXXNAMENONAMETYPELITERALNILADDSUBORXORADDSTRADDRANDANDAPPENDBYTES2STRBYTES2STRTMPRUNES2STRSTR2BYTESSTR2BYTESTMPSTR2RUNESSLICE2ARRPTRASAS2AS2DOTTYPEAS2FUNCAS2MAPRAS2RECVASOPCALLCALLFUNCCALLMETHCALLINTERCAPCLOSECLOSURECOMPLITMAPLITSTRUCTLITARRAYLITSLICELITPTRLITCONVCONVIFACECONVIDATACONVNOPCOPYDCLDCLFUNCDCLCONSTDCLTYPEDELETEDOTDOTPTRDOTMETHDOTINTERXDOTDOTTYPEDOTTYPE2EQNELTLEGEGTDEREFINDEXINDEXMAPKEYSTRUCTKEYLENMAKEMAKECHANMAKEMAPMAKESLICEMAKESLICECOPYMULDIVMODLSHRSHANDANDNOTNEWNOTBITNOTPLUSNEGORORPANICPRINTPRINTNPARENSENDSLICESLICEARRSLICESTRSLICE3SLICE3ARRSLICEHEADERRECOVERRECOVERFPRECVRUNESTRSELRECV2REALIMAGCOMPLEXALIGNOFOFFSETOFSIZEOFUNSAFEADDUNSAFESLICEMETHEXPRMETHVALUEBLOCKBREAKCASECONTINUEDEFERFALLFORGOTOIFLABELGORANGERETURNSELECTSWITCHTYPESWFUNCINSTINLCALLEFACEITABIDATASPTRCFUNCCHECKNILRESULTINLMARKLINKSYMOFFSETJUMPTABLEDYNAMICDOTTYPEDYNAMICDOTTYPE2DYNAMICTYPETAILCALLGETGGETCALLERPCGETCALLERSPEND"
 
-var _Op_index = [...]uint16{0, 3, 7, 13, 17, 24, 27, 30, 33, 35, 38, 44, 48, 54, 60, 69, 81, 90, 99, 111, 120, 132, 134, 137, 147, 154, 161, 168, 172, 176, 184, 192, 201, 204, 209, 216, 223, 229, 238, 246, 254, 260, 264, 273, 282, 289, 293, 296, 303, 311, 318, 324, 327, 333, 340, 348, 352, 359, 367, 369, 371, 373, 375, 377, 379, 384, 389, 397, 400, 409, 412, 416, 424, 431, 440, 453, 456, 459, 462, 465, 468, 471, 477, 480, 483, 489, 493, 496, 500, 505, 510, 516, 521, 525, 530, 538, 546, 552, 561, 572, 579, 588, 592, 599, 607, 611, 615, 622, 629, 637, 643, 652, 663, 671, 680, 685, 690, 694, 702, 707, 711, 714, 718, 720, 725, 727, 732, 738, 744, 750, 756, 764, 771, 776, 780, 785, 789, 794, 802, 808, 815, 821, 828, 841, 850, 864, 879, 890, 898, 902, 913, 924, 927}
+var _Op_index = [...]uint16{0, 3, 7, 13, 17, 24, 27, 30, 33, 35, 38, 44, 48, 54, 60, 69, 81, 90, 99, 111, 120, 132, 134, 137, 147, 154, 161, 168, 172, 176, 184, 192, 201, 204, 209, 216, 223, 229, 238, 246, 254, 260, 264, 273, 282, 289, 293, 296, 303, 311, 318, 324, 327, 333, 340, 348, 352, 359, 367, 369, 371, 373, 375, 377, 379, 384, 389, 397, 400, 409, 412, 416, 424, 431, 440, 453, 456, 459, 462, 465, 468, 471, 477, 480, 483, 489, 493, 496, 500, 505, 510, 516, 521, 525, 530, 538, 546, 552, 561, 572, 579, 588, 592, 599, 607, 611, 615, 622, 629, 637, 643, 652, 663, 671, 680, 685, 690, 694, 702, 707, 711, 714, 718, 720, 725, 727, 732, 738, 744, 750, 756, 764, 771, 776, 780, 785, 789, 794, 802, 808, 815, 828, 837, 851, 866, 877, 885, 889, 900, 911, 914}
 
 func (i Op) String() string {
        if i >= Op(len(_Op_index)-1) {
index 3e7adeb2ab5ad123ea01a116cc022885a0623cbd..c72cfa5144088351cb4e39fb2ff84348210c6c9a 100644 (file)
@@ -1384,11 +1384,8 @@ func (s *state) stmtList(l ir.Nodes) {
 
 // stmt converts the statement n to SSA and adds it to s.
 func (s *state) stmt(n ir.Node) {
-       if !(n.Op() == ir.OVARLIVE || n.Op() == ir.OVARDEF) {
-               // OVARLIVE and OVARDEF are invisible to the programmer, so we don't use their line numbers to avoid confusion in debugging.
-               s.pushLine(n.Pos())
-               defer s.popLine()
-       }
+       s.pushLine(n.Pos())
+       defer s.popLine()
 
        // If s.curBlock is nil, and n isn't a label (which might have an associated goto somewhere),
        // then this code is dead. Stop here.
@@ -1932,26 +1929,6 @@ func (s *state) stmt(n ir.Node) {
 
                s.startBlock(bEnd)
 
-       case ir.OVARDEF:
-               n := n.(*ir.UnaryExpr)
-               if !s.canSSA(n.X) {
-                       s.vars[memVar] = s.newValue1Apos(ssa.OpVarDef, types.TypeMem, n.X.(*ir.Name), s.mem(), false)
-               }
-
-       case ir.OVARLIVE:
-               // Insert a varlive op to record that a variable is still live.
-               n := n.(*ir.UnaryExpr)
-               v := n.X.(*ir.Name)
-               if !v.Addrtaken() {
-                       s.Fatalf("VARLIVE variable %v must have Addrtaken set", v)
-               }
-               switch v.Class {
-               case ir.PAUTO, ir.PPARAM, ir.PPARAMOUT:
-               default:
-                       s.Fatalf("VARLIVE variable %v must be Auto or Arg", v)
-               }
-               s.vars[memVar] = s.newValue1A(ssa.OpVarLive, types.TypeMem, v, s.mem())
-
        case ir.OCHECKNIL:
                n := n.(*ir.UnaryExpr)
                p := s.expr(n.X)
@@ -5160,9 +5137,17 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
        }
        s.prevCall = call
        s.vars[memVar] = s.newValue1I(ssa.OpSelectN, types.TypeMem, int64(len(ACResults)), call)
-       // Insert OVARLIVE nodes
-       for _, name := range n.KeepAlive {
-               s.stmt(ir.NewUnaryExpr(n.Pos(), ir.OVARLIVE, name))
+       // Insert VarLive opcodes.
+       for _, v := range n.KeepAlive {
+               if !v.Addrtaken() {
+                       s.Fatalf("KeepAlive variable %v must have Addrtaken set", v)
+               }
+               switch v.Class {
+               case ir.PAUTO, ir.PPARAM, ir.PPARAMOUT:
+               default:
+                       s.Fatalf("KeepAlive variable %v must be Auto or Arg", v)
+               }
+               s.vars[memVar] = s.newValue1A(ssa.OpVarLive, types.TypeMem, v, s.mem())
        }
 
        // Finish block for defers
index 26b26182ce7035cd3e889a9fc8f250520137b2ff..632adc7f93acdfc83afeffa6db85667ff12e5344 100644 (file)
@@ -359,7 +359,7 @@ func typecheck(n ir.Node, top int) (res ir.Node) {
        case ir.OAPPEND:
                // Must be used (and not BinaryExpr/UnaryExpr).
                isStmt = false
-       case ir.OCLOSE, ir.ODELETE, ir.OPANIC, ir.OPRINT, ir.OPRINTN, ir.OVARLIVE:
+       case ir.OCLOSE, ir.ODELETE, ir.OPANIC, ir.OPRINT, ir.OPRINTN:
                // Must not be used.
                isExpr = false
                isStmt = true
@@ -749,8 +749,7 @@ func typecheck1(n ir.Node, top int) ir.Node {
                ir.OCONTINUE,
                ir.ODCL,
                ir.OGOTO,
-               ir.OFALL,
-               ir.OVARLIVE:
+               ir.OFALL:
                return n
 
        case ir.OBLOCK:
index 0300985a29f854d70f7fff18744d8cab6a15ee75..d4239347219d90e5c20a06504153298af9e14690 100644 (file)
@@ -597,7 +597,7 @@ func (o *orderState) stmt(n ir.Node) {
        default:
                base.Fatalf("order.stmt %v", n.Op())
 
-       case ir.OVARLIVE, ir.OINLMARK:
+       case ir.OINLMARK:
                o.out = append(o.out, n)
 
        case ir.OAS:
index f0000fc08167bf06465999efa46c53f3cae4d65c..ceee1b1b75ff66b26271ea985cd89fe27d695ebe 100644 (file)
@@ -89,9 +89,7 @@ func walkStmt(n ir.Node) ir.Node {
                ir.ODCL,
                ir.ODCLCONST,
                ir.ODCLTYPE,
-               ir.OCHECKNIL,
-               ir.OVARDEF,
-               ir.OVARLIVE:
+               ir.OCHECKNIL:
                return n
 
        case ir.OBLOCK: