cmd/compile: remove nodeNeedsWrapper flag

CL 254397 attached OVARLIVE nodes to OCALLxxx nodes Nbody.

The NeedsWrapper flag is now redundant with n.Nbody.Len() > 0
condition, so use that condition instead and remove the flag.

Passes toolstash-check.

Change-Id: Iebc3e674d3c0040a876ca4be05025943d2b4fb31
Reviewed-on: https://go-review.googlesource.com/c/go/+/254398
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Cuong Manh Le 2020-09-12 07:19:22 +07:00
parent 1f45216694
commit 5f1b12bfbe
3 changed files with 18 additions and 31 deletions

View file

@ -496,7 +496,6 @@ func (o *Order) call(n *Node) {
arg.Left = x
x.Name.SetAddrtaken(true) // ensure SSA keeps the x variable
n.Nbody.Append(typecheck(nod(OVARLIVE, x, nil), ctxStmt))
n.SetNeedsWrapper(true)
}
}

View file

@ -154,7 +154,6 @@ const (
_, nodeHasVal // node.E contains a Val
_, nodeHasOpt // node.E contains an Opt
_, nodeEmbedded // ODCLFIELD embedded type
_, nodeNeedsWrapper // OCALLxxx node that needs to be wrapped
)
func (n *Node) Class() Class { return Class(n.flags.get3(nodeClass)) }
@ -287,20 +286,6 @@ func (n *Node) SetIota(x int64) {
n.Xoffset = x
}
func (n *Node) NeedsWrapper() bool {
return n.flags&nodeNeedsWrapper != 0
}
// SetNeedsWrapper indicates that OCALLxxx node needs to be wrapped by a closure.
func (n *Node) SetNeedsWrapper(b bool) {
switch n.Op {
case OCALLFUNC, OCALLMETH, OCALLINTER:
default:
Fatalf("Node.SetNeedsWrapper %v", n.Op)
}
n.flags.set(nodeNeedsWrapper, b)
}
// mayBeShared reports whether n may occur in multiple places in the AST.
// Extra care must be taken when mutating such a node.
func (n *Node) mayBeShared() bool {

View file

@ -231,12 +231,15 @@ func walkstmt(n *Node) *Node {
case OCOPY:
n.Left = copyany(n.Left, &n.Ninit, true)
default:
if n.Left.NeedsWrapper() {
case OCALLFUNC, OCALLMETH, OCALLINTER:
if n.Left.Nbody.Len() > 0 {
n.Left = wrapCall(n.Left, &n.Ninit)
} else {
n.Left = walkexpr(n.Left, &n.Ninit)
}
default:
n.Left = walkexpr(n.Left, &n.Ninit)
}
case OFOR, OFORUNTIL: