[Mesa-dev] [PATCH 122/133] nir: Call nir_metadata_preserve more places

Jason Ekstrand jason at jlekstrand.net
Mon Dec 15 22:13:05 PST 2014


---
 src/glsl/nir/nir_from_ssa.c             | 3 +++
 src/glsl/nir/nir_lower_atomics.c        | 5 ++++-
 src/glsl/nir/nir_lower_io.c             | 3 +++
 src/glsl/nir/nir_lower_locals_to_regs.c | 3 +++
 src/glsl/nir/nir_lower_system_values.c  | 2 ++
 src/glsl/nir/nir_opt_constant_folding.c | 4 ++++
 src/glsl/nir/nir_opt_dce.c              | 4 ++++
 src/glsl/nir/nir_to_ssa.c               | 5 ++++-
 8 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
index 2ec6219..845e3bb 100644
--- a/src/glsl/nir/nir_from_ssa.c
+++ b/src/glsl/nir/nir_from_ssa.c
@@ -840,6 +840,9 @@ nir_convert_from_ssa_impl(nir_function_impl *impl)
 
    nir_foreach_block(impl, resolve_parallel_copies_block, &state);
 
+   nir_metadata_preserve(impl, nir_metadata_block_index |
+                               nir_metadata_dominance);
+
    /* Clean up dead instructions and the hash tables */
    _mesa_hash_table_destroy(state.ssa_table, NULL);
    _mesa_hash_table_destroy(state.merge_node_table, NULL);
diff --git a/src/glsl/nir/nir_lower_atomics.c b/src/glsl/nir/nir_lower_atomics.c
index 23d5de0..b43e4fe 100644
--- a/src/glsl/nir/nir_lower_atomics.c
+++ b/src/glsl/nir/nir_lower_atomics.c
@@ -137,7 +137,10 @@ void
 nir_lower_atomics(nir_shader *shader)
 {
    nir_foreach_overload(shader, overload) {
-      if (overload->impl)
+      if (overload->impl) {
          nir_foreach_block(overload->impl, lower_block, overload->impl);
+         nir_metadata_preserve(overload->impl, nir_metadata_block_index |
+                                               nir_metadata_dominance);
+      }
    }
 }
diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c
index 1ab0400..2a52b81 100644
--- a/src/glsl/nir/nir_lower_io.c
+++ b/src/glsl/nir/nir_lower_io.c
@@ -307,6 +307,9 @@ nir_lower_io_impl(nir_function_impl *impl)
    state.mem_ctx = ralloc_parent(impl);
 
    nir_foreach_block(impl, nir_lower_io_block, &state);
+
+   nir_metadata_preserve(impl, nir_metadata_block_index |
+                               nir_metadata_dominance);
 }
 
 void
diff --git a/src/glsl/nir/nir_lower_locals_to_regs.c b/src/glsl/nir/nir_lower_locals_to_regs.c
index 081ed6b..5dec1b9 100644
--- a/src/glsl/nir/nir_lower_locals_to_regs.c
+++ b/src/glsl/nir/nir_lower_locals_to_regs.c
@@ -292,6 +292,9 @@ nir_lower_locals_to_regs_impl(nir_function_impl *impl)
 
    nir_foreach_block(impl, lower_locals_to_regs_block, &state);
 
+   nir_metadata_preserve(impl, nir_metadata_block_index |
+                               nir_metadata_dominance);
+
    _mesa_hash_table_destroy(state.regs_table, NULL);
 }
 
diff --git a/src/glsl/nir/nir_lower_system_values.c b/src/glsl/nir/nir_lower_system_values.c
index e700df4..7bb02a7 100644
--- a/src/glsl/nir/nir_lower_system_values.c
+++ b/src/glsl/nir/nir_lower_system_values.c
@@ -91,6 +91,8 @@ static void
 convert_impl(nir_function_impl *impl)
 {
    nir_foreach_block(impl, convert_block, NULL);
+   nir_metadata_preserve(impl, nir_metadata_block_index |
+                               nir_metadata_dominance);
 }
 
 void
diff --git a/src/glsl/nir/nir_opt_constant_folding.c b/src/glsl/nir/nir_opt_constant_folding.c
index e2b16e9..f4a987c 100644
--- a/src/glsl/nir/nir_opt_constant_folding.c
+++ b/src/glsl/nir/nir_opt_constant_folding.c
@@ -334,6 +334,10 @@ nir_opt_constant_folding_impl(nir_function_impl *impl)
 
    nir_foreach_block(impl, constant_fold_block, &state);
 
+   if (state.progress)
+      nir_metadata_preserve(impl, nir_metadata_block_index |
+                                  nir_metadata_dominance);
+
    return state.progress;
 }
 
diff --git a/src/glsl/nir/nir_opt_dce.c b/src/glsl/nir/nir_opt_dce.c
index 365a8cd..8a7490d 100644
--- a/src/glsl/nir/nir_opt_dce.c
+++ b/src/glsl/nir/nir_opt_dce.c
@@ -166,6 +166,10 @@ nir_opt_dce_impl(nir_function_impl *impl)
    bool progress = false;
    nir_foreach_block(impl, delete_block_cb, &progress);
 
+   if (progress)
+      nir_metadata_preserve(impl, nir_metadata_block_index |
+                                  nir_metadata_dominance);
+
    return progress;
 }
 
diff --git a/src/glsl/nir/nir_to_ssa.c b/src/glsl/nir/nir_to_ssa.c
index 757fcf0..acbe5e9 100644
--- a/src/glsl/nir/nir_to_ssa.c
+++ b/src/glsl/nir/nir_to_ssa.c
@@ -631,7 +631,7 @@ destroy_rewrite_state(rewrite_state *state)
 void
 nir_convert_to_ssa_impl(nir_function_impl *impl)
 {
-   nir_calc_dominance_impl(impl);
+   nir_metadata_require(impl, nir_metadata_dominance);
 
    insert_phi_nodes(impl);
 
@@ -642,6 +642,9 @@ nir_convert_to_ssa_impl(nir_function_impl *impl)
 
    remove_unused_regs(impl, &state);
 
+   nir_metadata_preserve(impl, nir_metadata_block_index |
+                               nir_metadata_dominance);
+
    destroy_rewrite_state(&state);
 }
 
-- 
2.2.0



More information about the mesa-dev mailing list