i965/fs: don't read from uninitialized memory while assigning registers
authorConnor Abbott <cwabbott0@gmail.com>
Fri, 8 Aug 2014 21:57:27 +0000 (14:57 -0700)
committerMatt Turner <mattst88@gmail.com>
Sun, 10 Aug 2014 22:00:52 +0000 (15:00 -0700)
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Connor Abbott <connor.abbott@intel.com>
src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp

index 3f273642200a9ab4e4ec82a4f8c3cde6cab4dae1..2233621b3cd995fe727a4e38331c43fa7bdd13bf 100644 (file)
@@ -56,9 +56,9 @@ fs_visitor::assign_regs_trivial()
 
    foreach_in_list(fs_inst, inst, &instructions) {
       assign_reg(hw_reg_mapping, &inst->dst, reg_width);
-      assign_reg(hw_reg_mapping, &inst->src[0], reg_width);
-      assign_reg(hw_reg_mapping, &inst->src[1], reg_width);
-      assign_reg(hw_reg_mapping, &inst->src[2], reg_width);
+      for (i = 0; i < inst->sources; i++) {
+         assign_reg(hw_reg_mapping, &inst->src[i], reg_width);
+      }
    }
 
    if (this->grf_used >= max_grf) {
@@ -518,9 +518,9 @@ fs_visitor::assign_regs(bool allow_spilling)
 
    foreach_in_list(fs_inst, inst, &instructions) {
       assign_reg(hw_reg_mapping, &inst->dst, reg_width);
-      assign_reg(hw_reg_mapping, &inst->src[0], reg_width);
-      assign_reg(hw_reg_mapping, &inst->src[1], reg_width);
-      assign_reg(hw_reg_mapping, &inst->src[2], reg_width);
+      for (int i = 0; i < inst->sources; i++) {
+         assign_reg(hw_reg_mapping, &inst->src[i], reg_width);
+      }
    }
 
    ralloc_free(g);