From: Cuong Manh Le Date: Sat, 12 Sep 2020 00:19:22 +0000 (+0700) Subject: cmd/compile: remove nodeNeedsWrapper flag X-Git-Tag: go1.16beta1~1067 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5f1b12bfbeb04ca6dbecbf064f5e5a42d8ba4b5a;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Matthew Dempsky --- diff --git a/src/cmd/compile/internal/gc/order.go b/src/cmd/compile/internal/gc/order.go index 341f4ee66f..75da154fe2 100644 --- a/src/cmd/compile/internal/gc/order.go +++ b/src/cmd/compile/internal/gc/order.go @@ -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) } } diff --git a/src/cmd/compile/internal/gc/syntax.go b/src/cmd/compile/internal/gc/syntax.go index 9592b7484c..14d2710da4 100644 --- a/src/cmd/compile/internal/gc/syntax.go +++ b/src/cmd/compile/internal/gc/syntax.go @@ -141,20 +141,19 @@ const ( nodeInitorder, _ // tracks state during init1; two bits _, _ // second nodeInitorder bit _, nodeHasBreak - _, nodeNoInline // used internally by inliner to indicate that a function call should not be inlined; set for OCALLFUNC and OCALLMETH only - _, nodeImplicit // implicit OADDR or ODEREF; ++/-- statement represented as OASOP; or ANDNOT lowered to OAND - _, nodeIsDDD // is the argument variadic - _, nodeDiag // already printed error about this - _, nodeColas // OAS resulting from := - _, nodeNonNil // guaranteed to be non-nil - _, nodeTransient // storage can be reused immediately after this statement - _, nodeBounded // bounds check unnecessary - _, nodeHasCall // expression contains a function call - _, nodeLikely // if statement condition likely - _, nodeHasVal // node.E contains a Val - _, nodeHasOpt // node.E contains an Opt - _, nodeEmbedded // ODCLFIELD embedded type - _, nodeNeedsWrapper // OCALLxxx node that needs to be wrapped + _, nodeNoInline // used internally by inliner to indicate that a function call should not be inlined; set for OCALLFUNC and OCALLMETH only + _, nodeImplicit // implicit OADDR or ODEREF; ++/-- statement represented as OASOP; or ANDNOT lowered to OAND + _, nodeIsDDD // is the argument variadic + _, nodeDiag // already printed error about this + _, nodeColas // OAS resulting from := + _, nodeNonNil // guaranteed to be non-nil + _, nodeTransient // storage can be reused immediately after this statement + _, nodeBounded // bounds check unnecessary + _, nodeHasCall // expression contains a function call + _, nodeLikely // if statement condition likely + _, nodeHasVal // node.E contains a Val + _, nodeHasOpt // node.E contains an Opt + _, nodeEmbedded // ODCLFIELD embedded type ) 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 { diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go index 361de7e0f3..2d29366880 100644 --- a/src/cmd/compile/internal/gc/walk.go +++ b/src/cmd/compile/internal/gc/walk.go @@ -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: