Browse Source

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!
Quentin Carbonneaux 6 years ago
parent
commit
2e7d6b24ea
1 changed files with 2 additions and 14 deletions
  1. 2 14
      spill.c

+ 2 - 14
spill.c

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