Mesa (master): nir: Add some asserts that we don't put derefs in phis

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Sep 19 07:01:26 UTC 2018


Module: Mesa
Branch: master
Commit: 976046a8d8f9bed8f805d09ac5aebe63b81a71d9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=976046a8d8f9bed8f805d09ac5aebe63b81a71d9

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Tue Sep 11 13:06:01 2018 -0500

nir: Add some asserts that we don't put derefs in phis

The lcssa and phis_to_regs passes are used by various NIR optimizations
that modify the CFG.  Putting a couple of asserts will help ensure that
we don't accidentally put derefs in phis as part of an optimization
pass.

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>

---

 src/compiler/nir/nir_from_ssa.c | 2 ++
 src/compiler/nir/nir_to_lcssa.c | 3 +++
 src/compiler/nir/nir_validate.c | 1 +
 3 files changed, 6 insertions(+)

diff --git a/src/compiler/nir/nir_from_ssa.c b/src/compiler/nir/nir_from_ssa.c
index 1aa35509b1..19d4bc3382 100644
--- a/src/compiler/nir/nir_from_ssa.c
+++ b/src/compiler/nir/nir_from_ssa.c
@@ -901,6 +901,8 @@ nir_lower_phis_to_regs_block(nir_block *block)
 
       nir_foreach_phi_src(src, phi) {
          assert(src->src.is_ssa);
+         /* We don't want derefs ending up in phi sources */
+         assert(!nir_src_as_deref(src->src));
          place_phi_read(shader, reg, src->src.ssa, src->pred);
       }
 
diff --git a/src/compiler/nir/nir_to_lcssa.c b/src/compiler/nir/nir_to_lcssa.c
index 9b3539193e..0f62fc3940 100644
--- a/src/compiler/nir/nir_to_lcssa.c
+++ b/src/compiler/nir/nir_to_lcssa.c
@@ -111,6 +111,9 @@ convert_loop_exit_for_ssa(nir_ssa_def *def, void *void_state)
    if (all_uses_inside_loop)
       return true;
 
+   /* We don't want derefs ending up in phi sources */
+   assert(def->parent_instr->type != nir_instr_type_deref);
+
    /* Initialize a phi-instruction */
    nir_phi_instr *phi = nir_phi_instr_create(state->shader);
    nir_ssa_dest_init(&phi->instr, &phi->dest,
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c
index 8e6f5bfb68..1852224b52 100644
--- a/src/compiler/nir/nir_validate.c
+++ b/src/compiler/nir/nir_validate.c
@@ -669,6 +669,7 @@ validate_phi_src(nir_phi_instr *instr, nir_block *pred, validate_state *state)
    nir_foreach_phi_src(src, instr) {
       if (src->pred == pred) {
          validate_assert(state, src->src.is_ssa);
+         validate_assert(state, src->src.ssa->parent_instr->type != nir_instr_type_deref);
          validate_src(&src->src, state, instr->dest.ssa.bit_size,
                       instr->dest.ssa.num_components);
          state->instr = NULL;




More information about the mesa-commit mailing list