From 3e40c2010e3bd24964ebcf67a8069277b1fce52d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 26 Nov 2024 22:01:57 -0500 Subject: [PATCH] nir/lower_clip: don't set cursor to fix crashes due to removed instructions The original builder already points at the end of the function impl. Just use that. Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_lower_clip.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/compiler/nir/nir_lower_clip.c b/src/compiler/nir/nir_lower_clip.c index 8aef1296b4e..878bc7135f1 100644 --- a/src/compiler/nir/nir_lower_clip.c +++ b/src/compiler/nir/nir_lower_clip.c @@ -161,7 +161,6 @@ static nir_def * find_output(nir_builder *b, unsigned location) { nir_def *comp[4] = {NULL}; - nir_instr *last_comp = NULL; nir_foreach_function_impl(impl, b->shader) { nir_foreach_block(block, impl) { @@ -184,9 +183,7 @@ find_output(nir_builder *b, unsigned location) /* Each component should be written only once. */ assert(!comp[index]); - b->cursor = nir_before_instr(&intr->instr); comp[index] = nir_channel(b, intr->src[0].ssa, i); - last_comp = comp[index]->parent_instr; } /* Remove it because it's going to be replaced by CLIP_DIST. */ @@ -196,11 +193,7 @@ find_output(nir_builder *b, unsigned location) } } } - - if (!last_comp) - return NULL; - - b->cursor = nir_after_instr(last_comp); + assert(comp[0] || comp[1] || comp[2] || comp[3]); for (unsigned i = 0; i < 4; i++) { if (!comp[i])