summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Abbott <cwabbott0@gmail.com>2023-10-31 18:09:24 +0100
committerMarge Bot <emma+marge@anholt.net>2024-04-26 12:55:13 +0000
commitb309418380e6ed25135f31437d30c76a4ddec432 (patch)
treef5efaa853a2009af273ff927f9bb6214d8a674f8
parent468f070a911607db10acc50e505c0f1a1bd956f2 (diff)
ir3: Validate that shared registers are in-bound
This would've caught some bugs with copy lowering. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22075>
-rw-r--r--src/freedreno/ir3/ir3_validate.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/freedreno/ir3/ir3_validate.c b/src/freedreno/ir3/ir3_validate.c
index 63e0680fd8d..45c6c4ef866 100644
--- a/src/freedreno/ir3/ir3_validate.c
+++ b/src/freedreno/ir3/ir3_validate.c
@@ -69,6 +69,15 @@ reg_class_flags(struct ir3_register *reg)
}
static void
+validate_reg(struct ir3_validate_ctx *ctx, struct ir3_register *reg)
+{
+ if ((reg->flags & IR3_REG_SHARED) && reg->num != INVALID_REG) {
+ validate_assert(ctx, reg->num >= SHARED_REG_START);
+ validate_assert(ctx, reg->num - SHARED_REG_START < SHARED_REG_SIZE);
+ }
+}
+
+static void
validate_src(struct ir3_validate_ctx *ctx, struct ir3_instruction *instr,
struct ir3_register *reg)
{
@@ -104,6 +113,8 @@ validate_src(struct ir3_validate_ctx *ctx, struct ir3_instruction *instr,
validate_assert(ctx,
found && "tied register not in the same instruction");
}
+
+ validate_reg(ctx, reg);
}
/* phi sources are logically read at the end of the predecessor basic block,
@@ -162,6 +173,8 @@ validate_dst(struct ir3_validate_ctx *ctx, struct ir3_instruction *instr,
if (reg->flags & IR3_REG_RELATIV)
validate_assert(ctx, instr->address);
+
+ validate_reg(ctx, reg);
}
#define validate_reg_size(ctx, reg, type) \