[Mesa-dev] [PATCH v2 006.1/129] FIXUP! Don't reach through casts in get_variable

Jason Ekstrand jason at jlekstrand.net
Sat Jun 2 00:51:01 UTC 2018


If something uses get_variable, it's likely that it doesn't know what to
do with casts.  If there are any casts in the chain, just return NULL.
---
 src/compiler/nir/nir.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 8b826d8..00c34f3 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1015,8 +1015,12 @@ nir_deref_instr_parent(const nir_deref_instr *instr)
 static inline nir_variable *
 nir_deref_instr_get_variable(const nir_deref_instr *instr)
 {
-   while (instr->deref_type != nir_deref_type_var)
+   while (instr->deref_type != nir_deref_type_var) {
+      if (instr->deref_type == nir_deref_type_cast)
+         return NULL;
+
       instr = nir_deref_instr_parent(instr);
+   }
 
    return instr->var;
 }
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list