shithub: mc

Download patch

ref: 094e3fb0ee4dd4b8aaaca40da90bf770ae42674f
parent: 37c3a754daff7f53930a7d47987403e6e2357bc7
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Aug 24 17:41:21 EDT 2016

Don't eliminate all record of prepainted liveness.

	If we have a prepainted register that we coalesced, we
	can't eliminate the move, because that means we could
	clobber it.

--- a/6/ra.c
+++ b/6/ra.c
@@ -1129,13 +1129,14 @@
 	return remapped;
 }
 
-static int nopmov(Insn *insn)
+static int nopmov(Isel *s, Insn *insn)
 {
-	if (insn->op != Imov && insn->op != Imovs)
+	if (insn->op != Imov)
 		return 0;
 	if (insn->args[0]->type != Locreg || insn->args[1]->type != Locreg)
 		return 0;
-	return insn->args[0]->reg.id == insn->args[1]->reg.id;
+	/* Prepainted register moves need to be kept live to avoid coalescing over them */
+	return insn->args[0]->reg.id == insn->args[1]->reg.id && !bshas(s->prepainted, insn->args[0]->reg.id);
 }
 
 void replacealias(Isel *s, Loc **map, size_t nreg, Insn *insn)
@@ -1198,7 +1199,7 @@
 	for (j = bb->ni; j > 0; j--) {
 		insn = bb->il[j - 1];
 		replacealias(s, aliasmap, s->nreg, insn);
-		if (nopmov(insn))
+		if (nopmov(s, insn))
 			continue;
 		nuse = uses(insn, use);
 		ndef = defs(insn, def);