From a9bc0541b5e69f902758210eb3bfa275a53a07e0 Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Mon, 5 Dec 2016 02:51:31 -0500 Subject: [PATCH] move some liveness code where it belongs --- live.c | 4 +++- spill.c | 22 +++++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/live.c b/live.c index 09a4a25..be5ec8c 100644 --- a/live.c +++ b/live.c @@ -13,8 +13,10 @@ liveon(BSet *v, Blk *b, Blk *s) for (p=s->phi; p; p=p->link) for (a=0; anarg; a++) if (p->blk[a] == b) - if (rtype(p->arg[a]) == RTmp) + if (rtype(p->arg[a]) == RTmp) { bsset(v, p->arg[a].val); + bsset(b->gen, p->arg[a].val); + } } static int diff --git a/spill.c b/spill.c index e4dae28..f9dcc49 100644 --- a/spill.c +++ b/spill.c @@ -1,22 +1,14 @@ #include "all.h" static void -loopmark(Blk *hd, Blk *b, Phi *p) +loopmark(Blk *hd, Blk *b) { - int k, head; - uint n, a; + int k; + uint n; - head = hd->id; - if (b->id < head) + if (b->id < hd->id || b->visit == hd->id) return; - for (; p; p=p->link) - for (a=0; anarg; a++) - if (p->blk[a] == b) - if (rtype(p->arg[a]) == RTmp) - bsset(hd->gen, p->arg[a].val); - if (b->visit == head) - return; - b->visit = head; + b->visit = hd->id; b->loop *= 10; /* aggregate looping information at * loop headers */ @@ -25,7 +17,7 @@ loopmark(Blk *hd, Blk *b, Phi *p) if (b->nlive[k] > hd->nlive[k]) hd->nlive[k] = b->nlive[k]; for (n=0; nnpred; n++) - loopmark(hd, b->pred[n], b->phi); + loopmark(hd, b->pred[n]); } static void @@ -72,7 +64,7 @@ fillcost(Fn *fn) hd = 0; for (a=0; anpred; a++) if (b->pred[a]->id >= n) { - loopmark(b, b->pred[a], b->phi); + loopmark(b, b->pred[a]); hd = 1; } if (hd && debug['S']) {