nir: add callback to nir_remove_dead_variables()
authorTimothy Arceri <tarceri@itsqueeze.com>
Thu, 28 May 2020 00:59:28 +0000 (10:59 +1000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 3 Jun 2020 02:22:23 +0000 (02:22 +0000)
This allows us to do API specific checks before removing variable
without filling nir_remove_dead_variables() with API specific code.

In the following patches we will use this to support the removal
of dead uniforms in GLSL.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4797>

23 files changed:
src/amd/vulkan/radv_pipeline.c
src/amd/vulkan/radv_shader.c
src/broadcom/compiler/vir.c
src/compiler/nir/nir.h
src/compiler/nir/nir_remove_dead_variables.c
src/compiler/spirv/spirv_to_nir.c
src/freedreno/ir3/ir3_nir.c
src/freedreno/vulkan/tu_shader.c
src/gallium/auxiliary/gallivm/lp_bld_nir.c
src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c
src/gallium/drivers/freedreno/a2xx/ir2_nir.c
src/gallium/drivers/lima/lima_program.c
src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
src/gallium/drivers/r600/sfn/sfn_nir.cpp
src/gallium/drivers/radeonsi/si_shader_nir.c
src/gallium/drivers/v3d/v3d_program.c
src/gallium/drivers/vc4/vc4_program.c
src/gallium/drivers/zink/zink_compiler.c
src/intel/blorp/blorp.c
src/intel/compiler/brw_nir.c
src/intel/vulkan/anv_pipeline.c
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/state_tracker/st_glsl_to_nir.cpp

index 738a9b1372d1b7908cbebea7c2434f3886a3f429..c51726f2bed3a2b7e04d4c4339bc2e9c7179af85 100644 (file)
@@ -2230,9 +2230,9 @@ radv_link_shaders(struct radv_pipeline *pipeline, nir_shader **shaders)
                        radv_optimize_nir(ordered_shaders[i - 1], false, false);
 
                nir_remove_dead_variables(ordered_shaders[i],
                        radv_optimize_nir(ordered_shaders[i - 1], false, false);
 
                nir_remove_dead_variables(ordered_shaders[i],
-                                         nir_var_shader_out);
+                                         nir_var_shader_out, NULL);
                nir_remove_dead_variables(ordered_shaders[i - 1],
                nir_remove_dead_variables(ordered_shaders[i - 1],
-                                         nir_var_shader_in);
+                                         nir_var_shader_in, NULL);
 
                bool progress = nir_remove_unused_varyings(ordered_shaders[i],
                                                           ordered_shaders[i - 1]);
 
                bool progress = nir_remove_unused_varyings(ordered_shaders[i],
                                                           ordered_shaders[i - 1]);
index b12b9f10d906010766b7b6798477bef5f1bba3a2..a23af0f7f9f8b0346a594bd0d7036bfc9a0a3c07 100644 (file)
@@ -226,7 +226,8 @@ radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively,
                NIR_PASS(progress, shader, nir_opt_copy_prop_vars);
                NIR_PASS(progress, shader, nir_opt_dead_write_vars);
                NIR_PASS(progress, shader, nir_remove_dead_variables,
                NIR_PASS(progress, shader, nir_opt_copy_prop_vars);
                NIR_PASS(progress, shader, nir_opt_dead_write_vars);
                NIR_PASS(progress, shader, nir_remove_dead_variables,
-                        nir_var_function_temp | nir_var_shader_in | nir_var_shader_out);
+                        nir_var_function_temp | nir_var_shader_in | nir_var_shader_out,
+                        NULL);
 
                 NIR_PASS_V(shader, nir_lower_alu_to_scalar, NULL, NULL);
                 NIR_PASS_V(shader, nir_lower_phis_to_scalar);
 
                 NIR_PASS_V(shader, nir_lower_alu_to_scalar, NULL, NULL);
                 NIR_PASS_V(shader, nir_lower_phis_to_scalar);
@@ -458,7 +459,8 @@ radv_shader_compile_to_nir(struct radv_device *device,
                        NIR_PASS_V(nir, nir_lower_input_attachments, true);
 
                NIR_PASS_V(nir, nir_remove_dead_variables,
                        NIR_PASS_V(nir, nir_lower_input_attachments, true);
 
                NIR_PASS_V(nir, nir_remove_dead_variables,
-                          nir_var_shader_in | nir_var_shader_out | nir_var_system_value | nir_var_mem_shared);
+                          nir_var_shader_in | nir_var_shader_out | nir_var_system_value | nir_var_mem_shared,
+                          NULL);
 
                NIR_PASS_V(nir, nir_propagate_invariant);
 
 
                NIR_PASS_V(nir, nir_propagate_invariant);
 
@@ -499,7 +501,7 @@ radv_shader_compile_to_nir(struct radv_device *device,
        nir_split_var_copies(nir);
 
        nir_lower_global_vars_to_local(nir);
        nir_split_var_copies(nir);
 
        nir_lower_global_vars_to_local(nir);
-       nir_remove_dead_variables(nir, nir_var_function_temp);
+       nir_remove_dead_variables(nir, nir_var_function_temp, NULL);
        bool gfx7minus = device->physical_device->rad_info.chip_class <= GFX7;
        nir_lower_subgroups(nir, &(struct nir_lower_subgroups_options) {
                        .subgroup_size = subgroup_size,
        bool gfx7minus = device->physical_device->rad_info.chip_class <= GFX7;
        nir_lower_subgroups(nir, &(struct nir_lower_subgroups_options) {
                        .subgroup_size = subgroup_size,
index 34f7773f0667c28507eff79b3252a890d17b9312..adfd587d53401a27b60644f91fc07a84a62f3657 100644 (file)
@@ -808,7 +808,7 @@ v3d_nir_lower_vs_early(struct v3d_compile *c)
                    &c->s->outputs, used_outputs, NULL); /* demotes to globals */
         NIR_PASS_V(c->s, nir_lower_global_vars_to_local);
         v3d_optimize_nir(c->s);
                    &c->s->outputs, used_outputs, NULL); /* demotes to globals */
         NIR_PASS_V(c->s, nir_lower_global_vars_to_local);
         v3d_optimize_nir(c->s);
-        NIR_PASS_V(c->s, nir_remove_dead_variables, nir_var_shader_in);
+        NIR_PASS_V(c->s, nir_remove_dead_variables, nir_var_shader_in, NULL);
 
         /* This must go before nir_lower_io */
         if (c->vs_key->per_vertex_point_size)
 
         /* This must go before nir_lower_io */
         if (c->vs_key->per_vertex_point_size)
@@ -839,7 +839,7 @@ v3d_nir_lower_gs_early(struct v3d_compile *c)
                    &c->s->outputs, used_outputs, NULL); /* demotes to globals */
         NIR_PASS_V(c->s, nir_lower_global_vars_to_local);
         v3d_optimize_nir(c->s);
                    &c->s->outputs, used_outputs, NULL); /* demotes to globals */
         NIR_PASS_V(c->s, nir_lower_global_vars_to_local);
         v3d_optimize_nir(c->s);
-        NIR_PASS_V(c->s, nir_remove_dead_variables, nir_var_shader_in);
+        NIR_PASS_V(c->s, nir_remove_dead_variables, nir_var_shader_in, NULL);
 
         /* This must go before nir_lower_io */
         if (c->gs_key->per_vertex_point_size)
 
         /* This must go before nir_lower_io */
         if (c->gs_key->per_vertex_point_size)
index 9bf399698951b8767ffc83cbba5bb6319da73eb8..79973655f2637c846d41b073ecd42ee9b2b134b2 100644 (file)
@@ -4083,7 +4083,8 @@ bool nir_lower_vars_to_ssa(nir_shader *shader);
 
 bool nir_remove_dead_derefs(nir_shader *shader);
 bool nir_remove_dead_derefs_impl(nir_function_impl *impl);
 
 bool nir_remove_dead_derefs(nir_shader *shader);
 bool nir_remove_dead_derefs_impl(nir_function_impl *impl);
-bool nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes);
+bool nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes,
+                               bool (*can_remove_var)(nir_variable *var));
 bool nir_lower_variable_initializers(nir_shader *shader,
                                      nir_variable_mode modes);
 
 bool nir_lower_variable_initializers(nir_shader *shader,
                                      nir_variable_mode modes);
 
index cfdd179629949bad410f658e529080ddaba34165..4fbe035c0241ea21b362c58ce99e90bbf52b6f5f 100644 (file)
@@ -143,11 +143,15 @@ remove_dead_var_writes(nir_shader *shader, struct set *live)
 }
 
 static bool
 }
 
 static bool
