Browse Source

treat retc as non-escaping

We may well treat all rets as
non-escaping since stack slots
are destroyed upon funcion
return.
Quentin Carbonneaux 3 years ago
parent
commit
c5ea06c136
2 changed files with 12 additions and 1 deletions
  1. 2 1
      alias.c
  2. 10 0
      mem.c

+ 2 - 1
alias.c

@@ -192,6 +192,7 @@ fillalias(Fn *fn)
 				}
 				}
 			}
 			}
 		}
 		}
-		esc(b->jmp.arg, fn);
+		if (b->jmp.type != Jretc)
+			esc(b->jmp.arg, fn);
 	}
 	}
 }
 }

+ 10 - 0
mem.c

@@ -302,6 +302,11 @@ coalesce(Fn *fn)
 		assert(t->ndef == 1 && t->def);
 		assert(t->ndef == 1 && t->def);
 		*t->def = (Ins){.op = Onop};
 		*t->def = (Ins){.op = Onop};
 		for (u=t->use; u<&t->use[t->nuse]; u++) {
 		for (u=t->use; u<&t->use[t->nuse]; u++) {
+			if (u->type == UJmp) {
+				b = fn->rpo[u->bid];
+				b->jmp.arg = CON_Z;
+				continue;
+			}
 			assert(u->type == UIns);
 			assert(u->type == UIns);
 			i = u->u.ins;
 			i = u->u.ins;
 			/* make loads crash */
 			/* make loads crash */
@@ -357,6 +362,11 @@ coalesce(Fn *fn)
 		assert(t->ndef == 1 && t->def);
 		assert(t->ndef == 1 && t->def);
 		*t->def = (Ins){.op = Onop};
 		*t->def = (Ins){.op = Onop};
 		for (u=t->use; u<&t->use[t->nuse]; u++) {
 		for (u=t->use; u<&t->use[t->nuse]; u++) {
+			if (u->type == UJmp) {
+				b = fn->rpo[u->bid];
+				b->jmp.arg = TMP(s->s->t);
+				continue;
+			}
 			assert(u->type == UIns);
 			assert(u->type == UIns);
 			arg = u->u.ins->arg;
 			arg = u->u.ins->arg;
 			for (n=0; n<2; n++)
 			for (n=0; n<2; n++)