Skip to content

Commit 5f1b12b

Browse files
committed
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>
1 parent 1f45216 commit 5f1b12b

File tree

3 files changed

+18
-31
lines changed

3 files changed

+18
-31
lines changed

src/cmd/compile/internal/gc/order.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,6 @@ func (o *Order) call(n *Node) {
496496
arg.Left = x
497497
x.Name.SetAddrtaken(true) // ensure SSA keeps the x variable
498498
n.Nbody.Append(typecheck(nod(OVARLIVE, x, nil), ctxStmt))
499-
n.SetNeedsWrapper(true)
500499
}
501500
}
502501

src/cmd/compile/internal/gc/syntax.go

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,19 @@ const (
141141
nodeInitorder, _ // tracks state during init1; two bits
142142
_, _ // second nodeInitorder bit
143143
_, nodeHasBreak
144-
_, nodeNoInline // used internally by inliner to indicate that a function call should not be inlined; set for OCALLFUNC and OCALLMETH only
145-
_, nodeImplicit // implicit OADDR or ODEREF; ++/-- statement represented as OASOP; or ANDNOT lowered to OAND
146-
_, nodeIsDDD // is the argument variadic
147-
_, nodeDiag // already printed error about this
148-
_, nodeColas // OAS resulting from :=
149-
_, nodeNonNil // guaranteed to be non-nil
150-
_, nodeTransient // storage can be reused immediately after this statement
151-
_, nodeBounded // bounds check unnecessary
152-
_, nodeHasCall // expression contains a function call
153-
_, nodeLikely // if statement condition likely
154-
_, nodeHasVal // node.E contains a Val
155-
_, nodeHasOpt // node.E contains an Opt
156-
_, nodeEmbedded // ODCLFIELD embedded type
157-
_, nodeNeedsWrapper // OCALLxxx node that needs to be wrapped
144+
_, nodeNoInline // used internally by inliner to indicate that a function call should not be inlined; set for OCALLFUNC and OCALLMETH only
145+
_, nodeImplicit // implicit OADDR or ODEREF; ++/-- statement represented as OASOP; or ANDNOT lowered to OAND
146+
_, nodeIsDDD // is the argument variadic
147+
_, nodeDiag // already printed error about this
148+
_, nodeColas // OAS resulting from :=
149+
_, nodeNonNil // guaranteed to be non-nil
150+
_, nodeTransient // storage can be reused immediately after this statement
151+
_, nodeBounded // bounds check unnecessary
152+
_, nodeHasCall // expression contains a function call
153+
_, nodeLikely // if statement condition likely
154+
_, nodeHasVal // node.E contains a Val
155+
_, nodeHasOpt // node.E contains an Opt
156+
_, nodeEmbedded // ODCLFIELD embedded type
158157
)
159158

160159
func (n *Node) Class() Class { return Class(n.flags.get3(nodeClass)) }
@@ -287,20 +286,6 @@ func (n *Node) SetIota(x int64) {
287286
n.Xoffset = x
288287
}
289288

290-
func (n *Node) NeedsWrapper() bool {
291-
return n.flags&nodeNeedsWrapper != 0
292-
}
293-
294-
// SetNeedsWrapper indicates that OCALLxxx node needs to be wrapped by a closure.
295-
func (n *Node) SetNeedsWrapper(b bool) {
296-
switch n.Op {
297-
case OCALLFUNC, OCALLMETH, OCALLINTER:
298-
default:
299-
Fatalf("Node.SetNeedsWrapper %v", n.Op)
300-
}
301-
n.flags.set(nodeNeedsWrapper, b)
302-
}
303-
304289
// mayBeShared reports whether n may occur in multiple places in the AST.
305290
// Extra care must be taken when mutating such a node.
306291
func (n *Node) mayBeShared() bool {

src/cmd/compile/internal/gc/walk.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,15 @@ func walkstmt(n *Node) *Node {
231231
case OCOPY:
232232
n.Left = copyany(n.Left, &n.Ninit, true)
233233

234-
default:
235-
if n.Left.NeedsWrapper() {
234+
case OCALLFUNC, OCALLMETH, OCALLINTER:
235+
if n.Left.Nbody.Len() > 0 {
236236
n.Left = wrapCall(n.Left, &n.Ninit)
237237
} else {
238238
n.Left = walkexpr(n.Left, &n.Ninit)
239239
}
240+
241+
default:
242+
n.Left = walkexpr(n.Left, &n.Ninit)
240243
}
241244

242245
case OFOR, OFORUNTIL:

0 commit comments

Comments
 (0)