From 3b9d27164630069b388bccbe36552d34b3e39e39 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 12 Nov 2022 11:37:49 -0500 Subject: [PATCH] agx: Assert more invariants in RA Was helpful for debugging. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_register_allocate.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/asahi/compiler/agx_register_allocate.c b/src/asahi/compiler/agx_register_allocate.c index f18d1ed7899..8aeceb48c0b 100644 --- a/src/asahi/compiler/agx_register_allocate.c +++ b/src/asahi/compiler/agx_register_allocate.c @@ -88,6 +88,8 @@ agx_split_width(const agx_instr *I) static unsigned find_regs(BITSET_WORD *used_regs, unsigned count, unsigned align, unsigned max) { + assert(count >= 1); + for (unsigned reg = 0; reg < max; reg += align) { if (!BITSET_TEST_RANGE(used_regs, reg, reg + count - 1)) return reg; @@ -137,6 +139,7 @@ assign_regs(struct ra_ctx *rctx, agx_index v, unsigned reg) assert(!BITSET_TEST(rctx->visited, v.value) && "SSA violated"); BITSET_SET(rctx->visited, v.value); + assert(rctx->ncomps[v.value] >= 1); unsigned end = reg + rctx->ncomps[v.value] - 1; assert(!BITSET_TEST_RANGE(rctx->used_regs, reg, end) && "no interference"); BITSET_SET_RANGE(rctx->used_regs, reg, end); @@ -162,6 +165,7 @@ pick_regs(struct ra_ctx *rctx, agx_instr *I, unsigned d) unsigned count = agx_write_registers(I, d); unsigned align = agx_size_align_16(idx.size); + assert(count >= 1); /* Try to allocate collects compatibly with their sources */ if (I->op == AGX_OPCODE_COLLECT) { @@ -278,6 +282,7 @@ agx_ra_assign_local(struct ra_ctx *rctx) unsigned reg = ssa_to_reg[I->src[s].value]; unsigned count = ncomps[I->src[s].value]; + assert(count >= 1); BITSET_CLEAR_RANGE(used_regs, reg, reg + count - 1); } }