summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--arm64/abi.c1
-rw-r--r--spill.c6
2 files changed, 6 insertions, 1 deletions
diff --git a/arm64/abi.c b/arm64/abi.c
index d38dcf5..8209944 100644
--- a/arm64/abi.c
+++ b/arm64/abi.c
@@ -448,6 +448,7 @@ selpar(Fn *fn, Ins *i0, Ins *i1)
 		if (cr.class & Cptr) {
 			fn->retr = newtmp("abi", Kl, fn);
 			emit(Ocopy, Kl, fn->retr, TMP(R8), R);
+			fn->reg |= BIT(R8);
 		}
 	}
 
diff --git a/spill.c b/spill.c
index baceccc..4c11d9f 100644
--- a/spill.c
+++ b/spill.c
@@ -428,6 +428,7 @@ spill(Fn *fn)
 				else {
 					/* make sure we have a reg
 					 * for the result */
+					assert(t >= Tmp0 && "dead reg");
 					bsset(v, t);
 					bsset(w, t);
 				}
@@ -476,7 +477,10 @@ spill(Fn *fn)
 			if (!req(i->to, R)) {
 				t = i->to.val;
 				store(i->to, tmp[t].slot);
-				bsclr(v, t);
+				if (t >= Tmp0)
+					/* in case i->to was a
+					 * dead temporary */
+					bsclr(v, t);
 			}
 			emiti(*i);
 			r = v->t[0]; /* Tmp0 is NBit */