[dev.regabi] cmd/compile: adjust one case in walkexpr

The mid-case n := n.(*ir.AssignExpr) does not lend itself
well to pulling the code into a new function, because n will
be a function argument and will not be redeclarable.

Change-Id: I673f2aa37eea64b083725326ed3fa36447bcc7af
Reviewed-on: https://go-review.googlesource.com/c/go/+/279426
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Russ Cox 2020-12-22 00:07:40 -05:00
parent 280e7fd1ee
commit c40934b33d

View file

@ -702,38 +702,38 @@ func walkexpr1(n ir.Node, init *ir.Nodes) ir.Node {
} else { } else {
n.(*ir.AssignStmt).SetLeft(left) n.(*ir.AssignStmt).SetLeft(left)
} }
n := n.(*ir.AssignStmt) as := n.(*ir.AssignStmt)
if oaslit(n, init) { if oaslit(as, init) {
return ir.NodAt(n.Pos(), ir.OBLOCK, nil, nil) return ir.NodAt(as.Pos(), ir.OBLOCK, nil, nil)
} }
if n.Right() == nil { if as.Right() == nil {
// TODO(austin): Check all "implicit zeroing" // TODO(austin): Check all "implicit zeroing"
return n return as
} }
if !instrumenting && isZero(n.Right()) { if !instrumenting && isZero(as.Right()) {
return n return as
} }
switch n.Right().Op() { switch as.Right().Op() {
default: default:
n.SetRight(walkexpr(n.Right(), init)) as.SetRight(walkexpr(as.Right(), init))
case ir.ORECV: case ir.ORECV:
// x = <-c; n.Left is x, n.Right.Left is c. // x = <-c; as.Left is x, as.Right.Left is c.
// order.stmt made sure x is addressable. // order.stmt made sure x is addressable.
recv := n.Right().(*ir.UnaryExpr) recv := as.Right().(*ir.UnaryExpr)
recv.SetLeft(walkexpr(recv.Left(), init)) recv.SetLeft(walkexpr(recv.Left(), init))
n1 := nodAddr(n.Left()) n1 := nodAddr(as.Left())
r := recv.Left() // the channel r := recv.Left() // the channel
return mkcall1(chanfn("chanrecv1", 2, r.Type()), nil, init, r, n1) return mkcall1(chanfn("chanrecv1", 2, r.Type()), nil, init, r, n1)
case ir.OAPPEND: case ir.OAPPEND:
// x = append(...) // x = append(...)
call := n.Right().(*ir.CallExpr) call := as.Right().(*ir.CallExpr)
if call.Type().Elem().NotInHeap() { if call.Type().Elem().NotInHeap() {
base.Errorf("%v can't be allocated in Go; it is incomplete (or unallocatable)", call.Type().Elem()) base.Errorf("%v can't be allocated in Go; it is incomplete (or unallocatable)", call.Type().Elem())
} }
@ -745,24 +745,24 @@ func walkexpr1(n ir.Node, init *ir.Nodes) ir.Node {
case call.IsDDD(): case call.IsDDD():
r = appendslice(call, init) // also works for append(slice, string). r = appendslice(call, init) // also works for append(slice, string).
default: default:
r = walkappend(call, init, n) r = walkappend(call, init, as)
} }
n.SetRight(r) as.SetRight(r)
if r.Op() == ir.OAPPEND { if r.Op() == ir.OAPPEND {
// Left in place for back end. // Left in place for back end.
// Do not add a new write barrier. // Do not add a new write barrier.
// Set up address of type for back end. // Set up address of type for back end.
r.(*ir.CallExpr).SetLeft(typename(r.Type().Elem())) r.(*ir.CallExpr).SetLeft(typename(r.Type().Elem()))
return n return as
} }
// Otherwise, lowered for race detector. // Otherwise, lowered for race detector.
// Treat as ordinary assignment. // Treat as ordinary assignment.
} }
if n.Left() != nil && n.Right() != nil { if as.Left() != nil && as.Right() != nil {
return convas(n, init) return convas(as, init)
} }
return n return as
case ir.OAS2: case ir.OAS2:
init.AppendNodes(n.PtrInit()) init.AppendNodes(n.PtrInit())