]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: enable late call lowering for "callDeferStack"
authorDavid Chase <drchase@google.com>
Tue, 11 Aug 2020 16:52:01 +0000 (12:52 -0400)
committerDavid Chase <drchase@google.com>
Fri, 9 Oct 2020 15:11:54 +0000 (15:11 +0000)
Change-Id: I773fce43d43f6e19180531e7bd1cc50bd8f31f75
Reviewed-on: https://go-review.googlesource.com/c/go/+/248187
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/gc/ssa.go

index 90ce9e54f8a2aba0927935c1ff503b4a9e52ccbf..77c92824013b0e1f0e41b37da504f65657211fa5 100644 (file)
@@ -4421,6 +4421,7 @@ func (s *state) call(n *Node, k callKind, returnResultAddr bool) *ssa.Value {
 
        var call *ssa.Value
        if k == callDeferStack {
+               testLateExpansion = ssa.LateCallExpansionEnabledWithin(s.f)
                // Make a defer struct d on the stack.
                t := deferstruct(stksize)
                d := tempAt(n.Pos, s.curfn, t)
@@ -4471,10 +4472,17 @@ func (s *state) call(n *Node, k callKind, returnResultAddr bool) *ssa.Value {
                }
 
                // Call runtime.deferprocStack with pointer to _defer record.
-               arg0 := s.constOffPtrSP(types.Types[TUINTPTR], Ctxt.FixedFrameSize())
-               s.store(types.Types[TUINTPTR], arg0, addr)
                ACArgs = append(ACArgs, ssa.Param{Type: types.Types[TUINTPTR], Offset: int32(Ctxt.FixedFrameSize())})
-               call = s.newValue1A(ssa.OpStaticCall, types.TypeMem, ssa.StaticAuxCall(deferprocStack, ACArgs, ACResults), s.mem())
+               aux := ssa.StaticAuxCall(deferprocStack, ACArgs, ACResults)
+               if testLateExpansion {
+                       callArgs = append(callArgs, addr, s.mem())
+                       call = s.newValue0A(ssa.OpStaticLECall, aux.LateExpansionResultType(), aux)
+                       call.AddArgs(callArgs...)
+               } else {
+                       arg0 := s.constOffPtrSP(types.Types[TUINTPTR], Ctxt.FixedFrameSize())
+                       s.store(types.Types[TUINTPTR], arg0, addr)
+                       call = s.newValue1A(ssa.OpStaticCall, types.TypeMem, aux, s.mem())
+               }
                if stksize < int64(Widthptr) {
                        // We need room for both the call to deferprocStack and the call to
                        // the deferred function.