-remove_dead_vars(struct exec_list *var_list, struct set *live)
+remove_dead_vars(struct exec_list *var_list, struct set *live,
+                 bool (*can_remove_var)(nir_variable *var))
 {
    bool progress = false;
 
    foreach_list_typed_safe(nir_variable, var, node, var_list) {
 {
    bool progress = false;
 
    foreach_list_typed_safe(nir_variable, var, node, var_list) {
+      if (can_remove_var && !can_remove_var(var))
+         continue;
+
       struct set_entry *entry = _mesa_set_search(live, var);
       if (entry == NULL) {
          /* Mark this variable as used by setting the mode to 0 */
       struct set_entry *entry = _mesa_set_search(live, var);
       if (entry == NULL) {
          /* Mark this variable as used by setting the mode to 0 */
@@ -161,35 +165,49 @@ remove_dead_vars(struct exec_list *var_list, struct set *live)
 }
 
 bool
 }
 
 bool
-nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes)
+nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes,
+                          bool (*can_remove_var)(nir_variable *var))
 {
    bool progress = false;
    struct set *live = _mesa_pointer_set_create(NULL);
 
    add_var_use_shader(shader, live, modes);
 
 {
    bool progress = false;
    struct set *live = _mesa_pointer_set_create(NULL);
 
    add_var_use_shader(shader, live, modes);
 
-   if (modes & nir_var_uniform)
-      progress = remove_dead_vars(&shader->uniforms, live) || progress;
+   if (modes & nir_var_uniform) {
+      progress = remove_dead_vars(&shader->uniforms, live, can_remove_var) ||
+         progress;
+   }
 
 
-   if (modes & nir_var_shader_in)
-      progress = remove_dead_vars(&shader->inputs, live) || progress;
+   if (modes & nir_var_shader_in) {
+      progress = remove_dead_vars(&shader->inputs, live, can_remove_var) ||
+         progress;
+   }
 
 
-   if (modes & nir_var_shader_out)
-      progress = remove_dead_vars(&shader->outputs, live) || progress;
+   if (modes & nir_var_shader_out) {
+      progress = remove_dead_vars(&shader->outputs, live, can_remove_var) ||
+         progress;
+   }
 
 
-   if (modes & nir_var_shader_temp)
-      progress = remove_dead_vars(&shader->globals, live) || progress;
+   if (modes & nir_var_shader_temp) {
+      progress = remove_dead_vars(&shader->globals, live, can_remove_var) ||
+         progress;
+   }
 
 
-   if (modes & nir_var_system_value)
-      progress = remove_dead_vars(&shader->system_values, live) || progress;
+   if (modes & nir_var_system_value) {
+      progress = remove_dead_vars(&shader->system_values, live,
+                                  can_remove_var) || progress;
+   }
 
 
-   if (modes & nir_var_mem_shared)
-      progress = remove_dead_vars(&shader->shared, live) || progress;
+   if (modes & nir_var_mem_shared) {
+      progress = remove_dead_vars(&shader->shared, live, can_remove_var) ||
+         progress;
+   }
 
    if (modes & nir_var_function_temp) {
       nir_foreach_function(function, shader) {
          if (function->impl) {
 
    if (modes & nir_var_function_temp) {
       nir_foreach_function(function, shader) {
          if (function->impl) {
-            if (remove_dead_vars(&function->impl->locals, live))
+            if (remove_dead_vars(&function->impl->locals, live,
+                                 can_remove_var))
                progress = true;
          }
       }
                progress = true;
          }
       }
index 425fbcbbe72092fcee454c47a3be803d2c58e19e..7bb9489aaeb4d8e871e9222c976a262dc42e5cee 100644 (file)
@@ -5324,7 +5324,7 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
     */
    nir_lower_variable_initializers(b->shader, nir_var_shader_out);
    nir_remove_dead_variables(b->shader,
     */
    nir_lower_variable_initializers(b->shader, nir_var_shader_out);
    nir_remove_dead_variables(b->shader,
-                             nir_var_shader_in | nir_var_shader_out);
+                             nir_var_shader_in | nir_var_shader_out, NULL);
 
    /* We sometimes generate bogus derefs that, while never used, give the
     * validator a bit of heartburn.  Run dead code to get rid of them.
 
    /* We sometimes generate bogus derefs that, while never used, give the
     * validator a bit of heartburn.  Run dead code to get rid of them.
index 48dc9a340abf10332552cd719c62de048e335543..148186050bfcf7530d3203fa3705e289cf6fc853 100644 (file)
@@ -352,7 +352,7 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s,
                OPT_V(s, nir_opt_cse);
        }
 
                OPT_V(s, nir_opt_cse);
        }
 
-       OPT_V(s, nir_remove_dead_variables, nir_var_function_temp);
+       OPT_V(s, nir_remove_dead_variables, nir_var_function_temp, NULL);
 
        OPT_V(s, nir_opt_sink, nir_move_const_undef);
 
 
        OPT_V(s, nir_opt_sink, nir_move_const_undef);
 
index af0415e0efdda7118f58e5cf3e7104276eb2d62c..29ac80bc48db4ebb0087bbb162b87b037c4d2573 100644 (file)
@@ -590,7 +590,8 @@ tu_shader_create(struct tu_device *dev,
    NIR_PASS_V(nir, nir_split_per_member_structs);
 
    NIR_PASS_V(nir, nir_remove_dead_variables,
    NIR_PASS_V(nir, nir_split_per_member_structs);
 
    NIR_PASS_V(nir, nir_remove_dead_variables,
-              nir_var_shader_in | nir_var_shader_out | nir_var_system_value | nir_var_mem_shared);
+              nir_var_shader_in | nir_var_shader_out | nir_var_system_value | nir_var_mem_shared,
+              NULL);
 
    /* Gather information for transform feedback.
     * This should be called after nir_split_per_member_structs.
 
    /* Gather information for transform feedback.
     * This should be called after nir_split_per_member_structs.
index 93234ac37b2d701160dfc1632324f8efed594db2..d78aab2ef270f50030f8a4ec2bfde898538a44c6 100644 (file)
@@ -1909,7 +1909,7 @@ bool lp_build_nir_llvm(
    nir_convert_from_ssa(nir, true);
    nir_lower_locals_to_regs(nir);
    nir_remove_dead_derefs(nir);
    nir_convert_from_ssa(nir, true);
    nir_lower_locals_to_regs(nir);
    nir_remove_dead_derefs(nir);
-   nir_remove_dead_variables(nir, nir_var_function_temp);
+   nir_remove_dead_variables(nir, nir_var_function_temp, NULL);
 
    nir_foreach_variable(variable, &nir->outputs)
       handle_shader_output_decl(bld_base, nir, variable);
 
    nir_foreach_variable(variable, &nir->outputs)
       handle_shader_output_decl(bld_base, nir, variable);
index c731067f54212ad320eb653e271c45d909c8697d..4542f429ddc67936fb0927cb7585c38479eccbe5 100644 (file)
@@ -839,7 +839,7 @@ etna_compile_shader_nir(struct etna_shader_variant *v)
    while( OPT(s, nir_opt_vectorize) );
    OPT_V(s, nir_lower_alu_to_scalar, etna_alu_to_scalar_filter_cb, specs);
 
    while( OPT(s, nir_opt_vectorize) );
    OPT_V(s, nir_lower_alu_to_scalar, etna_alu_to_scalar_filter_cb, specs);
 
-   NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp);
+   NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp, NULL);
    NIR_PASS_V(s, nir_opt_algebraic_late);
 
    NIR_PASS_V(s, nir_move_vec_src_uses_to_dest);
    NIR_PASS_V(s, nir_opt_algebraic_late);
 
    NIR_PASS_V(s, nir_move_vec_src_uses_to_dest);
index 53a3c0a664915e6ebc8c006cf45327196c4b1ee2..44e53afaa3c5c399de8986dd76052abde78f54b0 100644 (file)
@@ -122,7 +122,7 @@ ir2_optimize_nir(nir_shader *s, bool lower)
 
        ir2_optimize_loop(s);
 
 
        ir2_optimize_loop(s);
 
-       OPT_V(s, nir_remove_dead_variables, nir_var_function_temp);
+       OPT_V(s, nir_remove_dead_variables, nir_var_function_temp, NULL);
        OPT_V(s, nir_opt_sink, nir_move_const_undef);
 
        /* TODO we dont want to get shaders writing to depth for depth textures */
        OPT_V(s, nir_opt_sink, nir_move_const_undef);
 
        /* TODO we dont want to get shaders writing to depth for depth textures */
index 2537e770ef966d3b56ebd6c4401f32ccf61e2a90..0d942d4712698bac9dac084df26619a21abd3e19 100644 (file)
@@ -138,7 +138,7 @@ lima_program_optimize_vs_nir(struct nir_shader *s)
    NIR_PASS_V(s, nir_opt_dce);
    NIR_PASS_V(s, nir_lower_locals_to_regs);
    NIR_PASS_V(s, nir_convert_from_ssa, true);
    NIR_PASS_V(s, nir_opt_dce);
    NIR_PASS_V(s, nir_lower_locals_to_regs);
    NIR_PASS_V(s, nir_convert_from_ssa, true);
-   NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp);
+   NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp, NULL);
    nir_sweep(s);
 }
 
    nir_sweep(s);
 }
 
@@ -243,7 +243,7 @@ lima_program_optimize_fs_nir(struct nir_shader *s,
 
    NIR_PASS_V(s, nir_lower_locals_to_regs);
    NIR_PASS_V(s, nir_convert_from_ssa, true);
 
    NIR_PASS_V(s, nir_lower_locals_to_regs);
    NIR_PASS_V(s, nir_convert_from_ssa, true);
-   NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp);
+   NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp, NULL);
 
    NIR_PASS_V(s, nir_move_vec_src_uses_to_dest);
    NIR_PASS_V(s, nir_lower_vec_to_movs);
 
    NIR_PASS_V(s, nir_move_vec_src_uses_to_dest);
    NIR_PASS_V(s, nir_lower_vec_to_movs);
index bd78b76f38499b76d3283bbf458e0b1c9a167fad..50c8345e4b662dbe1e0606f02bafb016090294e3 100644 (file)
@@ -3239,7 +3239,7 @@ Converter::run()
 
    NIR_PASS_V(nir, nir_lower_bool_to_int32);
    NIR_PASS_V(nir, nir_lower_locals_to_regs);
 
    NIR_PASS_V(nir, nir_lower_bool_to_int32);
    NIR_PASS_V(nir, nir_lower_locals_to_regs);
-   NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp);
+   NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL);
    NIR_PASS_V(nir, nir_convert_from_ssa, true);
 
    // Garbage collect dead instructions
    NIR_PASS_V(nir, nir_convert_from_ssa, true);
 
    // Garbage collect dead instructions
