summaryrefslogtreecommitdiff
path: root/6/isel.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-09-27 22:52:17 -0700
committerOri Bernstein <ori@eigenstate.org>2015-09-27 22:52:17 -0700
commitc8c4b88ecadf05438561c05f97500e35843218c4 (patch)
tree950afbb15a71d129fdf5bab862ebe8d17eaeac59 /6/isel.c
parentac306beff772b0a894ca95e0e0d0fe3029c7f8e4 (diff)
downloadmc-c8c4b88ecadf05438561c05f97500e35843218c4.tar.gz
Don't index directly off of %rax.
We use it for function returns. We also use it for environment of called closures. This means we clobbered it. Oops.
Diffstat (limited to '6/isel.c')
-rw-r--r--6/isel.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/6/isel.c b/6/isel.c
index 0d8637c..7eee71c 100644
--- a/6/isel.c
+++ b/6/isel.c
@@ -104,7 +104,7 @@ static Loc *varloc(Isel *s, Node *n)
l = locmeml(htget(s->globls, n), rip, NULL, mode(n));
} else if (hthas(s->envoff, n)) {
off = ptoi(htget(s->envoff, n));
- l = locmem(off, locphysreg(Rrax), NULL, mode(n));
+ l = locmem(off, s->envp, NULL, mode(n));
} else if (hthas(s->stkoff, n)) {
off = ptoi(htget(s->stkoff, n));
l = locmem(-off, locphysreg(Rrbp), NULL, mode(n));
@@ -980,6 +980,8 @@ static void prologue(Isel *s, Func *fn, size_t sz)
g(s, Imov, phys, s->calleesave[i], NULL);
}
}
+ if (s->envp)
+ g(s, Imov, locphysreg(Rrax), s->envp, NULL);
addarglocs(s, fn);
s->nsaved = i;
s->stksz = stksz; /* need to update if we spill */