nir/propagate_invariant: Don't add NULL vars to the hash table

Fixes: 8410cf66d "nir/propagate_invariant: Skip unknown vars"
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Jason Ekstrand 2019-06-05 16:54:40 -05:00
parent 1c30d26d89
commit d96878a66a
1 changed files with 10 additions and 1 deletions

View File

@ -65,12 +65,21 @@ add_cf_node(nir_cf_node *cf, struct set *invariants)
static void
add_var(nir_variable *var, struct set *invariants)
{
_mesa_set_add(invariants, var);
/* Because we pass the result of nir_intrinsic_get_var directly to this
* function, it's possible for var to be NULL if, for instance, there's a
* cast somewhere in the chain.
*/
if (var != NULL)
_mesa_set_add(invariants, var);
}
static bool
var_is_invariant(nir_variable *var, struct set * invariants)
{
/* Because we pass the result of nir_intrinsic_get_var directly to this
* function, it's possible for var to be NULL if, for instance, there's a
* cast somewhere in the chain.
*/
return var && (var->data.invariant || _mesa_set_search(invariants, var));
}