Module: Mesa
Branch: master
Commit: f4e449108060dcaea1b4e1e445b76a8ef43d3a05
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f4e449108060dcaea1b4e1e445b76a8ef43d3a05

Author: Kenneth Graunke <[email protected]>
Date:   Fri Mar 27 16:17:20 2015 -0700

nir: Combine remove_dead_local_vars() and remove_dead_global_vars().

We can just pass a pointer to the list of variables, and reuse the code.

Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>

---

 src/glsl/nir/nir_remove_dead_variables.c |   18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/src/glsl/nir/nir_remove_dead_variables.c 
b/src/glsl/nir/nir_remove_dead_variables.c
index e7f8aea..baa321e 100644
--- a/src/glsl/nir/nir_remove_dead_variables.c
+++ b/src/glsl/nir/nir_remove_dead_variables.c
@@ -98,19 +98,9 @@ add_var_use_shader(nir_shader *shader, struct set *live)
 }
 
 static void
-remove_dead_local_vars(nir_function_impl *impl, struct set *live)
+remove_dead_vars(struct exec_list *var_list, struct set *live)
 {
-   foreach_list_typed_safe(nir_variable, var, node, &impl->locals) {
-      struct set_entry *entry = _mesa_set_search(live, var);
-      if (entry == NULL)
-         exec_node_remove(&var->node);
-   }
-}
-
-static void
-remove_dead_global_vars(nir_shader *shader, struct set *live)
-{
-   foreach_list_typed_safe(nir_variable, var, node, &shader->globals) {
+   foreach_list_typed_safe(nir_variable, var, node, var_list) {
       struct set_entry *entry = _mesa_set_search(live, var);
       if (entry == NULL)
          exec_node_remove(&var->node);
@@ -125,11 +115,11 @@ nir_remove_dead_variables(nir_shader *shader)
 
    add_var_use_shader(shader, live);
 
-   remove_dead_global_vars(shader, live);
+   remove_dead_vars(&shader->globals, live);
 
    nir_foreach_overload(shader, overload) {
       if (overload->impl)
-         remove_dead_local_vars(overload->impl, live);
+         remove_dead_vars(&overload->impl->locals, live);
    }
 
    _mesa_set_destroy(live, NULL);

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to