From: David Chase Date: Mon, 10 Aug 2020 22:30:11 +0000 (-0400) Subject: cmd/compile: enable late expansion for closure calls X-Git-Tag: go1.16beta1~873 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8c84dcfe8c6a795ed6ae6be540ffc638841144ce;p=gostls13.git cmd/compile: enable late expansion for closure calls This works for "normal" calls. Defer func() and Go func() still pending. RT calls still pending. Change-Id: I29cbdad8c877d12c08bbf7f3f0696611de877da9 Reviewed-on: https://go-review.googlesource.com/c/go/+/247771 Trust: David Chase Run-TryBot: David Chase TryBot-Result: Go Bot Reviewed-by: Cherry Zhang --- diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index e01ebd6e89..7e377f9b84 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -4386,6 +4386,9 @@ func (s *state) call(n *Node, k callKind, returnResultAddr bool) *ssa.Value { // Deferred nil function needs to panic when the function is invoked, // not the point of defer statement. s.maybeNilCheckClosure(closure, k) + if k == callNormal && ssa.LateCallExpansionEnabledWithin(s.f) { + testLateExpansion = true + } } case OCALLMETH: if fn.Op != ODOTMETH { @@ -4556,7 +4559,13 @@ func (s *state) call(n *Node, k callKind, returnResultAddr bool) *ssa.Value { // critical that we not clobber any arguments already // stored onto the stack. codeptr = s.rawLoad(types.Types[TUINTPTR], closure) - call = s.newValue3A(ssa.OpClosureCall, types.TypeMem, ssa.ClosureAuxCall(ACArgs, ACResults), codeptr, closure, s.mem()) + if testLateExpansion { + aux := ssa.ClosureAuxCall(ACArgs, ACResults) + call = s.newValue2A(ssa.OpClosureLECall, aux.LateExpansionResultType(), aux, codeptr, closure) + call.AddArgs(callArgs...) + } else { + call = s.newValue3A(ssa.OpClosureCall, types.TypeMem, ssa.ClosureAuxCall(ACArgs, ACResults), codeptr, closure, s.mem()) + } case codeptr != nil: if testLateExpansion { aux := ssa.InterfaceAuxCall(ACArgs, ACResults)