diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-08-15 20:51:36 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-09-15 23:01:31 -0400 |
commit | 2b34ec6d2455da5990433e5ba23dd12d3995d03d (patch) | |
tree | c761955c6703397c768e156b081af5a3bc42d3fc /lisc | |
parent | bccfc34ca3f58a2e6706fa37bc0729a56f35bc1f (diff) | |
download | roux-2b34ec6d2455da5990433e5ba23dd12d3995d03d.tar.gz |
forgot about phi nodes in the spiller
When we are dealing with a block that is not a loop, we must make sure to consider phi arguments of successors as live variables. Ideally we could move the code to find all live-ins (including phi arguments) to the live module.
Diffstat (limited to 'lisc')
-rw-r--r-- | lisc/spill.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/lisc/spill.c b/lisc/spill.c index a0f6f38..f8a174f 100644 --- a/lisc/spill.c +++ b/lisc/spill.c @@ -255,6 +255,22 @@ setloc(Ref *pr, Bits *v, Bits *w) } } +static Bits +inregs(Blk *b, Blk *s) /* todo, move to live.c */ +{ + Bits v; + Phi *p; + uint a; + + v = s->in; + for (p=s->phi; p; p=p->link) + for (a=0; a<p->narg; a++) + if (p->blk[a] == b) + if (rtype(p->arg[a]) == RTmp) + BSET(v, p->arg[a].val); + return v; +} + /* spill code insertion * requires spill costs, rpo, liveness * @@ -274,7 +290,7 @@ spill(Fn *fn) { Blk *b, *s1, *s2, *hd; int n, z, l, t; - Bits v, w; + Bits u, v, w; Ins *i; int j, s; Phi *p; @@ -317,13 +333,15 @@ spill(Fn *fn) } else if (j > NReg) limit(&v, NReg, 0); } else if (s1) { - v = s1->in; - w = s1->in; - if (s2) + v = inregs(b, s1); + w = v; + if (s2) { + u = inregs(b, s2); for (z=0; z<BITS; z++) { - v.t[z] |= s2->in.t[z]; - w.t[z] &= s2->in.t[z]; + v.t[z] |= u.t[z]; + w.t[z] &= u.t[z]; } + } assert(bcnt(&w) <= NReg); limit(&v, NReg, &w); } |