<div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">On Dec 27, 2016 8:35 AM, "Jason Ekstrand" <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div class="quoted-text"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Dec 27, 2016 7:05 AM, "Eduardo Lima Mitev" <<a href="mailto:elima@igalia.com" target="_blank">elima@igalia.com</a>> wrote:<br type="attribution"><blockquote class="m_-2676053324317783919quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_-2676053324317783919quoted-text">On 12/26/2016 06:13 PM, Jason Ekstrand wrote:<br>
> We rename it to nir_deref_clone, re-order the sources to match the other<br>
> clone functions, and expose nir_deref_var_clone. This past part, in<br>
> particular, lets us get rid of quite a few lines since we no longer have<br>
> to call nir_copy_deref and wrap it in deref_to_var.<br>
> ---<br>
><br>
<br>
</div>This patch brings a number of regressions in piglit at least, crashing<br>
tests that were passing or failing before. All of them crash because<br>
nir_deref_var_clone() gets called with a null 'deref' argument. The<br>
attached diff fixes all crashes I found, but I only tried piglit, so<br>
there could be more. Maybe the solution is just adding a check for<br>
nullness to 'deref' argument inside nir_deref_var_clone() ?<br></blockquote></div></div></div><div dir="auto"><br></div></div><div dir="auto">I've already done that locally</div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">It turns or that I put the fix in a later patch that I didn't send out. I've pulled it into this patch and an running it through CI now. Thanks for catching it.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div class="elided-text"><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="m_-2676053324317783919quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The list of regressions are:<br>
<br>
spec/arb_shader_texture_lod/co<wbr>mpiler/tex_grad-texturecube-cu<wbr>be-vec3.frag<br>
<br>
spec/arb_shader_texture_lod/ex<wbr>ecution/arb_shader_texture_lod<wbr>-texgradcube<br>
<br>
spec/arb_shader_texture_lod/ex<wbr>ecution/tex-miplevel-selection *gradarb cube<br>
<br>
spec/arb_texture_cube_map_arra<wbr>y/compiler/tex_grad-01.frag<br>
<br>
spec/ext_image_dma_buf_import/<wbr>ext_image_dma_buf_import-sampl<wbr>e_nv12<br>
<br>
spec/ext_image_dma_buf_import/<wbr>ext_image_dma_buf_import-sampl<wbr>e_yuv420<br>
<br>
spec/ext_image_dma_buf_import/<wbr>ext_image_dma_buf_import-sampl<wbr>e_yvu420<br>
<br>
spec/glsl-1.30/execution/tex-m<wbr>iplevel-selection texturegrad cube<br>
<br>
spec/glsl-1.30/execution/tex-m<wbr>iplevel-selection texturegrad cubearray<br>
<br>
spec/glsl-1.30/execution/tex-m<wbr>iplevel-selection texturegrad cubeshadow<br>
<br>
<br>
An example gdb backtrace:<br>
<br>
Starting program: piglit/bin/glslparsertest<br>
generated_tests/spec/arb_shade<wbr>r_texture_lod/compiler/tex_<wbr>grad-textureCube-Cube-vec3.<wbr>frag<br>
pass 1.10 GL_ARB_shader_texture_lod<br>
[Thread debugging using libthread_db enabled]<br>
Using host libthread_db library "/lib/x86_64-linux-gnu/libthre<wbr>ad_db.so.1".<br>
<br>
Program received signal SIGSEGV, Segmentation fault.<br>
0x00007ffff1720f09 in nir_deref_var_clone (deref=0x0, mem_ctx=0x786c40)<br>
at nir/nir.c:630<br>
630 nir_deref_var *ret = nir_deref_var_create(mem_ctx, deref->var);<br>
(gdb) bt<br>
#0 0x00007ffff1720f09 in nir_deref_var_clone (deref=0x0,<br>
mem_ctx=0x786c40) at nir/nir.c:630<br>
#1 0x00007ffff1759f95 in get_texture_size (b=0x7fffffffd7e0,<br>
tex=0x782260) at nir/nir_lower_tex.c:168<br>
#2 0x00007ffff175af05 in lower_gradient_cube_map (b=0x7fffffffd7e0,<br>
tex=0x782260) at nir/nir_lower_tex.c:363<br>
#3 0x00007ffff175c6bc in nir_lower_tex_block (block=0x781000,<br>
b=0x7fffffffd7e0, options=0x7ffff1a42ce0 <tex_options>) at<br>
nir/nir_lower_tex.c:786<br>
#4 0x00007ffff175c78b in nir_lower_tex_impl (impl=0x780f10,<br>
options=0x7ffff1a42ce0 <tex_options>) at nir/nir_lower_tex.c:811<br>
#5 0x00007ffff175c810 in nir_lower_tex (shader=0x7878e0,<br>
options=0x7ffff1a42ce0 <tex_options>) at nir/nir_lower_tex.c:826<br>
#6 0x00007ffff18c7152 in brw_preprocess_nir (compiler=0x62e760,<br>
nir=0x7878e0) at brw_nir.c:494<br>
#7 0x00007ffff17c1b6b in brw_create_nir (brw=0x7ffff7f80040,<br>
shader_prog=0x8f42d0, prog=0x780680, stage=MESA_SHADER_FRAGMENT,<br>
is_scalar=true) at brw_program.c:93<br>
#8 0x00007ffff17b927e in brw_link_shader (ctx=0x7ffff7f80040,<br>
shProg=0x8f42d0) at brw_link.cpp:245<br>
#9 0x00007ffff162a676 in _mesa_glsl_link_shader (ctx=0x7ffff7f80040,<br>
prog=0x8f42d0) at program/ir_to_mesa.cpp:3066<br>
#10 0x00007ffff14bd7bc in _mesa_link_program (ctx=0x7ffff7f80040,<br>
shProg=0x8f42d0) at main/shaderapi.c:1089<br>
#11 0x00007ffff14be87d in _mesa_LinkProgram (programObj=2) at<br>
main/shaderapi.c:1595<br>
#12 0x00007ffff7ac9c3d in stub_glLinkProgram (program=2) at<br>
tests/util/piglit-dispatch-gen<wbr>.c:33005<br>
#13 0x000000000040206f in test () at<br>
tests/glslparsertest/glslparse<wbr>rtest.c:345<br>
#14 0x00000000004026ed in piglit_init (argc=5, argv=0x7fffffffdd68) at<br>
tests/glslparsertest/glslparse<wbr>rtest.c:543<br>
#15 0x00007ffff7b3b0b0 in run_test (gl_fw=0x615c20, argc=5,<br>
argv=0x7fffffffdd68) at<br>
tests/util/piglit-framework-gl<wbr>/piglit_winsys_framework.c:73<br>
#16 0x00007ffff7b1fbe4 in piglit_gl_test_run (argc=5,<br>
argv=0x7fffffffdd68, config=0x7fffffffdc20) at<br>
tests/util/piglit-framework-gl<wbr>.c:203<br>
#17 0x000000000040196e in main (argc=5, argv=0x7fffffffdd68) at<br>
tests/glslparsertest/glslparse<wbr>rtest.c:90<br>
<font color="#888888"><br>
Eduardo<br>
</font><div class="m_-2676053324317783919elided-text"><br>
> src/compiler/glsl/glsl_to_nir.<wbr>cpp | 3 +--<br>
> src/compiler/nir/nir.c | 22 +++++++++++-----------<br>
> src/compiler/nir/nir.h | 4 ++--<br>
> src/compiler/nir/nir_builder.<wbr>h | 6 +++---<br>
> src/compiler/nir/nir_inline_fu<wbr>nctions.c | 2 +-<br>
> src/compiler/nir/nir_lower_ind<wbr>irect_derefs.c | 6 ++----<br>
> src/compiler/nir/nir_lower_tex<wbr>.c | 18 ++++++------------<br>
> src/compiler/nir/nir_lower_var<wbr>_copies.c | 4 ++--<br>
> src/compiler/nir/nir_split_var<wbr>_copies.c | 17 +++++++----------<br>
> src/compiler/spirv/spirv_to_ni<wbr>r.c | 22 ++++++++++------------<br>
> src/compiler/spirv/vtn_glsl450<wbr>.c | 3 +--<br>
> src/compiler/spirv/vtn_variabl<wbr>es.c | 3 +--<br>
> src/intel/vulkan/anv_nir_lower<wbr>_input_attachments.c | 3 +--<br>
> 13 files changed, 48 insertions(+), 65 deletions(-)<br>
><br>
> diff --git a/src/compiler/glsl/glsl_to_ni<wbr>r.cpp b/src/compiler/glsl/glsl_to_ni<wbr>r.cpp<br>
> index fcaca9f..8efd030 100644<br>
> --- a/src/compiler/glsl/glsl_to_ni<wbr>r.cpp<br>
> +++ b/src/compiler/glsl/glsl_to_ni<wbr>r.cpp<br>
> @@ -1179,8 +1179,7 @@ nir_visitor::visit(ir_assignme<wbr>nt *ir)<br>
> nir_intrinsic_instr_create(thi<wbr>s->shader, nir_intrinsic_store_var);<br>
> store->num_components = ir->lhs->type->vector_elements<wbr>;<br>
> nir_intrinsic_set_write_mask(<wbr>store, ir->write_mask);<br>
> - nir_deref *store_deref = nir_copy_deref(store, &lhs_deref->deref);<br>
> - store->variables[0] = nir_deref_as_var(store_deref);<br>
> + store->variables[0] = nir_deref_var_clone(lhs_deref, store);<br>
> store->src[0] = nir_src_for_ssa(src);<br>
><br>
> if (ir->condition) {<br>
> diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c<br>
> index 885616e..6057143 100644<br>
> --- a/src/compiler/nir/nir.c<br>
> +++ b/src/compiler/nir/nir.c<br>
> @@ -624,18 +624,18 @@ nir_deref_struct_create(void *mem_ctx, unsigned field_index)<br>
> return deref;<br>
> }<br>
><br>
> -static nir_deref_var *<br>
> -copy_deref_var(void *mem_ctx, nir_deref_var *deref)<br>
> +nir_deref_var *<br>
> +nir_deref_var_clone(const nir_deref_var *deref, void *mem_ctx)<br>
> {<br>
> nir_deref_var *ret = nir_deref_var_create(mem_ctx, deref->var);<br>
> ret->deref.type = deref->deref.type;<br>
> if (deref->deref.child)<br>
> - ret->deref.child = nir_copy_deref(ret, deref->deref.child);<br>
> + ret->deref.child = nir_deref_clone(deref->deref.c<wbr>hild, ret);<br>
> return ret;<br>
> }<br>
><br>
> static nir_deref_array *<br>
> -copy_deref_array(void *mem_ctx, nir_deref_array *deref)<br>
> +deref_array_clone(const nir_deref_array *deref, void *mem_ctx)<br>
> {<br>
> nir_deref_array *ret = nir_deref_array_create(mem_ctx<wbr>);<br>
> ret->base_offset = deref->base_offset;<br>
> @@ -645,33 +645,33 @@ copy_deref_array(void *mem_ctx, nir_deref_array *deref)<br>
> }<br>
> ret->deref.type = deref->deref.type;<br>
> if (deref->deref.child)<br>
> - ret->deref.child = nir_copy_deref(ret, deref->deref.child);<br>
> + ret->deref.child = nir_deref_clone(deref->deref.c<wbr>hild, ret);<br>
> return ret;<br>
> }<br>
><br>
> static nir_deref_struct *<br>
> -copy_deref_struct(void *mem_ctx, nir_deref_struct *deref)<br>
> +deref_struct_clone(const nir_deref_struct *deref, void *mem_ctx)<br>
> {<br>
> nir_deref_struct *ret = nir_deref_struct_create(mem_ct<wbr>x, deref->index);<br>
> ret->deref.type = deref->deref.type;<br>
> if (deref->deref.child)<br>
> - ret->deref.child = nir_copy_deref(ret, deref->deref.child);<br>
> + ret->deref.child = nir_deref_clone(deref->deref.c<wbr>hild, ret);<br>
> return ret;<br>
> }<br>
><br>
> nir_deref *<br>
> -nir_copy_deref(void *mem_ctx, nir_deref *deref)<br>
> +nir_deref_clone(const nir_deref *deref, void *mem_ctx)<br>
> {<br>
> if (deref == NULL)<br>
> return NULL;<br>
><br>
> switch (deref->deref_type) {<br>
> case nir_deref_type_var:<br>
> - return ©_deref_var(mem_ctx, nir_deref_as_var(deref))->dere<wbr>f;<br>
> + return &nir_deref_var_clone(nir_deref<wbr>_as_var(deref), mem_ctx)->deref;<br>
> case nir_deref_type_array:<br>
> - return ©_deref_array(mem_ctx, nir_deref_as_array(deref))->de<wbr>ref;<br>
> + return &deref_array_clone(nir_deref_a<wbr>s_array(deref), mem_ctx)->deref;<br>
> case nir_deref_type_struct:<br>
> - return ©_deref_struct(mem_ctx, nir_deref_as_struct(deref))->d<wbr>eref;<br>
> + return &deref_struct_clone(nir_deref_<wbr>as_struct(deref), mem_ctx)->deref;<br>
> default:<br>
> unreachable("Invalid dereference type");<br>
> }<br>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
> index 6557631..d896679 100644<br>
> --- a/src/compiler/nir/nir.h<br>
> +++ b/src/compiler/nir/nir.h<br>
> @@ -1927,8 +1927,6 @@ nir_deref_var *nir_deref_var_create(void *mem_ctx, nir_variable *var);<br>
> nir_deref_array *nir_deref_array_create(void *mem_ctx);<br>
> nir_deref_struct *nir_deref_struct_create(void *mem_ctx, unsigned field_index);<br>
><br>
> -nir_deref *nir_copy_deref(void *mem_ctx, nir_deref *deref);<br>
> -<br>
> typedef bool (*nir_deref_foreach_leaf_cb)(n<wbr>ir_deref_var *deref, void *state);<br>
> bool nir_deref_foreach_leaf(nir_der<wbr>ef_var *deref,<br>
> nir_deref_foreach_leaf_cb cb, void *state);<br>
> @@ -2236,6 +2234,8 @@ nir_shader *nir_shader_clone(void *mem_ctx, const nir_shader *s);<br>
> nir_function_impl *nir_function_impl_clone(const nir_function_impl *fi);<br>
> nir_constant *nir_constant_clone(const nir_constant *c, nir_variable *var);<br>
> nir_variable *nir_variable_clone(const nir_variable *c, nir_shader *shader);<br>
> +nir_deref *nir_deref_clone(const nir_deref *deref, void *mem_ctx);<br>
> +nir_deref_var *nir_deref_var_clone(const nir_deref_var *deref, void *mem_ctx);<br>
><br>
> #ifdef DEBUG<br>
> void nir_validate_shader(nir_shader *shader);<br>
> diff --git a/src/compiler/nir/nir_builder<wbr>.h b/src/compiler/nir/nir_builder<wbr>.h<br>
> index 0ee7d1a..2ea9af1 100644<br>
> --- a/src/compiler/nir/nir_builder<wbr>.h<br>
> +++ b/src/compiler/nir/nir_builder<wbr>.h<br>
> @@ -437,7 +437,7 @@ nir_store_deref_var(nir_builde<wbr>r *build, nir_deref_var *deref,<br>
> nir_intrinsic_instr_create(bui<wbr>ld->shader, nir_intrinsic_store_var);<br>
> store->num_components = num_components;<br>
> store->const_index[0] = writemask & ((1 << num_components) - 1);<br>
> - store->variables[0] = nir_deref_as_var(nir_copy_dere<wbr>f(store, &deref->deref));<br>
> + store->variables[0] = nir_deref_var_clone(deref, store);<br>
> store->src[0] = nir_src_for_ssa(value);<br>
> nir_builder_instr_insert(buil<wbr>d, &store->instr);<br>
> }<br>
> @@ -450,8 +450,8 @@ nir_copy_deref_var(nir_builder *build, nir_deref_var *dest, nir_deref_var *src)<br>
><br>
> nir_intrinsic_instr *copy =<br>
> nir_intrinsic_instr_create(bui<wbr>ld->shader, nir_intrinsic_copy_var);<br>
> - copy->variables[0] = nir_deref_as_var(nir_copy_dere<wbr>f(copy, &dest->deref));<br>
> - copy->variables[1] = nir_deref_as_var(nir_copy_dere<wbr>f(copy, &src->deref));<br>
> + copy->variables[0] = nir_deref_var_clone(dest, copy);<br>
> + copy->variables[1] = nir_deref_var_clone(src, copy);<br>
> nir_builder_instr_insert(buil<wbr>d, ©->instr);<br>
> }<br>
><br>
> diff --git a/src/compiler/nir/nir_inline_<wbr>functions.c b/src/compiler/nir/nir_inline_<wbr>functions.c<br>
> index c36748d..b91e7bc 100644<br>
> --- a/src/compiler/nir/nir_inline_<wbr>functions.c<br>
> +++ b/src/compiler/nir/nir_inline_<wbr>functions.c<br>
> @@ -49,7 +49,7 @@ convert_deref_to_param_deref(n<wbr>ir_instr *instr, nir_deref_var **deref,<br>
> /* Now we make a new deref by concatenating the deref in the call's<br>
> * parameter with the deref we were given.<br>
> */<br>
> - nir_deref_var *new_deref = nir_deref_as_var(nir_copy_dere<wbr>f(instr, &call_deref->deref));<br>
> + nir_deref_var *new_deref = nir_deref_var_clone(call_deref<wbr>, instr);<br>
> nir_deref *new_tail = nir_deref_tail(&new_deref->der<wbr>ef);<br>
> new_tail->child = (*deref)->deref.child;<br>
> ralloc_steal(new_tail, new_tail->child);<br>
> diff --git a/src/compiler/nir/nir_lower_i<wbr>ndirect_derefs.c b/src/compiler/nir/nir_lower_i<wbr>ndirect_derefs.c<br>
> index 5c97dc8e..09cc9a3 100644<br>
> --- a/src/compiler/nir/nir_lower_i<wbr>ndirect_derefs.c<br>
> +++ b/src/compiler/nir/nir_lower_i<wbr>ndirect_derefs.c<br>
> @@ -122,8 +122,7 @@ emit_load_store(nir_builder *b, nir_intrinsic_instr *orig_instr,<br>
> nir_intrinsic_instr *load =<br>
> nir_intrinsic_instr_create(b-<wbr>>shader, nir_intrinsic_load_var);<br>
> load->num_components = orig_instr->num_components;<br>
> - load->variables[0] =<br>
> - nir_deref_as_var(nir_copy_der<wbr>ef(load, &deref->deref));<br>
> + load->variables[0] = nir_deref_var_clone(deref, load);<br>
> unsigned bit_size = orig_instr->dest.ssa.bit_size;<br>
> nir_ssa_dest_init(&load->instr<wbr>, &load->dest,<br>
> load->num_components, bit_size, NULL);<br>
> @@ -135,8 +134,7 @@ emit_load_store(nir_builder *b, nir_intrinsic_instr *orig_instr,<br>
> nir_intrinsic_instr_create(b-<wbr>>shader, nir_intrinsic_store_var);<br>
> store->num_components = orig_instr->num_components;<br>
> nir_intrinsic_set_write_mask(s<wbr>tore, nir_intrinsic_write_mask(orig_<wbr>instr));<br>
> - store->variables[0] =<br>
> - nir_deref_as_var(nir_copy_der<wbr>ef(store, &deref->deref));<br>
> + store->variables[0] = nir_deref_var_clone(deref, store);<br>
> store->src[0] = nir_src_for_ssa(src);<br>
> nir_builder_instr_insert(b, &store->instr);<br>
> }<br>
> diff --git a/src/compiler/nir/nir_lower_t<wbr>ex.c b/src/compiler/nir/nir_lower_t<wbr>ex.c<br>
> index 3e3ac8c..66e2317 100644<br>
> --- a/src/compiler/nir/nir_lower_t<wbr>ex.c<br>
> +++ b/src/compiler/nir/nir_lower_t<wbr>ex.c<br>
> @@ -163,11 +163,9 @@ get_texture_size(nir_builder *b, nir_tex_instr *tex)<br>
> txs->is_shadow = tex->is_shadow;<br>
> txs->is_new_style_shadow = tex->is_new_style_shadow;<br>
> txs->texture_index = tex->texture_index;<br>
> - txs->texture = (nir_deref_var *)<br>
> - nir_copy_deref(txs, &tex->texture->deref);<br>
> + txs->texture = nir_deref_var_clone(tex->textu<wbr>re, txs);<br>
> txs->sampler_index = tex->sampler_index;<br>
> - txs->sampler = (nir_deref_var *)<br>
> - nir_copy_deref(txs, &tex->sampler->deref);<br>
> + txs->sampler = nir_deref_var_clone(tex->sampl<wbr>er, txs);<br>
> txs->dest_type = nir_type_int;<br>
><br>
> /* only single src, the lod: */<br>
> @@ -221,11 +219,9 @@ sample_plane(nir_builder *b, nir_tex_instr *tex, int plane)<br>
> plane_tex->coord_components = 2;<br>
><br>
> plane_tex->texture_index = tex->texture_index;<br>
> - plane_tex->texture = (nir_deref_var *)<br>
> - nir_copy_deref(plane_tex, &tex->texture->deref);<br>
> + plane_tex->texture = nir_deref_var_clone(tex->textu<wbr>re, plane_tex);<br>
> plane_tex->sampler_index = tex->sampler_index;<br>
> - plane_tex->sampler = (nir_deref_var *)<br>
> - nir_copy_deref(plane_tex, &tex->sampler->deref);<br>
> + plane_tex->sampler = nir_deref_var_clone(tex->sampl<wbr>er, plane_tex);<br>
><br>
> nir_ssa_dest_init(&plane_tex-<wbr>>instr, &plane_tex->dest, 4, 32, NULL);<br>
><br>
> @@ -325,10 +321,8 @@ replace_gradient_with_lod(nir_<wbr>builder *b, nir_ssa_def *lod, nir_tex_instr *tex)<br>
> txl->is_shadow = tex->is_shadow;<br>
> txl->is_new_style_shadow = tex->is_new_style_shadow;<br>
> txl->sampler_index = tex->sampler_index;<br>
> - txl->texture = (nir_deref_var *)<br>
> - nir_copy_deref(txl, &tex->texture->deref);<br>
> - txl->sampler = (nir_deref_var *)<br>
> - nir_copy_deref(txl, &tex->sampler->deref);<br>
> + txl->texture = nir_deref_var_clone(tex->textu<wbr>re, txl);<br>
> + txl->sampler = nir_deref_var_clone(tex->sampl<wbr>er, txl);<br>
> txl->coord_components = tex->coord_components;<br>
><br>
> nir_ssa_dest_init(&txl-><wbr>instr, &txl->dest, 4, 32, NULL);<br>
> diff --git a/src/compiler/nir/nir_lower_v<wbr>ar_copies.c b/src/compiler/nir/nir_lower_v<wbr>ar_copies.c<br>
> index b7e9989..b12d953 100644<br>
> --- a/src/compiler/nir/nir_lower_v<wbr>ar_copies.c<br>
> +++ b/src/compiler/nir/nir_lower_v<wbr>ar_copies.c<br>
> @@ -121,7 +121,7 @@ emit_copy_load_store(nir_intri<wbr>nsic_instr *copy_instr,<br>
> nir_intrinsic_instr *load =<br>
> nir_intrinsic_instr_create(me<wbr>m_ctx, nir_intrinsic_load_var);<br>
> load->num_components = num_components;<br>
> - load->variables[0] = nir_deref_as_var(nir_copy_dere<wbr>f(load, &src_head->deref));<br>
> + load->variables[0] = nir_deref_var_clone(src_head, load);<br>
> nir_ssa_dest_init(&load->instr<wbr>, &load->dest, num_components, bit_size,<br>
> NULL);<br>
><br>
> @@ -131,7 +131,7 @@ emit_copy_load_store(nir_intri<wbr>nsic_instr *copy_instr,<br>
> nir_intrinsic_instr_create(me<wbr>m_ctx, nir_intrinsic_store_var);<br>
> store->num_components = num_components;<br>
> nir_intrinsic_set_write_mask(s<wbr>tore, (1 << num_components) - 1);<br>
> - store->variables[0] = nir_deref_as_var(nir_copy_dere<wbr>f(store, &dest_head->deref));<br>
> + store->variables[0] = nir_deref_var_clone(dest_head, store);<br>
><br>
> store->src[0].is_ssa = true;<br>
> store->src[0].ssa = &load->dest.ssa;<br>
> diff --git a/src/compiler/nir/nir_split_v<wbr>ar_copies.c b/src/compiler/nir/nir_split_v<wbr>ar_copies.c<br>
> index 63a7611..cfebb0b 100644<br>
> --- a/src/compiler/nir/nir_split_v<wbr>ar_copies.c<br>
> +++ b/src/compiler/nir/nir_split_v<wbr>ar_copies.c<br>
> @@ -82,7 +82,7 @@ struct split_var_copies_state {<br>
> */<br>
> static void<br>
> split_var_copy_instr(nir_intri<wbr>nsic_instr *old_copy,<br>
> - nir_deref *dest_head, nir_deref *src_head,<br>
> + nir_deref_var *dest_head, nir_deref_var *src_head,<br>
> nir_deref *dest_tail, nir_deref *src_tail,<br>
> struct split_var_copies_state *state)<br>
> {<br>
> @@ -182,11 +182,8 @@ split_var_copy_instr(nir_intri<wbr>nsic_instr *old_copy,<br>
> * belongs to the copy instruction and b) the deref chains may<br>
> * have some of the same links due to the way we constructed them<br>
> */<br>
> - nir_deref *src = nir_copy_deref(new_copy, src_head);<br>
> - nir_deref *dest = nir_copy_deref(new_copy, dest_head);<br>
> -<br>
> - new_copy->variables[0] = nir_deref_as_var(dest);<br>
> - new_copy->variables[1] = nir_deref_as_var(src);<br>
> + new_copy->variables[0] = nir_deref_var_clone(dest_head, new_copy);<br>
> + new_copy->variables[1] = nir_deref_var_clone(src_head, new_copy);<br>
><br>
> /* Emit the copy instruction after the old instruction. We'll<br>
> * remove the old one later.<br>
> @@ -216,10 +213,10 @@ split_var_copies_block(nir_blo<wbr>ck *block, struct split_var_copies_state *state)<br>
> if (intrinsic->intrinsic != nir_intrinsic_copy_var)<br>
> continue;<br>
><br>
> - nir_deref *dest_head = &intrinsic->variables[0]->dere<wbr>f;<br>
> - nir_deref *src_head = &intrinsic->variables[1]->dere<wbr>f;<br>
> - nir_deref *dest_tail = nir_deref_tail(dest_head);<br>
> - nir_deref *src_tail = nir_deref_tail(src_head);<br>
> + nir_deref_var *dest_head = intrinsic->variables[0];<br>
> + nir_deref_var *src_head = intrinsic->variables[1];<br>
> + nir_deref *dest_tail = nir_deref_tail(&dest_head->der<wbr>ef);<br>
> + nir_deref *src_tail = nir_deref_tail(&src_head->dere<wbr>f);<br>
><br>
> switch (glsl_get_base_type(src_tail-><wbr>type)) {<br>
> case GLSL_TYPE_ARRAY:<br>
> diff --git a/src/compiler/spirv/spirv_to_<wbr>nir.c b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
> index 57d0886..739fa71 100644<br>
> --- a/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
> +++ b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
> @@ -1206,7 +1206,7 @@ vtn_handle_function_call(struc<wbr>t vtn_builder *b, SpvOp opcode,<br>
> struct vtn_value *arg = vtn_untyped_value(b, arg_id);<br>
> if (arg->value_type == vtn_value_type_access_chain) {<br>
> nir_deref_var *d = vtn_access_chain_to_deref(b, arg->access_chain);<br>
> - call->params[i] = nir_deref_as_var(nir_copy_dere<wbr>f(call, &d->deref));<br>
> + call->params[i] = nir_deref_var_clone(d, call);<br>
> } else {<br>
> struct vtn_ssa_value *arg_ssa = vtn_ssa_value(b, arg_id);<br>
><br>
> @@ -1542,15 +1542,15 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,<br>
> }<br>
><br>
> nir_deref_var *sampler = vtn_access_chain_to_deref(b, sampled.sampler);<br>
> - nir_deref *texture;<br>
> + nir_deref_var *texture;<br>
> if (sampled.image) {<br>
> nir_deref_var *image = vtn_access_chain_to_deref(b, sampled.image);<br>
> - texture = &image->deref;<br>
> + texture = image;<br>
> } else {<br>
> - texture = &sampler->deref;<br>
> + texture = sampler;<br>
> }<br>
><br>
> - instr->texture = nir_deref_as_var(nir_copy_dere<wbr>f(instr, texture));<br>
> + instr->texture = nir_deref_var_clone(texture, instr);<br>
><br>
> switch (instr->op) {<br>
> case nir_texop_tex:<br>
> @@ -1558,7 +1558,7 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,<br>
> case nir_texop_txl:<br>
> case nir_texop_txd:<br>
> /* These operations require a sampler */<br>
> - instr->sampler = nir_deref_as_var(nir_copy_dere<wbr>f(instr, &sampler->deref));<br>
> + instr->sampler = nir_deref_var_clone(sampler, instr);<br>
> break;<br>
> case nir_texop_txf:<br>
> case nir_texop_txf_ms:<br>
> @@ -1599,8 +1599,7 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,<br>
> instrs[i]->is_new_style_<wbr>shadow = instr->is_new_style_shadow;<br>
> instrs[i]->component = instr->component;<br>
> instrs[i]->dest_type = instr->dest_type;<br>
> - instrs[i]->texture =<br>
> - nir_deref_as_var(nir_copy_dere<wbr>f(instrs[i], texture));<br>
> + instrs[i]->texture = nir_deref_var_clone(texture, instrs[i]);<br>
> instrs[i]->sampler = NULL;<br>
><br>
> memcpy(instrs[i]->src, srcs, instr->num_srcs * sizeof(*instr->src));<br>
> @@ -1807,8 +1806,7 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,<br>
> nir_intrinsic_instr *intrin = nir_intrinsic_instr_create(b-><wbr>shader, op);<br>
><br>
> nir_deref_var *image_deref = vtn_access_chain_to_deref(b, image.image);<br>
> - intrin->variables[0] =<br>
> - nir_deref_as_var(nir_copy_dere<wbr>f(&intrin->instr, &image_deref->deref));<br>
> + intrin->variables[0] = nir_deref_var_clone(image_dere<wbr>f, intrin);<br>
><br>
> /* ImageQuerySize doesn't take any extra parameters */<br>
> if (opcode != SpvOpImageQuerySize) {<br>
> @@ -1967,10 +1965,10 @@ vtn_handle_ssbo_or_shared_atom<wbr>ic(struct vtn_builder *b, SpvOp opcode,<br>
><br>
> if (chain->var->mode == vtn_variable_mode_workgroup) {<br>
> struct vtn_type *type = chain->var->type;<br>
> - nir_deref *deref = &vtn_access_chain_to_deref(b, chain)->deref;<br>
> + nir_deref_var *deref = vtn_access_chain_to_deref(b, chain);<br>
> nir_intrinsic_op op = get_shared_nir_atomic_op(opcod<wbr>e);<br>
> atomic = nir_intrinsic_instr_create(b-><wbr>nb.shader, op);<br>
> - atomic->variables[0] = nir_deref_as_var(nir_copy_dere<wbr>f(atomic, deref));<br>
> + atomic->variables[0] = nir_deref_var_clone(deref, atomic);<br>
><br>
> switch (opcode) {<br>
> case SpvOpAtomicLoad:<br>
> diff --git a/src/compiler/spirv/vtn_glsl4<wbr>50.c b/src/compiler/spirv/vtn_glsl4<wbr>50.c<br>
> index fbc7ce6..a19676f 100644<br>
> --- a/src/compiler/spirv/vtn_glsl4<wbr>50.c<br>
> +++ b/src/compiler/spirv/vtn_glsl4<wbr>50.c<br>
> @@ -667,8 +667,7 @@ handle_glsl450_interpolation(s<wbr>truct vtn_builder *b, enum GLSLstd450 opcode,<br>
> nir_intrinsic_instr *intrin = nir_intrinsic_instr_create(b-><wbr>nb.shader, op);<br>
><br>
> nir_deref_var *deref = vtn_nir_deref(b, w[5]);<br>
> - intrin->variables[0] =<br>
> - nir_deref_as_var(nir_copy_dere<wbr>f(intrin, &deref->deref));<br>
> + intrin->variables[0] = nir_deref_var_clone(deref, intrin);<br>
><br>
> switch (opcode) {<br>
> case GLSLstd450InterpolateAtCentroi<wbr>d:<br>
> diff --git a/src/compiler/spirv/vtn_varia<wbr>bles.c b/src/compiler/spirv/vtn_varia<wbr>bles.c<br>
> index be64dd9..de7c8fe 100644<br>
> --- a/src/compiler/spirv/vtn_varia<wbr>bles.c<br>
> +++ b/src/compiler/spirv/vtn_varia<wbr>bles.c<br>
> @@ -186,8 +186,7 @@ _vtn_local_load_store(struct vtn_builder *b, bool load, nir_deref_var *deref,<br>
> nir_intrinsic_store_var;<br>
><br>
> nir_intrinsic_instr *intrin = nir_intrinsic_instr_create(b-><wbr>shader, op);<br>
> - intrin->variables[0] =<br>
> - nir_deref_as_var(nir_copy_der<wbr>ef(intrin, &deref->deref));<br>
> + intrin->variables[0] = nir_deref_var_clone(deref, intrin);<br>
> intrin->num_components = glsl_get_vector_elements(tail-<wbr>>type);<br>
><br>
> if (load) {<br>
> diff --git a/src/intel/vulkan/anv_nir_low<wbr>er_input_attachments.c b/src/intel/vulkan/anv_nir_low<wbr>er_input_attachments.c<br>
> index e11b563..1d6f727 100644<br>
> --- a/src/intel/vulkan/anv_nir_low<wbr>er_input_attachments.c<br>
> +++ b/src/intel/vulkan/anv_nir_low<wbr>er_input_attachments.c<br>
> @@ -86,8 +86,7 @@ try_lower_input_load(nir_funct<wbr>ion_impl *impl, nir_intrinsic_instr *load)<br>
> tex->is_array = true;<br>
> tex->is_shadow = false;<br>
><br>
> - tex->texture =<br>
> - nir_deref_as_var(nir_copy_dere<wbr>f(tex, &load->variables[0]->deref));<br>
> + tex->texture = nir_deref_var_clone(load->vari<wbr>ables[0], tex);<br>
> tex->sampler = NULL;<br>
> tex->texture_index = 0;<br>
> tex->sampler_index = 0;<br>
><br>
<br>
</div></blockquote></div><br></div></div></div></div>
</blockquote></div><br></div></div></div>