nir/spirv: Use instr_rewrite_src for updating phi sources
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 29 Dec 2015 23:44:37 +0000 (15:44 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 29 Dec 2015 23:44:39 +0000 (15:44 -0800)
You can't just add a new source to a phi because use/def information won't
get updated properly.  Instead, you have to use one of the core helpers.
Some day, we may want to add a nir_phi_instr_add_src helper.

src/glsl/nir/spirv/spirv_to_nir.c

index da58653352983d73adccc4317e05aa4ebfc6b718..b6e38704887da2d105bd2c1b7b3c1589e3b5c2b2 100644 (file)
@@ -3039,8 +3039,10 @@ vtn_phi_node_add_src(struct vtn_ssa_value *phi, const nir_block *pred,
       nir_phi_instr *phi_instr = nir_instr_as_phi(phi->def->parent_instr);
       nir_phi_src *src = ralloc(phi_instr, nir_phi_src);
       src->pred = (nir_block *) pred;
-      src->src = nir_src_for_ssa(val->def);
+      src->src = NIR_SRC_INIT;
       exec_list_push_tail(&phi_instr->srcs, &src->node);
+      nir_instr_rewrite_src(&phi_instr->instr, &src->src,
+                            nir_src_for_ssa(val->def));
    } else {
       unsigned elems = glsl_get_length(phi->type);
       for (unsigned i = 0; i < elems; i++)