Mesa (master): nir: Report progress from nir_remove_dead_variables().

Kenneth Graunke kwg at kemper.freedesktop.org
Tue Sep 22 00:53:18 UTC 2015


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Thu Sep 17 10:57:14 2015 -0700

nir: Report progress from nir_remove_dead_variables().

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>

---

 src/glsl/nir/nir.h                       |    2 +-
 src/glsl/nir/nir_remove_dead_variables.c |   15 +++++++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 4b05807..5be5bfa 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1823,7 +1823,7 @@ void nir_lower_io(nir_shader *shader,
                   int (*type_size)(const struct glsl_type *));
 void nir_lower_vars_to_ssa(nir_shader *shader);
 
-void nir_remove_dead_variables(nir_shader *shader);
+bool nir_remove_dead_variables(nir_shader *shader);
 
 void nir_move_vec_src_uses_to_dest(nir_shader *shader);
 bool nir_lower_vec_to_movs(nir_shader *shader);
diff --git a/src/glsl/nir/nir_remove_dead_variables.c b/src/glsl/nir/nir_remove_dead_variables.c
index 4417e2a..d6783e7 100644
--- a/src/glsl/nir/nir_remove_dead_variables.c
+++ b/src/glsl/nir/nir_remove_dead_variables.c
@@ -97,32 +97,39 @@ add_var_use_shader(nir_shader *shader, struct set *live)
    }
 }
 
-static void
+static bool
 remove_dead_vars(struct exec_list *var_list, struct set *live)
 {
+   bool progress = false;
+
    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);
          ralloc_free(var);
+         progress = true;
       }
    }
+
+   return progress;
 }
 
-void
+bool
 nir_remove_dead_variables(nir_shader *shader)
 {
+   bool progress = false;
    struct set *live =
       _mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
 
    add_var_use_shader(shader, live);
 
-   remove_dead_vars(&shader->globals, live);
+   progress = remove_dead_vars(&shader->globals, live) || progress;
 
    nir_foreach_overload(shader, overload) {
       if (overload->impl)
-         remove_dead_vars(&overload->impl->locals, live);
+         progress = remove_dead_vars(&overload->impl->locals, live) || progress;
    }
 
    _mesa_set_destroy(live, NULL);
+   return progress;
 }




More information about the mesa-commit mailing list