spirv: Move cursor before calling vtn_ssa_value() in phi 2nd pass.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 9 Jan 2017 07:03:25 +0000 (23:03 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 10 Jan 2017 00:52:02 +0000 (16:52 -0800)
vtn_ssa_value() can produce variable loads, and the cursor might
be after a return statement, causing nir_builder assert failures
about not inserting instructions after a jump.

This fixes:
dEQP-VK.spirv_assembly.instruction.graphics.barrier.in_if
dEQP-VK.spirv_assembly.instruction.graphics.barrier.in_switch

Cc: "13.0 12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/spirv/vtn_cfg.c

index 62b9056990e39d091bed24c1d88f084496fcb0ff..3a31657e09945eb8c48d136c7947f039309eab87 100644 (file)
@@ -527,12 +527,13 @@ vtn_handle_phi_second_pass(struct vtn_builder *b, SpvOp opcode,
    nir_variable *phi_var = phi_entry->data;
 
    for (unsigned i = 3; i < count; i += 2) {
-      struct vtn_ssa_value *src = vtn_ssa_value(b, w[i]);
       struct vtn_block *pred =
          vtn_value(b, w[i + 1], vtn_value_type_block)->block;
 
       b->nb.cursor = nir_after_instr(&pred->end_nop->instr);
 
+      struct vtn_ssa_value *src = vtn_ssa_value(b, w[i]);
+
       vtn_local_store(b, src, nir_deref_var_create(b, phi_var));
    }