ra: assert against unsigned underflow in q_total
authorConnor Abbott <cwabbott0@gmail.com>
Sat, 6 Sep 2014 00:59:32 +0000 (20:59 -0400)
committerAndreas Boll <andreas.boll.dev@gmail.com>
Fri, 12 Sep 2014 14:07:47 +0000 (16:07 +0200)
q_total should never go below 0 (which is why it's defined as unsigned),
and if it does, then something is seriously wrong.

Signed-off-by: Connor Abbott <cwabbott0@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/program/register_allocate.c

index db2be5dfad4ec38a5d6a79678c9dff0462b68dd0..7faf67215c84440f2bbf43684185b9f8ae8e1a93 100644 (file)
@@ -434,6 +434,7 @@ decrement_q(struct ra_graph *g, unsigned int n)
       unsigned int n2_class = g->nodes[n2].class;
 
       if (n != n2 && !g->nodes[n2].in_stack) {
+         assert(g->nodes[n2].q_total >= g->regs->classes[n2_class]->q[n_class]);
         g->nodes[n2].q_total -= g->regs->classes[n2_class]->q[n_class];
       }
    }