From 2b34ec6d2455da5990433e5ba23dd12d3995d03d Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Sat, 15 Aug 2015 20:51:36 -0400 Subject: 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. --- lisc/spill.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'lisc/spill.c') 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; anarg; 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; zin.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); } -- cgit 1.4.1