From 911ea2c66fc54c5066707f7fe4451ec573792ae7 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 22 May 2019 18:01:14 -0500 Subject: [PATCH] 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 Reviewed-by: Caio Marcelo de Oliveira Filho --- src/compiler/nir/nir_lower_vars_to_ssa.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/compiler/nir/nir_lower_vars_to_ssa.c b/src/compiler/nir/nir_lower_vars_to_ssa.c index 8771910f7e5..b1b26c1fbf2 100644 --- a/src/compiler/nir/nir_lower_vars_to_ssa.c +++ b/src/compiler/nir/nir_lower_vars_to_ssa.c @@ -61,6 +61,8 @@ struct deref_node { struct deref_node *children[0]; }; +#define UNDEF_NODE ((struct deref_node *)(uintptr_t)1) + struct lower_variables_state { nir_shader *shader; void *dead_ctx; @@ -169,7 +171,7 @@ get_deref_node_recur(nir_deref_instr *deref, * somewhat gracefully. */ if (index >= glsl_get_length(parent->type)) - return NULL; + return UNDEF_NODE; if (parent->children[index] == NULL) { parent->children[index] = @@ -508,7 +510,7 @@ rename_variables(struct lower_variables_state *state) continue; 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 * value. Most likely, we unrolled something and are * 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); 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 * no-op. */ nir_instr_remove(&intrin->instr); -- 2.30.2