nir/validate: Don't allow derefs in if conditions
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 4 Jan 2019 17:11:49 +0000 (11:11 -0600)
committerJason Ekstrand <jason@jlekstrand.net>
Tue, 8 Jan 2019 00:38:30 +0000 (00:38 +0000)
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
src/compiler/nir/nir_validate.c

index 9f8455d21ccc01a994654dfa79d0d5dc72883e72..df1e7b330044ebbbf1b65b465cb557b1bc52caea 100644 (file)
@@ -493,6 +493,12 @@ validate_deref_instr(nir_deref_instr *instr, validate_state *state)
     * pointers should be.
     */
    validate_dest(&instr->dest, state, 0, 0);
+
+   /* Deref instructions as if conditions don't make sense because if
+    * conditions expect well-formed Booleans.  If you want to compare with
+    * NULL, an explicit comparison operation should be used.
+    */
+   validate_assert(state, list_empty(&instr->dest.ssa.if_uses));
 }
 
 static void