]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: remove okAs
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 2 Dec 2020 07:40:48 +0000 (14:40 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 3 Dec 2020 08:30:09 +0000 (08:30 +0000)
The check for blank in okAs is redundant with what its callers already
done, so just inline the conversion in callers side instead.

Passes toolstash-check.

Change-Id: I606105e2d2cf8e80214722a13c3101c464d20d82
Reviewed-on: https://go-review.googlesource.com/c/go/+/274793
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/order.go

index 352e9c473b51c5ec5099318151bda6ed07639f88..7816e684dc0899ac1c579114d9629df3fe0ffe81 100644 (file)
@@ -936,7 +936,7 @@ func (o *Order) stmt(n ir.Node) {
                                        }
 
                                        tmp := o.newTemp(types.Types[types.TBOOL], false)
-                                       as := okas(ok, tmp)
+                                       as := ir.Nod(ir.OAS, ok, conv(tmp, ok.Type()))
                                        as = typecheck(as, ctxStmt)
                                        n2.PtrInit().Append(as)
                                        ok = tmp
@@ -1382,15 +1382,6 @@ func (o *Order) expr(n, lhs ir.Node) ir.Node {
        return n
 }
 
-// okas creates and returns an assignment of val to ok,
-// including an explicit conversion if necessary.
-func okas(ok, val ir.Node) ir.Node {
-       if !ir.IsBlank(ok) {
-               val = conv(val, ok.Type())
-       }
-       return ir.Nod(ir.OAS, ok, val)
-}
-
 // as2 orders OAS2XXXX nodes. It creates temporaries to ensure left-to-right assignment.
 // The caller should order the right-hand side of the assignment before calling order.as2.
 // It rewrites,
@@ -1442,7 +1433,7 @@ func (o *Order) okAs2(n ir.Node) {
                n.List().SetFirst(tmp1)
        }
        if tmp2 != nil {
-               r := okas(n.List().Second(), tmp2)
+               r := ir.Nod(ir.OAS, n.List().Second(), conv(tmp2, n.List().Second().Type()))
                r = typecheck(r, ctxStmt)
                o.mapAssign(r)
                n.List().SetSecond(tmp2)