Mesa (master): nv50: preallocate TEMPs written first time in a subroutine

Christoph Bumiller chrisbmr at kemper.freedesktop.org
Thu Jan 7 20:20:07 UTC 2010


Module: Mesa
Branch: master
Commit: 7fc5fcada5600b401d23a29a4a3d1a09e3492d1c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7fc5fcada5600b401d23a29a4a3d1a09e3492d1c

Author: Christoph Bumiller <e0425955 at student.tuwien.ac.at>
Date:   Thu Jan  7 21:17:13 2010 +0100

nv50: preallocate TEMPs written first time in a subroutine

Otherwise we risk overwriting them with temporary GPRs if
they're not used immediately after the CALL.

---

 src/gallium/drivers/nv50/nv50_program.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c
index b1bac44..53f9f0a 100644
--- a/src/gallium/drivers/nv50/nv50_program.c
+++ b/src/gallium/drivers/nv50/nv50_program.c
@@ -2911,7 +2911,7 @@ nv50_program_tx_insn(struct nv50_pc *pc,
 static void
 prep_inspect_insn(struct nv50_pc *pc, const struct tgsi_full_instruction *insn)
 {
-	struct nv50_reg *reg = NULL;
+	struct nv50_reg *r, *reg = NULL;
 	const struct tgsi_full_src_register *src;
 	const struct tgsi_dst_register *dst;
 	unsigned i, c, k, mask;
@@ -2957,7 +2957,15 @@ prep_inspect_insn(struct nv50_pc *pc, const struct tgsi_full_instruction *insn)
 				continue;
 			k = tgsi_util_get_full_src_register_swizzle(src, c);
 
-			reg[src->Register.Index * 4 + k].acc = pc->insn_nr;
+			r = &reg[src->Register.Index * 4 + k];
+
+			/* If used before written, pre-allocate the reg,
+			 * lest we overwrite results from a subroutine.
+			 */
+			if (!r->acc && r->type == P_TEMP)
+				alloc_reg(pc, r);
+
+			r->acc = pc->insn_nr;
 		}
 	}
 }




More information about the mesa-commit mailing list