nir: handle shared pointers in lowering indirect derefs.
authorDave Airlie <airlied@redhat.com>
Mon, 19 Nov 2018 03:54:33 +0000 (13:54 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 19 Nov 2018 19:36:52 +0000 (05:36 +1000)
Check if the base ends up with no variable, and continue
if we see that case outside the loop.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir_lower_indirect_derefs.c

index 897a0620872eabef5f8388d8ea5f37cddcd1b3fe..adcfaec219ff496a8dcd65182a5bb82ad2dbf607 100644 (file)
@@ -135,7 +135,7 @@ lower_indirect_derefs_block(nir_block *block, nir_builder *b,
       /* Walk the deref chain back to the base and look for indirects */
       bool has_indirect = false;
       nir_deref_instr *base = deref;
-      while (base->deref_type != nir_deref_type_var) {
+      while (base && base->deref_type != nir_deref_type_var) {
          if (base->deref_type == nir_deref_type_array &&
              !nir_src_is_const(base->arr.index))
             has_indirect = true;
@@ -143,7 +143,7 @@ lower_indirect_derefs_block(nir_block *block, nir_builder *b,
          base = nir_deref_instr_parent(base);
       }
 
-      if (!has_indirect)
+      if (!has_indirect || !base)
          continue;
 
       /* Only lower variables whose mode is in the mask, or compact