Mesa (19.1): nir/propagate_invariant: Don't add NULL vars to the hash table

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 11 14:12:01 UTC 2019


Module: Mesa
Branch: 19.1
Commit: 1f40ef24cc77331f7fe450a0d8e7e1199be217ba
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1f40ef24cc77331f7fe450a0d8e7e1199be217ba

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Wed Jun  5 16:54:40 2019 -0500

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 at whitecape.org>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
(cherry picked from commit d96878a66a559f6690f01e82f06fcf92ae958d3c)

---

 src/compiler/nir/nir_propagate_invariant.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_propagate_invariant.c b/src/compiler/nir/nir_propagate_invariant.c
index 103b2422b83..a0cfde67891 100644
--- a/src/compiler/nir/nir_propagate_invariant.c
+++ b/src/compiler/nir/nir_propagate_invariant.c
@@ -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));
 }
 




More information about the mesa-commit mailing list