summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2020-04-09 15:10:08 -0700
committerMarge Bot <[email protected]>2020-04-29 19:46:08 +0000
commita1de267a21acacc4c77bbb94127bfbf1caa4bfc8 (patch)
tree5bf60287a83dcc6cc84f7931342f91a53ae141a8 /src/util
parent5bcaf30aba08b718e913b10745df5e92854ed5b6 (diff)
util/ra: Sanity check that we're adding a valid reg to a class.
BITSET_SET might not segfault on you right away if you're just slightly off, and an assert is nicer anyway. Reviewed-by: Kenneth Graunke <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4537>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/register_allocate.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/util/register_allocate.c b/src/util/register_allocate.c
index a65b5ea154f..68d4a13ca1e 100644
--- a/src/util/register_allocate.c
+++ b/src/util/register_allocate.c
@@ -371,6 +371,8 @@ ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int r)
{
struct ra_class *class = regs->classes[c];
+ assert(r < regs->count);
+
BITSET_SET(class->regs, r);
class->p++;
}