From: Dave Airlie Date: Mon, 19 Nov 2018 03:51:48 +0000 (+1000) Subject: nir: move getting deref from var after we check deref type. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=760859cac219d9ea4d29f58351161ea8de0bcc44;hp=2f4f5a5055c74a35916645ed6eb2f8bd8ca7d221;p=mesa.git nir: move getting deref from var after we check deref type. I posted a load of hacks before to do this, Jason suggested this, just check the deref mode, not the variable mode and delay getting the variable until we know the type. avoids crashes when derefing shared memory pointers. Reviewed-by: Jason Ekstrand --- diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c index 15d38f036b5..7eaa4c27c1f 100644 --- a/src/compiler/nir/nir_gather_info.c +++ b/src/compiler/nir/nir_gather_info.c @@ -210,10 +210,9 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader, case nir_intrinsic_load_deref: case nir_intrinsic_store_deref:{ nir_deref_instr *deref = nir_src_as_deref(instr->src[0]); - nir_variable *var = nir_deref_instr_get_variable(deref); - - if (var->data.mode == nir_var_shader_in || - var->data.mode == nir_var_shader_out) { + if (deref->mode == nir_var_shader_in || + deref->mode == nir_var_shader_out) { + nir_variable *var = nir_deref_instr_get_variable(deref); bool is_output_read = false; if (var->data.mode == nir_var_shader_out && instr->intrinsic == nir_intrinsic_load_deref)