Commit 14b9032f authored by Luuk van Dijk's avatar Luuk van Dijk

5l/6l/8l: undo spadj cleanup at ARET for following instructions in the same stackframe.

5l was already correct, clarified comment and added diags for unmaintained code.

R=rsc
CC=golang-dev
https://golang.org/cl/4277070
parent 9d3b3998
...@@ -364,14 +364,14 @@ noops(void) ...@@ -364,14 +364,14 @@ noops(void)
p = appendp(p); p = appendp(p);
p->as = ABL; p->as = ABL;
p->scond = C_SCOND_LO; p->scond = C_SCOND_LO;
p->to.type = D_BRANCH; p->to.type = D_BRANCH;
p->to.sym = symmorestack; p->to.sym = symmorestack;
p->cond = pmorestack; p->cond = pmorestack;
// MOVW.W R14,$-autosize(SP) // MOVW.W R14,$-autosize(SP)
p = appendp(p); p = appendp(p);
p->as = AMOVW; p->as = AMOVW;
p->scond |= C_WBIT; p->scond |= C_WBIT;
p->from.type = D_REG; p->from.type = D_REG;
p->from.reg = REGLINK; p->from.reg = REGLINK;
p->to.type = D_OREG; p->to.type = D_OREG;
...@@ -413,14 +413,14 @@ noops(void) ...@@ -413,14 +413,14 @@ noops(void)
// BL runtime.morestack(SB) // modifies LR // BL runtime.morestack(SB) // modifies LR
p = appendp(p); p = appendp(p);
p->as = ABL; p->as = ABL;
p->to.type = D_BRANCH; p->to.type = D_BRANCH;
p->to.sym = symmorestack; p->to.sym = symmorestack;
p->cond = pmorestack; p->cond = pmorestack;
// MOVW.W R14,$-autosize(SP) // MOVW.W R14,$-autosize(SP)
p = appendp(p); p = appendp(p);
p->as = AMOVW; p->as = AMOVW;
p->scond |= C_WBIT; p->scond |= C_WBIT;
p->from.type = D_REG; p->from.type = D_REG;
p->from.reg = REGLINK; p->from.reg = REGLINK;
p->to.type = D_OREG; p->to.type = D_OREG;
...@@ -450,6 +450,8 @@ noops(void) ...@@ -450,6 +450,8 @@ noops(void)
} }
} }
if(thumb){ if(thumb){
diag("thumb not maintained");
errorexit();
if(cursym->text->mark & LEAF){ if(cursym->text->mark & LEAF){
if(autosize){ if(autosize){
p->as = AADD; p->as = AADD;
...@@ -481,7 +483,7 @@ noops(void) ...@@ -481,7 +483,7 @@ noops(void)
q->to.type = D_REG; q->to.type = D_REG;
q->to.reg = REGSP; q->to.reg = REGSP;
q->link = p->link; q->link = p->link;
p->link = q; p->link = q;
} }
else else
q = p; q = p;
...@@ -492,6 +494,8 @@ noops(void) ...@@ -492,6 +494,8 @@ noops(void)
break; break;
} }
if(foreign) { if(foreign) {
diag("foreign not maintained");
errorexit();
// if(foreign) print("ABXRET 3 %s\n", cursym->name); // if(foreign) print("ABXRET 3 %s\n", cursym->name);
#define R 1 #define R 1
p->as = AMOVW; p->as = AMOVW;
...@@ -530,7 +534,9 @@ noops(void) ...@@ -530,7 +534,9 @@ noops(void)
p->from.reg = REGSP; p->from.reg = REGSP;
p->to.type = D_REG; p->to.type = D_REG;
p->to.reg = REGPC; p->to.reg = REGPC;
// no spadj because it doesn't fall through // If there are instructions following
// this ARET, they come from a branch
// with the same stackframe, so no spadj.
} }
break; break;
......
...@@ -274,10 +274,10 @@ patch(void) ...@@ -274,10 +274,10 @@ patch(void)
if(HEADTYPE == Hwindows) { if(HEADTYPE == Hwindows) {
// Windows // Windows
// Convert // Convert
// op n(GS), reg // op n(GS), reg
// to // to
// MOVL 0x58(GS), reg // MOVL 0x58(GS), reg
// op n(reg), reg // op n(reg), reg
// The purpose of this patch is to fix some accesses // The purpose of this patch is to fix some accesses
// to extern register variables (TLS) on Windows, as // to extern register variables (TLS) on Windows, as
// a different method is used to access them. // a different method is used to access them.
...@@ -674,6 +674,11 @@ dostkoff(void) ...@@ -674,6 +674,11 @@ dostkoff(void)
p->spadj = -autoffset; p->spadj = -autoffset;
p = appendp(p); p = appendp(p);
p->as = ARET; p->as = ARET;
// If there are instructions following
// this ARET, they come from a branch
// with the same stackframe, so undo
// the cleanup.
p->spadj = +autoffset;
} }
} }
} }
......
...@@ -614,14 +614,17 @@ dostkoff(void) ...@@ -614,14 +614,17 @@ dostkoff(void)
diag("unbalanced PUSH/POP"); diag("unbalanced PUSH/POP");
if(autoffset) { if(autoffset) {
q = p; p->as = AADJSP;
p->from.type = D_CONST;
p->from.offset = -autoffset;
p->spadj = -autoffset;
p = appendp(p); p = appendp(p);
p->as = ARET; p->as = ARET;
// If there are instructions following
q->as = AADJSP; // this ARET, they come from a branch
q->from.type = D_CONST; // with the same stackframe, so undo
q->from.offset = -autoffset; // the cleanup.
p->spadj = -autoffset; p->spadj = +autoffset;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment