]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile: remove SetClosureCalled(false) hacks
authorMatthew Dempsky <mdempsky@google.com>
Wed, 23 Jun 2021 05:21:09 +0000 (22:21 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 23 Jun 2021 15:11:06 +0000 (15:11 +0000)
The current go/defer wrapping code goes to some length to clear
ClosureCalled when a function call will end up not being called
directly, and so it will need to use the context register.

But we already have a flag to indicate we need to use the context
register: Needctxt. The real issue here is just that buildssa was
using fn.ClosureCalled instead of fn.Needctxt.

Change-Id: Ic9f5f23b66eb467fc61fa84eacb45d46c54133d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/330329
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/ssagen/ssa.go
src/cmd/compile/internal/walk/order.go

index 7a6bf878e1bc5977d73865a7600339372ed67766..659ba02b5bd3aa897a3ae587ec0fd035920c2ac4 100644 (file)
@@ -535,7 +535,7 @@ func buildssa(fn *ir.Func, worker int) *ssa.Func {
        }
 
        // Populate closure variables.
-       if !fn.ClosureCalled() {
+       if fn.Needctxt() {
                clo := s.entryNewValue0(ssa.OpGetClosurePtr, s.f.Config.Types.BytePtr)
                offset := int64(types.PtrSize) // PtrSize to skip past function entry PC field
                for _, n := range fn.ClosureVars {
index c24f80508a046718621587ea8ba8e294205a76f5..75657cd3e49daaa3b740cd09a1afbaa9e2647617 100644 (file)
@@ -1566,7 +1566,6 @@ func (o *orderState) wrapGoDefer(n *ir.GoDeferStmt) {
        if len(callArgs) == 0 && call.Op() == ir.OCALLFUNC && callX.Type().NumResults() == 0 {
                if callX.Op() == ir.OCLOSURE {
                        clo := callX.(*ir.ClosureExpr)
-                       clo.Func.SetClosureCalled(false)
                        clo.IsGoWrap = true
                }
                return
@@ -1691,12 +1690,6 @@ func (o *orderState) wrapGoDefer(n *ir.GoDeferStmt) {
                        // Deal with "defer returnsafunc()(x, y)" (for
                        // example) by copying the callee expression.
                        fnExpr = mkArgCopy(callX)
-                       if callX.Op() == ir.OCLOSURE {
-                               // For "defer func(...)", in addition to copying the
-                               // closure into a temp, mark it as no longer directly
-                               // called.
-                               callX.(*ir.ClosureExpr).Func.SetClosureCalled(false)
-                       }
                }
        }
 
@@ -1770,8 +1763,6 @@ func (o *orderState) wrapGoDefer(n *ir.GoDeferStmt) {
        topcall := ir.NewCallExpr(n.Pos(), ir.OCALL, clo, nil)
        typecheck.Call(topcall)
 
-       fn.SetClosureCalled(false)
-
        // Finally, point the defer statement at the newly generated call.
        n.Call = topcall
 }