summaryrefslogtreecommitdiff
path: root/src/cmd/5g
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-02-19 17:08:55 -0500
committerRuss Cox <rsc@golang.org>2014-02-19 17:08:55 -0500
commitbad327a9d33e61c1c5f9056a2beedec9abe545cc (patch)
tree47da2af3d74ac686ce698918c2beb5089698ef83 /src/cmd/5g
parent7d216d05e6113b834b231e932696307805abec14 (diff)
downloadgo-bad327a9d33e61c1c5f9056a2beedec9abe545cc.tar.gz
cmd/5g, cmd/8g: zero ambiguously live values on entry
The code here is being restored after its deletion in CL 14430048. I restored the copy in cmd/6g in CL 56430043 but neglected the other two. This is the reason that enabling precisestack only worked on amd64. LGTM=r R=r CC=golang-codereviews https://codereview.appspot.com/66170043
Diffstat (limited to 'src/cmd/5g')
-rw-r--r--src/cmd/5g/ggen.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/cmd/5g/ggen.c b/src/cmd/5g/ggen.c
index 18431c2bf..b9930f49e 100644
--- a/src/cmd/5g/ggen.c
+++ b/src/cmd/5g/ggen.c
@@ -9,10 +9,13 @@
#include "gg.h"
#include "opt.h"
+static Prog* appendpp(Prog*, int, int, int, int32, int, int, int32);
+
void
defframe(Prog *ptxt)
{
uint32 frame;
+ Prog *p, *p1;
// fill in argument size
ptxt->to.type = D_CONST2;
@@ -24,6 +27,41 @@ defframe(Prog *ptxt)
frame = rnd(maxstksize+maxarg, widthptr);
ptxt->to.offset = frame;
maxstksize = 0;
+
+ p = ptxt;
+ if(stkzerosize > 0) {
+ p = appendpp(p, AMOVW, D_CONST, NREG, 0, D_REG, 0, 0);
+ p = appendpp(p, AADD, D_CONST, NREG, 4+frame-stkzerosize, D_REG, 1, 0);
+ p->reg = REGSP;
+ p = appendpp(p, AADD, D_CONST, NREG, stkzerosize, D_REG, 2, 0);
+ p->reg = 1;
+ p1 = p = appendpp(p, AMOVW, D_REG, 0, 0, D_OREG, 1, 4);
+ p->scond |= C_PBIT;
+ p = appendpp(p, ACMP, D_REG, 1, 0, D_NONE, 0, 0);
+ p->reg = 2;
+ p = appendpp(p, ABNE, D_NONE, NREG, 0, D_BRANCH, NREG, 0);
+ patch(p, p1);
+ }
+}
+
+static Prog*
+appendpp(Prog *p, int as, int ftype, int freg, int32 foffset, int ttype, int treg, int32 toffset)
+{
+ Prog *q;
+
+ q = mal(sizeof(*q));
+ clearp(q);
+ q->as = as;
+ q->lineno = p->lineno;
+ q->from.type = ftype;
+ q->from.reg = freg;
+ q->from.offset = foffset;
+ q->to.type = ttype;
+ q->to.reg = treg;
+ q->to.offset = toffset;
+ q->link = p->link;
+ p->link = q;
+ return q;
}
// Sweep the prog list to mark any used nodes.