]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: remove OCLOSUREREAD
authorMatthew Dempsky <mdempsky@google.com>
Tue, 5 Jan 2021 00:33:30 +0000 (16:33 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Sun, 10 Jan 2021 08:02:23 +0000 (08:02 +0000)
After the previous CLs, all closure reads are handled during SSA
construction.

Change-Id: Iad67b01fa2d3798f50ea647be7ccf8195f189c27
Reviewed-on: https://go-review.googlesource.com/c/go/+/281512
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>
src/cmd/compile/internal/escape/escape.go
src/cmd/compile/internal/ir/expr.go
src/cmd/compile/internal/ir/node.go
src/cmd/compile/internal/ir/node_gen.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/expr.go
src/cmd/compile/internal/walk/walk.go

index 9b9b8f6a5870c0b4144c94a3bf753afdc65a55e3..c63383af43a9f6156793be7b05c4d4e54062cb39 100644 (file)
@@ -575,7 +575,7 @@ func (e *escape) exprSkipInit(k hole, n ir.Node) {
        default:
                base.Fatalf("unexpected expr: %v", n)
 
-       case ir.OLITERAL, ir.ONIL, ir.OGETG, ir.OCLOSUREREAD, ir.OTYPE, ir.OMETHEXPR:
+       case ir.OLITERAL, ir.ONIL, ir.OGETG, ir.OTYPE, ir.OMETHEXPR:
                // nop
 
        case ir.ONAME:
@@ -1926,7 +1926,7 @@ func mayAffectMemory(n ir.Node) bool {
        // an ir.Any looking for any op that's not the ones in the case statement.
        // But that produces changes in the compiled output detected by buildall.
        switch n.Op() {
-       case ir.ONAME, ir.OCLOSUREREAD, ir.OLITERAL, ir.ONIL:
+       case ir.ONAME, ir.OLITERAL, ir.ONIL:
                return false
 
        case ir.OADD, ir.OSUB, ir.OOR, ir.OXOR, ir.OMUL, ir.OLSH, ir.ORSH, ir.OAND, ir.OANDNOT, ir.ODIV, ir.OMOD:
index e7aa9c6a8f06d572aff3c9e1536a1f237ac1778d..51425db42d43100d18cfca75d2fc6a135fdff4cd 100644 (file)
@@ -203,19 +203,6 @@ func NewClosureExpr(pos src.XPos, fn *Func) *ClosureExpr {
        return n
 }
 
-// A ClosureRead denotes reading a variable stored within a closure struct.
-type ClosureReadExpr struct {
-       miniExpr
-       Offset int64
-}
-
-func NewClosureRead(typ *types.Type, offset int64) *ClosureReadExpr {
-       n := &ClosureReadExpr{Offset: offset}
-       n.typ = typ
-       n.op = OCLOSUREREAD
-       return n
-}
-
 // A CompLitExpr is a composite literal Type{Vals}.
 // Before type-checking, the type is Ntype.
 type CompLitExpr struct {
@@ -727,7 +714,7 @@ func IsAddressable(n Node) bool {
                        return false
                }
                fallthrough
-       case ODEREF, ODOTPTR, OCLOSUREREAD:
+       case ODEREF, ODOTPTR:
                return true
 
        case ODOT:
@@ -889,7 +876,7 @@ func SameSafeExpr(l Node, r Node) bool {
        }
 
        switch l.Op() {
-       case ONAME, OCLOSUREREAD:
+       case ONAME:
                return l == r
 
        case ODOT, ODOTPTR:
index 850d7343aaef189ff8f96505172e27577986ce23..a2b6e7203b35d210fb022809bda3180b8ce1f895 100644 (file)
@@ -294,20 +294,19 @@ const (
        OTSLICE // []int
 
        // misc
-       OINLCALL     // intermediary representation of an inlined call.
-       OEFACE       // itable and data words of an empty-interface value.
-       OITAB        // itable word of an interface value.
-       OIDATA       // data word of an interface value in Left
-       OSPTR        // base pointer of a slice or string.
-       OCLOSUREREAD // read from inside closure struct at beginning of closure function
-       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
-       OVARKILL     // variable is dead
-       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.
-       ONAMEOFFSET  // offset within a name
+       OINLCALL    // intermediary representation of an inlined call.
+       OEFACE      // itable and data words of an empty-interface value.
+       OITAB       // itable word of an interface value.
+       OIDATA      // data word of an interface value in Left
+       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
+       OVARKILL    // variable is dead
+       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.
+       ONAMEOFFSET // offset within a name
 
        // arch-specific opcodes
        ORETJMP // return to other function
index 7f494b16cd3409fed10727445fda39e00e932edb..f1b0a2162837304666e6089649399a6ffcba708b 100644 (file)
@@ -353,22 +353,6 @@ func (n *ClosureExpr) editChildren(edit func(Node) Node) {
        }
 }
 
-func (n *ClosureReadExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
-func (n *ClosureReadExpr) copy() Node {
-       c := *n
-       c.init = copyNodes(c.init)
-       return &c
-}
-func (n *ClosureReadExpr) doChildren(do func(Node) bool) bool {
-       if doNodes(n.init, do) {
-               return true
-       }
-       return false
-}
-func (n *ClosureReadExpr) editChildren(edit func(Node) Node) {
-       editNodes(n.init, edit)
-}
-
 func (n *CommClause) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
 func (n *CommClause) copy() Node {
        c := *n
index 0339444132e44b20b76110faca7751960eba3602..b54b4785a239124bc4b2ebd2d4b392d2b8cbd20c 100644 (file)
@@ -150,23 +150,22 @@ func _() {
        _ = x[OITAB-139]
        _ = x[OIDATA-140]
        _ = x[OSPTR-141]
-       _ = x[OCLOSUREREAD-142]
-       _ = x[OCFUNC-143]
-       _ = x[OCHECKNIL-144]
-       _ = x[OVARDEF-145]
-       _ = x[OVARKILL-146]
-       _ = x[OVARLIVE-147]
-       _ = x[ORESULT-148]
-       _ = x[OINLMARK-149]
-       _ = x[ONAMEOFFSET-150]
-       _ = x[ORETJMP-151]
-       _ = x[OGETG-152]
-       _ = x[OEND-153]
+       _ = x[OCFUNC-142]
+       _ = x[OCHECKNIL-143]
+       _ = x[OVARDEF-144]
+       _ = x[OVARKILL-145]
+       _ = x[OVARLIVE-146]
+       _ = x[ORESULT-147]
+       _ = x[OINLMARK-148]
+       _ = x[ONAMEOFFSET-149]
+       _ = x[ORETJMP-150]
+       _ = x[OGETG-151]
+       _ = x[OEND-152]
 }
 
-const _Op_name = "XXXNAMENONAMETYPEPACKLITERALNILADDSUBORXORADDSTRADDRANDANDAPPENDBYTES2STRBYTES2STRTMPRUNES2STRSTR2BYTESSTR2BYTESTMPSTR2RUNESASAS2AS2DOTTYPEAS2FUNCAS2MAPRAS2RECVASOPCALLCALLFUNCCALLMETHCALLINTERCALLPARTCAPCLOSECLOSURECOMPLITMAPLITSTRUCTLITARRAYLITSLICELITPTRLITCONVCONVIFACECONVNOPCOPYDCLDCLFUNCDCLCONSTDCLTYPEDELETEDOTDOTPTRDOTMETHDOTINTERXDOTDOTTYPEDOTTYPE2EQNELTLEGEGTDEREFINDEXINDEXMAPKEYSTRUCTKEYLENMAKEMAKECHANMAKEMAPMAKESLICEMAKESLICECOPYMULDIVMODLSHRSHANDANDNOTNEWNEWOBJNOTBITNOTPLUSNEGORORPANICPRINTPRINTNPARENSENDSLICESLICEARRSLICESTRSLICE3SLICE3ARRSLICEHEADERRECOVERRECVRUNESTRSELRECV2IOTAREALIMAGCOMPLEXALIGNOFOFFSETOFSIZEOFMETHEXPRSTMTEXPRBLOCKBREAKCASECONTINUEDEFERFALLFORFORUNTILGOTOIFLABELGORANGERETURNSELECTSWITCHTYPESWTCHANTMAPTSTRUCTTINTERTFUNCTARRAYTSLICEINLCALLEFACEITABIDATASPTRCLOSUREREADCFUNCCHECKNILVARDEFVARKILLVARLIVERESULTINLMARKNAMEOFFSETRETJMPGETGEND"
+const _Op_name = "XXXNAMENONAMETYPEPACKLITERALNILADDSUBORXORADDSTRADDRANDANDAPPENDBYTES2STRBYTES2STRTMPRUNES2STRSTR2BYTESSTR2BYTESTMPSTR2RUNESASAS2AS2DOTTYPEAS2FUNCAS2MAPRAS2RECVASOPCALLCALLFUNCCALLMETHCALLINTERCALLPARTCAPCLOSECLOSURECOMPLITMAPLITSTRUCTLITARRAYLITSLICELITPTRLITCONVCONVIFACECONVNOPCOPYDCLDCLFUNCDCLCONSTDCLTYPEDELETEDOTDOTPTRDOTMETHDOTINTERXDOTDOTTYPEDOTTYPE2EQNELTLEGEGTDEREFINDEXINDEXMAPKEYSTRUCTKEYLENMAKEMAKECHANMAKEMAPMAKESLICEMAKESLICECOPYMULDIVMODLSHRSHANDANDNOTNEWNEWOBJNOTBITNOTPLUSNEGORORPANICPRINTPRINTNPARENSENDSLICESLICEARRSLICESTRSLICE3SLICE3ARRSLICEHEADERRECOVERRECVRUNESTRSELRECV2IOTAREALIMAGCOMPLEXALIGNOFOFFSETOFSIZEOFMETHEXPRSTMTEXPRBLOCKBREAKCASECONTINUEDEFERFALLFORFORUNTILGOTOIFLABELGORANGERETURNSELECTSWITCHTYPESWTCHANTMAPTSTRUCTTINTERTFUNCTARRAYTSLICEINLCALLEFACEITABIDATASPTRCFUNCCHECKNILVARDEFVARKILLVARLIVERESULTINLMARKNAMEOFFSETRETJMPGETGEND"
 
-var _Op_index = [...]uint16{0, 3, 7, 13, 17, 21, 28, 31, 34, 37, 39, 42, 48, 52, 58, 64, 73, 85, 94, 103, 115, 124, 126, 129, 139, 146, 153, 160, 164, 168, 176, 184, 193, 201, 204, 209, 216, 223, 229, 238, 246, 254, 260, 264, 273, 280, 284, 287, 294, 302, 309, 315, 318, 324, 331, 339, 343, 350, 358, 360, 362, 364, 366, 368, 370, 375, 380, 388, 391, 400, 403, 407, 415, 422, 431, 444, 447, 450, 453, 456, 459, 462, 468, 471, 477, 480, 486, 490, 493, 497, 502, 507, 513, 518, 522, 527, 535, 543, 549, 558, 569, 576, 580, 587, 595, 599, 603, 607, 614, 621, 629, 635, 643, 651, 656, 661, 665, 673, 678, 682, 685, 693, 697, 699, 704, 706, 711, 717, 723, 729, 735, 740, 744, 751, 757, 762, 768, 774, 781, 786, 790, 795, 799, 810, 815, 823, 829, 836, 843, 849, 856, 866, 872, 876, 879}
+var _Op_index = [...]uint16{0, 3, 7, 13, 17, 21, 28, 31, 34, 37, 39, 42, 48, 52, 58, 64, 73, 85, 94, 103, 115, 124, 126, 129, 139, 146, 153, 160, 164, 168, 176, 184, 193, 201, 204, 209, 216, 223, 229, 238, 246, 254, 260, 264, 273, 280, 284, 287, 294, 302, 309, 315, 318, 324, 331, 339, 343, 350, 358, 360, 362, 364, 366, 368, 370, 375, 380, 388, 391, 400, 403, 407, 415, 422, 431, 444, 447, 450, 453, 456, 459, 462, 468, 471, 477, 480, 486, 490, 493, 497, 502, 507, 513, 518, 522, 527, 535, 543, 549, 558, 569, 576, 580, 587, 595, 599, 603, 607, 614, 621, 629, 635, 643, 651, 656, 661, 665, 673, 678, 682, 685, 693, 697, 699, 704, 706, 711, 717, 723, 729, 735, 740, 744, 751, 757, 762, 768, 774, 781, 786, 790, 795, 799, 804, 812, 818, 825, 832, 838, 845, 855, 861, 865, 868}
 
 func (i Op) String() string {
        if i >= Op(len(_Op_index)-1) {
index 0c222b12cf325c1260c4052dc1816772bbae5a24..54bde20f1cdc960d0f0d044e5e27997e3df0fae2 100644 (file)
@@ -2168,9 +2168,6 @@ func (s *state) expr(n ir.Node) *ssa.Value {
                }
                addr := s.addr(n)
                return s.load(n.Type(), addr)
-       case ir.OCLOSUREREAD:
-               addr := s.addr(n)
-               return s.load(n.Type(), addr)
        case ir.ONIL:
                n := n.(*ir.NilExpr)
                t := n.Type()
@@ -5074,10 +5071,6 @@ func (s *state) addr(n ir.Node) *ssa.Value {
                n := n.(*ir.SelectorExpr)
                p := s.exprPtr(n.X, n.Bounded(), n.Pos())
                return s.newValue1I(ssa.OpOffPtr, t, n.Offset(), p)
-       case ir.OCLOSUREREAD:
-               n := n.(*ir.ClosureReadExpr)
-               return s.newValue1I(ssa.OpOffPtr, t, n.Offset,
-                       s.entryNewValue0(ssa.OpGetClosurePtr, s.f.Config.Types.BytePtr))
        case ir.OCONVNOP:
                n := n.(*ir.ConvExpr)
                if n.Type() == n.X.Type() {
index 07bbd2510586f7150d606e740d6cde27ab38b884..3160725e3c56a7504b619dae759e08e0b711fa5b 100644 (file)
@@ -789,9 +789,6 @@ func typecheck1(n ir.Node, top int) ir.Node {
                n := n.(*ir.UnaryExpr)
                return tcSPtr(n)
 
-       case ir.OCLOSUREREAD:
-               return n
-
        case ir.OCFUNC:
                n := n.(*ir.UnaryExpr)
                n.X = Expr(n.X)
index 6fdb8f15f58d6ec71bebe471ddc0b276b92bf741..df575d698589b468380ce4aad851d049297b7f61 100644 (file)
@@ -162,7 +162,7 @@ func walkExpr1(n ir.Node, init *ir.Nodes) ir.Node {
                n := n.(*ir.CallExpr)
                return mkcall("gorecover", n.Type(), init, typecheck.NodAddr(ir.RegFP))
 
-       case ir.OCLOSUREREAD, ir.OCFUNC:
+       case ir.OCFUNC:
                return n
 
        case ir.OCALLINTER, ir.OCALLFUNC, ir.OCALLMETH:
index 928b6737528ce34efcfb6803bedc302fcd5e185e..e780a9066031da99f529bbeb47f1552d9d29a5b2 100644 (file)
@@ -476,7 +476,7 @@ func calcHasCall(n ir.Node) bool {
                n := n.(*ir.SelectorExpr)
                return n.X.HasCall()
 
-       case ir.OGETG, ir.OCLOSUREREAD, ir.OMETHEXPR:
+       case ir.OGETG, ir.OMETHEXPR:
                return false
 
        // TODO(rsc): These look wrong in various ways but are what calcHasCall has always done.