qbe

Internal scc patchset buffer for QBE
Log | Files | Refs | README | LICENSE

commit 2e7d6b24eaa1314eb4fe663ef5dc529e461fb8ce
parent 4b7f02c09710b379a706708ae5880a1811519539
Author: Quentin Carbonneaux <quentin@c9x.me>
Date:   Thu,  2 May 2019 20:26:16 +0200

revert heuristic to reuse stack slots

The heuristic was bogus for at least
two reasons (see below), and, looking
at some generated code, it looks like
some other issues are more pressing.

 1. A stack slot of 4 bytes could be
    used for a temporary of 8 bytes.
 2. Should 2 arguments of an operation
    end up spilled, the same slot
    could be allocated to both!

Diffstat:
Mspill.c | 16++--------------
1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/spill.c b/spill.c @@ -309,7 +309,7 @@ void spill(Fn *fn) { Blk *b, *s1, *s2, *hd, **bp; - int j, l, t, k, s, lvarg[2]; + int j, l, t, k, lvarg[2]; uint n; BSet u[1], v[1], w[1]; Ins *i; @@ -404,11 +404,9 @@ spill(Fn *fn) continue; } bszero(w); - s = -1; if (!req(i->to, R)) { assert(rtype(i->to) == RTmp); t = i->to.val; - s = tmp[t].slot; if (bshas(v, t)) bsclr(v, t); else { @@ -442,13 +440,6 @@ spill(Fn *fn) bsset(v, t); if (j-- <= 0) bsset(w, t); - else if (!lvarg[n]) { - /* recycle the slot of - * i->to when possible - */ - if (tmp[t].slot == -1) - tmp[t].slot = s; - } break; } bscopy(u, v); @@ -456,10 +447,7 @@ spill(Fn *fn) for (n=0; n<2; n++) if (rtype(i->arg[n]) == RTmp) { t = i->arg[n].val; - if (bshas(v, t)) { - if (tmp[t].slot == s) - tmp[t].slot = -1; - } else { + if (!bshas(v, t)) { /* do not reload if the * argument is dead */