From 664cc248b340d58907be9146a779612f38e5cfb9 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Thu, 21 Oct 2021 11:35:28 +0200 Subject: [PATCH] broadcom/compiler: fix assert that current instruction must be in current block This was not considering the possibility that the driver has called nir_before_block() or nir_after_block() to update the cursor, in which case the cursor link points to the instruction list header and not to an actual instruction. Fixes incorrect debug-assert crash in: dEQP-VK.graphicsfuzz.cov-increment-vector-component-with-matrix-copy Fixes: 265515fa62 ("broadcom/compiler: check instruction belongs to current block") Reviewed-by: Juan A. Suarez Part-of: (cherry picked from commit 1561d0126a569f76b1adbdd1a5e8ec79f9577450) --- .pick_status.json | 2 +- src/broadcom/compiler/vir.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index b07b5678cda..358210b5a4c 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -841,7 +841,7 @@ "description": "broadcom/compiler: fix assert that current instruction must be in current block", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "265515fa62664eac006dcff278ed549c75863b79" }, diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c index 27869a35a3b..bf75a4da170 100644 --- a/src/broadcom/compiler/vir.c +++ b/src/broadcom/compiler/vir.c @@ -1873,7 +1873,10 @@ try_opt_ldunif(struct v3d_compile *c, uint32_t index, struct qreg *unif) assert(c->cur_block); #ifdef DEBUG - /* Check if the current instruction is part of the current block */ + /* We can only reuse a uniform if it was emitted in the same block, + * so callers must make sure the current instruction is being emitted + * in the current block. + */ bool found = false; vir_for_each_inst(inst, c->cur_block) { if (&inst->link == c->cursor.link) { @@ -1882,7 +1885,7 @@ try_opt_ldunif(struct v3d_compile *c, uint32_t index, struct qreg *unif) } } - assert(found || list_is_empty(&c->cur_block->instructions)); + assert(found || &c->cur_block->instructions == c->cursor.link); #endif list_for_each_entry_from_rev(struct qinst, inst, c->cursor.link->prev,