nir/vars_to_ssa: Use a non-null UNDEF_NODE pointer

We're about to change the meaning of get_deref_node returning NULL so we
need a non-NULL value to mean properly undefined.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
This commit is contained in:
Jason Ekstrand 2019-05-22 18:01:14 -05:00
parent e84194686d
commit 911ea2c66f

View file

@ -61,6 +61,8 @@ struct deref_node {
struct deref_node *children[0]; struct deref_node *children[0];
}; };
#define UNDEF_NODE ((struct deref_node *)(uintptr_t)1)
struct lower_variables_state { struct lower_variables_state {
nir_shader *shader; nir_shader *shader;
void *dead_ctx; void *dead_ctx;
@ -169,7 +171,7 @@ get_deref_node_recur(nir_deref_instr *deref,
* somewhat gracefully. * somewhat gracefully.
*/ */
if (index >= glsl_get_length(parent->type)) if (index >= glsl_get_length(parent->type))
return NULL; return UNDEF_NODE;
if (parent->children[index] == NULL) { if (parent->children[index] == NULL) {
parent->children[index] = parent->children[index] =
@ -508,7 +510,7 @@ rename_variables(struct lower_variables_state *state)
continue; continue;
struct deref_node *node = get_deref_node(deref, state); struct deref_node *node = get_deref_node(deref, state);
if (node == NULL) { if (node == UNDEF_NODE) {
/* If we hit this path then we are referencing an invalid /* If we hit this path then we are referencing an invalid
* value. Most likely, we unrolled something and are * value. Most likely, we unrolled something and are
* reading past the end of some array. In any case, this * reading past the end of some array. In any case, this
@ -562,7 +564,7 @@ rename_variables(struct lower_variables_state *state)
assert(intrin->src[1].is_ssa); assert(intrin->src[1].is_ssa);
nir_ssa_def *value = intrin->src[1].ssa; nir_ssa_def *value = intrin->src[1].ssa;
if (node == NULL) { if (node == UNDEF_NODE) {
/* Probably an out-of-bounds array store. That should be a /* Probably an out-of-bounds array store. That should be a
* no-op. */ * no-op. */
nir_instr_remove(&intrin->instr); nir_instr_remove(&intrin->instr);