index 3f8badf6fc330e58ce5aa5ab502e8b2b5b156dfd..571498a8f4b976790f00f4bed23284e754cefe3d 100644 (file)
@@ -635,8 +635,8 @@ int r600_shader_from_nir(struct r600_context *rctx,
    if (optimize)
       while(optimize_once(sel->nir));
 
    if (optimize)
       while(optimize_once(sel->nir));
 
-   NIR_PASS_V(sel->nir, nir_remove_dead_variables, nir_var_shader_in);
-   NIR_PASS_V(sel->nir, nir_remove_dead_variables,  nir_var_shader_out);
+   NIR_PASS_V(sel->nir, nir_remove_dead_variables, nir_var_shader_in, NULL);
+   NIR_PASS_V(sel->nir, nir_remove_dead_variables,  nir_var_shader_out, NULL);
 
 
    NIR_PASS_V(sel->nir, nir_lower_vars_to_scratch,
 
 
    NIR_PASS_V(sel->nir, nir_lower_vars_to_scratch,
index 6b8bea1c11cf48cb16176d5367e0697e429fbd9e..7ce107e1b0f931e99aee4cad9dcf7c6d45114c11 100644 (file)
@@ -934,7 +934,7 @@ static void si_lower_nir(struct si_screen *sscreen, struct nir_shader *nir)
       si_nir_opts(nir);
 
    NIR_PASS_V(nir, nir_lower_bool_to_int32);
       si_nir_opts(nir);
 
    NIR_PASS_V(nir, nir_lower_bool_to_int32);
-   NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp);
+   NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL);
 
    if (sscreen->debug_flags & DBG(FS_CORRECT_DERIVS_AFTER_KILL))
       NIR_PASS_V(nir, nir_lower_discard_to_demote);
 
    if (sscreen->debug_flags & DBG(FS_CORRECT_DERIVS_AFTER_KILL))
       NIR_PASS_V(nir, nir_lower_discard_to_demote);
index ad6a796866a3e4cadd43b453e00e96d80312eaba..dbe3c7b4454fa90601fc8f6906058dac42d066e6 100644 (file)
@@ -322,7 +322,7 @@ v3d_uncompiled_shader_create(struct pipe_context *pctx,
 
         v3d_optimize_nir(s);
 
 
         v3d_optimize_nir(s);
 
-        NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp);
+        NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp, NULL);
 
         /* Garbage collect dead instructions */
         nir_sweep(s);
 
         /* Garbage collect dead instructions */
         nir_sweep(s);
