]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.power64] liblink: fix lost branch target
authorAustin Clements <austin@google.com>
Mon, 27 Oct 2014 21:19:41 +0000 (17:19 -0400)
committerAustin Clements <austin@google.com>
Mon, 27 Oct 2014 21:19:41 +0000 (17:19 -0400)
A recent commit lost the branch target in the really-big-stack
case of splitstack, causing an infinite loop stack preempt
case.  Revive the branch target.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/157790044

src/liblink/obj9.c

index fa8af5f839d33f6397131b3ce2717d490a0a9f9d..3db08c5450523a01d290ae87323bdb9de7c9b096 100644 (file)
@@ -703,7 +703,7 @@ addstacksplit(Link *ctxt, LSym *cursym)
 static Prog*
 stacksplit(Link *ctxt, Prog *p, int32 framesize, int noctxt)
 {
-       Prog *q1;
+       Prog *q, *q1;
 
        // MOVD g_stackguard(g), R3
        p = appendp(ctxt, p);
@@ -716,6 +716,7 @@ stacksplit(Link *ctxt, Prog *p, int32 framesize, int noctxt)
        p->to.type = D_REG;
        p->to.reg = 3;
 
+       q = nil;
        if(framesize <= StackSmall) {
                // small stack: SP < stackguard
                //      CMP     stackguard, SP
@@ -766,7 +767,7 @@ stacksplit(Link *ctxt, Prog *p, int32 framesize, int noctxt)
                p->to.type = D_CONST;
                p->to.offset = StackPreempt;
 
-               p = appendp(ctxt, p);
+               q = p = appendp(ctxt, p);
                p->as = ABEQ;
                p->to.type = D_BRANCH;
 
@@ -812,6 +813,8 @@ stacksplit(Link *ctxt, Prog *p, int32 framesize, int noctxt)
        p->from.offset = D_LR;
        p->to.type = D_REG;
        p->to.reg = 5;
+       if(q)
+               q->pcond = p;
 
        // BL   runtime.morestack(SB)
        p = appendp(ctxt, p);