From 5f04a61219fadf8e4e99fe1254674c6b3258a28a Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 29 Dec 2015 14:51:45 -0800 Subject: [PATCH] nir/lower_returns: Don't just change the type of a jump. It doesn't give core NIR the opportunity to update predecessors and successors. Instead, we have to remove and re-insert the instruction. --- src/glsl/nir/nir_lower_returns.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/glsl/nir/nir_lower_returns.c b/src/glsl/nir/nir_lower_returns.c index dcdd14e2026..af16676b822 100644 --- a/src/glsl/nir/nir_lower_returns.c +++ b/src/glsl/nir/nir_lower_returns.c @@ -144,8 +144,10 @@ lower_returns_in_block(nir_block *block, struct lower_returns_state *state) if (jump->type != nir_jump_return) return false; + nir_instr_remove(&jump->instr); + nir_builder *b = &state->builder; - b->cursor = nir_before_instr(&jump->instr); + b->cursor = nir_after_block(block); /* Set the return flag */ if (state->return_flag == NULL) { @@ -159,14 +161,11 @@ lower_returns_in_block(nir_block *block, struct lower_returns_state *state) nir_store_var(b, state->return_flag, nir_imm_int(b, NIR_TRUE), 1); if (state->loop) { - /* We're in a loop. Make the return a break. */ - jump->type = nir_jump_break; + /* We're in a loop; we need to break out of it. */ + nir_jump(b, nir_jump_break); } else { - /* Not in a loop. Just delete the return; we'll deal with - * predicating later. - */ + /* Not in a loop; we'll deal with predicating later*/ assert(nir_cf_node_next(&block->cf_node) == NULL); - nir_instr_remove(&jump->instr); } return true; -- 2.30.2