index 66a095e12161c15c9ed3fd954b417b92d0d2c2e3..2d16c479313dd92b7e95dcf900e80f9d99c0ee9a 100644 (file)
@@ -2482,7 +2482,7 @@ vc4_shader_state_create(struct pipe_context *pctx,
 
         vc4_optimize_nir(s);
 
 
         vc4_optimize_nir(s);
 
-        NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp);
+        NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp, NULL);
 
         /* Garbage collect dead instructions */
         nir_sweep(s);
 
         /* Garbage collect dead instructions */
         nir_sweep(s);
index 98ef706fb8fdd0ccc3ef60cec8b438495168834b..d3efcb987a62f25c0f9aceb1105bbab19ce47201 100644 (file)
@@ -140,7 +140,7 @@ zink_compile_nir(struct zink_screen *screen, struct nir_shader *nir)
    NIR_PASS_V(nir, nir_lower_clip_halfz);
    NIR_PASS_V(nir, nir_lower_regs_to_ssa);
    optimize_nir(nir);
    NIR_PASS_V(nir, nir_lower_clip_halfz);
    NIR_PASS_V(nir, nir_lower_regs_to_ssa);
    optimize_nir(nir);
-   NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp);
+   NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL);
    NIR_PASS_V(nir, lower_discard_if);
    NIR_PASS_V(nir, nir_convert_from_ssa, true);
 
    NIR_PASS_V(nir, lower_discard_if);
    NIR_PASS_V(nir, nir_convert_from_ssa, true);
 
