diff --git a/src/cmd/internal/obj/arm64/obj7.go b/src/cmd/internal/obj/arm64/obj7.go index 9774e0120bd..0e16e287a78 100644 --- a/src/cmd/internal/obj/arm64/obj7.go +++ b/src/cmd/internal/obj/arm64/obj7.go @@ -289,11 +289,12 @@ func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog { } call.To.Sym = c.ctxt.Lookup(morestack) - unspill := c.cursym.Func().UnspillRegisterArgs(call, c.newprog) - pcdata = c.ctxt.EndUnsafePoint(unspill, c.newprog, -1) + // The instructions which unspill regs should be preemptible. + pcdata = c.ctxt.EndUnsafePoint(call, c.newprog, -1) + unspill := c.cursym.Func().UnspillRegisterArgs(pcdata, c.newprog) // B start - jmp := obj.Appendp(pcdata, c.newprog) + jmp := obj.Appendp(unspill, c.newprog) jmp.As = AB jmp.To.Type = obj.TYPE_BRANCH jmp.To.SetTarget(startPred.Link) diff --git a/src/cmd/internal/obj/ppc64/obj9.go b/src/cmd/internal/obj/ppc64/obj9.go index 02831b890a3..da95e65079c 100644 --- a/src/cmd/internal/obj/ppc64/obj9.go +++ b/src/cmd/internal/obj/ppc64/obj9.go @@ -1363,11 +1363,12 @@ func (c *ctxt9) stacksplit(p *obj.Prog, framesize int32) *obj.Prog { p.To.Reg = REG_R2 } + // The instructions which unspill regs should be preemptible. + p = c.ctxt.EndUnsafePoint(p, c.newprog, -1) unspill := c.cursym.Func().UnspillRegisterArgs(p, c.newprog) - p = c.ctxt.EndUnsafePoint(unspill, c.newprog, -1) // BR start - p = obj.Appendp(p, c.newprog) + p = obj.Appendp(unspill, c.newprog) p.As = ABR p.To.Type = obj.TYPE_BRANCH p.To.SetTarget(startPred.Link) diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go index 7b5621f6508..675031de73f 100644 --- a/src/cmd/internal/obj/riscv/obj.go +++ b/src/cmd/internal/obj/riscv/obj.go @@ -913,8 +913,9 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, cursym *obj.LSym, newprog obj.ProgA } jalToSym(ctxt, p, REG_X5) - p = cursym.Func().UnspillRegisterArgs(p, newprog) + // The instructions which unspill regs should be preemptible. p = ctxt.EndUnsafePoint(p, newprog, -1) + p = cursym.Func().UnspillRegisterArgs(p, newprog) // JMP start p = obj.Appendp(p, newprog) diff --git a/src/cmd/internal/obj/x86/obj6.go b/src/cmd/internal/obj/x86/obj6.go index fc4007ec88b..e6ea8985e4f 100644 --- a/src/cmd/internal/obj/x86/obj6.go +++ b/src/cmd/internal/obj/x86/obj6.go @@ -1226,10 +1226,11 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgA progedit(ctxt, callend.Link, newprog) } - pcdata = cursym.Func().UnspillRegisterArgs(callend, newprog) - pcdata = ctxt.EndUnsafePoint(pcdata, newprog, -1) + // The instructions which unspill regs should be preemptible. + pcdata = ctxt.EndUnsafePoint(callend, newprog, -1) + unspill := cursym.Func().UnspillRegisterArgs(pcdata, newprog) - jmp := obj.Appendp(pcdata, newprog) + jmp := obj.Appendp(unspill, newprog) jmp.As = obj.AJMP jmp.To.Type = obj.TYPE_BRANCH jmp.To.SetTarget(startPred.Link)