Selaa lähdekoodia

move some liveness code where it belongs

Quentin Carbonneaux 9 vuotta sitten
vanhempi
sitoutus
a9bc0541b5
2 muutettua tiedostoa jossa 10 lisäystä ja 16 poistoa
  1. 3 1
      live.c
  2. 7 15
      spill.c

+ 3 - 1
live.c

@@ -13,8 +13,10 @@ liveon(BSet *v, Blk *b, Blk *s)
 	for (p=s->phi; p; p=p->link)
 	for (p=s->phi; p; p=p->link)
 		for (a=0; a<p->narg; a++)
 		for (a=0; a<p->narg; a++)
 			if (p->blk[a] == b)
 			if (p->blk[a] == b)
-			if (rtype(p->arg[a]) == RTmp)
+			if (rtype(p->arg[a]) == RTmp) {
 				bsset(v, p->arg[a].val);
 				bsset(v, p->arg[a].val);
+				bsset(b->gen, p->arg[a].val);
+			}
 }
 }
 
 
 static int
 static int

+ 7 - 15
spill.c

@@ -1,22 +1,14 @@
 #include "all.h"
 #include "all.h"
 
 
 static void
 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;
 		return;
-	for (; p; p=p->link)
-		for (a=0; a<p->narg; 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;
 	b->loop *= 10;
 	/* aggregate looping information at
 	/* aggregate looping information at
 	 * loop headers */
 	 * loop headers */
@@ -25,7 +17,7 @@ loopmark(Blk *hd, Blk *b, Phi *p)
 		if (b->nlive[k] > hd->nlive[k])
 		if (b->nlive[k] > hd->nlive[k])
 			hd->nlive[k] = b->nlive[k];
 			hd->nlive[k] = b->nlive[k];
 	for (n=0; n<b->npred; n++)
 	for (n=0; n<b->npred; n++)
-		loopmark(hd, b->pred[n], b->phi);
+		loopmark(hd, b->pred[n]);
 }
 }
 
 
 static void
 static void
@@ -72,7 +64,7 @@ fillcost(Fn *fn)
 		hd = 0;
 		hd = 0;
 		for (a=0; a<b->npred; a++)
 		for (a=0; a<b->npred; a++)
 			if (b->pred[a]->id >= n) {
 			if (b->pred[a]->id >= n) {
-				loopmark(b, b->pred[a], b->phi);
+				loopmark(b, b->pred[a]);
 				hd = 1;
 				hd = 1;
 			}
 			}
 		if (hd && debug['S']) {
 		if (hd && debug['S']) {