index d60d75e16c63492be9932e90fa896ccff99f0a90..c3181a19e6c587047735ceaaeda664b43ede19b7 100644 (file)
@@ -191,7 +191,7 @@ blorp_compile_fs(struct blorp_context *blorp, void *mem_ctx,
    wm_prog_data->base.binding_table.texture_start = BLORP_TEXTURE_BT_INDEX;
 
    brw_preprocess_nir(compiler, nir, NULL);
    wm_prog_data->base.binding_table.texture_start = BLORP_TEXTURE_BT_INDEX;
 
    brw_preprocess_nir(compiler, nir, NULL);
-   nir_remove_dead_variables(nir, nir_var_shader_in);
+   nir_remove_dead_variables(nir, nir_var_shader_in, NULL);
    nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
 
    if (blorp->compiler->devinfo->gen < 6) {
    nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
 
    if (blorp->compiler->devinfo->gen < 6) {
index 7a1fea10aa2e7eed5ac797f2535e1a18446cb48b..ff1b3bf5572b96eea8aac3d959fbc302151a3092 100644 (file)
@@ -597,7 +597,7 @@ brw_nir_optimize(nir_shader *nir, const struct brw_compiler *compiler,
    /* Workaround Gfxbench unused local sampler variable which will trigger an
     * assert in the opt_large_constants pass.
     */
    /* Workaround Gfxbench unused local sampler variable which will trigger an
     * assert in the opt_large_constants pass.
     */
-   OPT(nir_remove_dead_variables, nir_var_function_temp);
+   OPT(nir_remove_dead_variables, nir_var_function_temp, NULL);
 }
 
 static unsigned
 }
 
 static unsigned
@@ -785,8 +785,8 @@ brw_nir_link_shaders(const struct brw_compiler *compiler,
    if (nir_link_opt_varyings(producer, consumer))
       brw_nir_optimize(consumer, compiler, c_is_scalar, false);
 
    if (nir_link_opt_varyings(producer, consumer))
       brw_nir_optimize(consumer, compiler, c_is_scalar, false);
 
-   NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out);
-   NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in);
+   NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out, NULL);
+   NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in, NULL);
 
    if (nir_remove_unused_varyings(producer, consumer)) {
       NIR_PASS_V(producer, nir_lower_global_vars_to_local);
 
    if (nir_remove_unused_varyings(producer, consumer)) {
       NIR_PASS_V(producer, nir_lower_global_vars_to_local);
index bd2d1884d7a1e1f44e6fd4a531fdd82d575d098b..62a0c5a0b1617a8d127459c9b48ca5133f8c150a 100644 (file)
@@ -282,7 +282,8 @@ anv_shader_compile_to_nir(struct anv_device *device,
    NIR_PASS_V(nir, nir_split_per_member_structs);
 
    NIR_PASS_V(nir, nir_remove_dead_variables,
    NIR_PASS_V(nir, nir_split_per_member_structs);
 
    NIR_PASS_V(nir, nir_remove_dead_variables,
-              nir_var_shader_in | nir_var_shader_out | nir_var_system_value);
+              nir_var_shader_in | nir_var_shader_out | nir_var_system_value,
+              NULL);
 
    NIR_PASS_V(nir, nir_propagate_invariant);
    NIR_PASS_V(nir, nir_lower_io_to_temporaries,
 
    NIR_PASS_V(nir, nir_propagate_invariant);
    NIR_PASS_V(nir, nir_lower_io_to_temporaries,
index be4347881f2f065cf2ef6c0145890b373bbc57d9..cbb5b312efd25e7058c878ecede88604243f6b80 100644 (file)
@@ -106,7 +106,8 @@ brw_create_nir(struct brw_context *brw,
       }
       assert (nir);
 
       }
       assert (nir);
 
-      nir_remove_dead_variables(nir, nir_var_shader_in | nir_var_shader_out);
+      nir_remove_dead_variables(nir, nir_var_shader_in | nir_var_shader_out,
+                                NULL);
       nir_validate_shader(nir, "after glsl_to_nir or spirv_to_nir");
       NIR_PASS_V(nir, nir_lower_io_to_temporaries,
                  nir_shader_get_entrypoint(nir), true, false);
       nir_validate_shader(nir, "after glsl_to_nir or spirv_to_nir");
       NIR_PASS_V(nir, nir_lower_io_to_temporaries,
                  nir_shader_get_entrypoint(nir), true, false);
index d7277f7f5c59a416a275b2c3b3930685a7201016..b99e8339ae0245977f7c1db4badb1031f68015e6 100644 (file)
@@ -260,7 +260,8 @@ st_nir_opts(nir_shader *nir)
       NIR_PASS(progress, nir, nir_remove_dead_variables,
                (nir_variable_mode)(nir_var_function_temp |
                                    nir_var_shader_temp |
       NIR_PASS(progress, nir, nir_remove_dead_variables,
                (nir_variable_mode)(nir_var_function_temp |
                                    nir_var_shader_temp |
-                                   nir_var_mem_shared));
+                                   nir_var_mem_shared),
+               NULL);
 
       NIR_PASS(progress, nir, nir_opt_copy_prop_vars);
       NIR_PASS(progress, nir, nir_opt_dead_write_vars);
 
       NIR_PASS(progress, nir, nir_opt_copy_prop_vars);
       NIR_PASS(progress, nir, nir_opt_dead_write_vars);
@@ -378,7 +379,7 @@ st_nir_preprocess(struct st_context *st, struct gl_program *prog,
    if (!_mesa_is_gles(st->ctx) || !nir->info.separate_shader) {
       nir_variable_mode mask =
          (nir_variable_mode) (nir_var_shader_in | nir_var_shader_out);
    if (!_mesa_is_gles(st->ctx) || !nir->info.separate_shader) {
       nir_variable_mode mask =
          (nir_variable_mode) (nir_var_shader_in | nir_var_shader_out);
-      nir_remove_dead_variables(nir, mask);
+      nir_remove_dead_variables(nir, mask, NULL);
    }
 
    if (options->lower_all_io_to_temps ||
    }
 
    if (options->lower_all_io_to_temps ||
@@ -503,7 +504,7 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog,
 
    nir_variable_mode mask = (nir_variable_mode)
       (nir_var_shader_in | nir_var_shader_out | nir_var_function_temp );
 
    nir_variable_mode mask = (nir_variable_mode)
       (nir_var_shader_in | nir_var_shader_out | nir_var_function_temp );
-   nir_remove_dead_variables(nir, mask);
+   nir_remove_dead_variables(nir, mask, NULL);
 
    if (!st->has_hw_atomics)
       NIR_PASS_V(nir, nir_lower_atomics_to_ssbo);
 
    if (!st->has_hw_atomics)
       NIR_PASS_V(nir, nir_lower_atomics_to_ssbo);
@@ -561,8 +562,8 @@ st_nir_link_shaders(nir_shader *producer, nir_shader *consumer)
    if (nir_link_opt_varyings(producer, consumer))
       st_nir_opts(consumer);
 
    if (nir_link_opt_varyings(producer, consumer))
       st_nir_opts(consumer);
 
-   NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out);
-   NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in);
+   NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out, NULL);
+   NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in, NULL);
 
    if (nir_remove_unused_varyings(producer, consumer)) {
       NIR_PASS_V(producer, nir_lower_global_vars_to_local);
 
    if (nir_remove_unused_varyings(producer, consumer)) {
       NIR_PASS_V(producer, nir_lower_global_vars_to_local);
@@ -575,8 +576,10 @@ st_nir_link_shaders(nir_shader *producer, nir_shader *consumer)
        * nir_compact_varyings() depends on all dead varyings being removed so
        * we need to call nir_remove_dead_variables() again here.
        */
        * nir_compact_varyings() depends on all dead varyings being removed so
        * we need to call nir_remove_dead_variables() again here.
        */
-      NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out);
-      NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in);
+      NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out,
+                 NULL);
+      NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in,
+                 NULL);
    }
 }
 
    }
 }