diff options
author | Matt Turner <[email protected]> | 2018-09-10 14:31:29 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2019-01-09 16:42:40 -0800 |
commit | 2623653126985be5aca1a29e24bdecb4bb42c8b4 (patch) | |
tree | ed143cc0df8f0a91fd36d15ebce95251dfe855a4 | |
parent | e633fae5cb160aec66195364fac05af359503be7 (diff) |
nir: Unset metadata debug bit if no progress made
NIR metadata validation verifies that the debug bit was unset (by a call
to nir_metadata_preserve) if a NIR optimization pass made progress on
the shader. With the expectation that the NIR shader consists of only a
single main function, it has been safe to call nir_metadata_preserve()
iff progress was made.
However, most optimization passes calculate progress per-function and
then return the union of those calculations. In the case that an
optimization pass makes progress only on a subset of the functions in
the shader metadata validation will detect the debug bit is still set on
any unchanged functions resulting in a failed assertion.
This patch offers a quick solution (short of a larger scale refactoring
which I do not wish to undertake as part of this series) that simply
unsets the debug bit on unchanged functions.
Reviewed-by: Kenneth Graunke <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
22 files changed, 115 insertions, 12 deletions
diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py index 238127235fd..fe9d1051e67 100644 --- a/src/compiler/nir/nir_algebraic.py +++ b/src/compiler/nir/nir_algebraic.py @@ -731,9 +731,14 @@ ${pass_name}_impl(nir_function_impl *impl, const bool *condition_flags) progress |= ${pass_name}_block(&build, block, condition_flags); } - if (progress) + if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif + } return progress; } diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c index 947888a5e20..26de64c5140 100644 --- a/src/compiler/nir/nir_deref.c +++ b/src/compiler/nir/nir_deref.c @@ -721,6 +721,10 @@ nir_opt_deref_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif } return progress; diff --git a/src/compiler/nir/nir_inline_functions.c b/src/compiler/nir/nir_inline_functions.c index dd2dfa04cfc..74d39db7ab2 100644 --- a/src/compiler/nir/nir_inline_functions.c +++ b/src/compiler/nir/nir_inline_functions.c @@ -125,6 +125,10 @@ inline_function_impl(nir_function_impl *impl, struct set *inlined) nir_index_local_regs(impl); nir_metadata_preserve(impl, nir_metadata_none); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif } _mesa_set_add(inlined, impl); diff --git a/src/compiler/nir/nir_lower_constant_initializers.c b/src/compiler/nir/nir_lower_constant_initializers.c index b1c51834917..cbee59b1f30 100644 --- a/src/compiler/nir/nir_lower_constant_initializers.c +++ b/src/compiler/nir/nir_lower_constant_initializers.c @@ -117,6 +117,10 @@ nir_lower_constant_initializers(nir_shader *shader, nir_variable_mode modes) nir_metadata_preserve(function->impl, nir_metadata_block_index | nir_metadata_dominance | nir_metadata_live_ssa_defs); + } else { +#ifndef NDEBUG + function->impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif } } diff --git a/src/compiler/nir/nir_lower_double_ops.c b/src/compiler/nir/nir_lower_double_ops.c index 48e0c80b108..4d4cdf635ea 100644 --- a/src/compiler/nir/nir_lower_double_ops.c +++ b/src/compiler/nir/nir_lower_double_ops.c @@ -754,9 +754,14 @@ nir_lower_doubles_impl(nir_function_impl *impl, } } - if (progress) + if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif + } return progress; } diff --git a/src/compiler/nir/nir_lower_global_vars_to_local.c b/src/compiler/nir/nir_lower_global_vars_to_local.c index 7cc1b2cb69e..1ca7c1996a3 100644 --- a/src/compiler/nir/nir_lower_global_vars_to_local.c +++ b/src/compiler/nir/nir_lower_global_vars_to_local.c @@ -107,5 +107,13 @@ nir_lower_global_vars_to_local(nir_shader *shader) if (progress) nir_fixup_deref_modes(shader); +#ifndef NDEBUG + nir_foreach_function(function, shader) { + if (function->impl) { + function->impl->valid_metadata &= ~nir_metadata_not_properly_reset; + } + } +#endif + return progress; } diff --git a/src/compiler/nir/nir_lower_int64.c b/src/compiler/nir/nir_lower_int64.c index 1ec4816cf3e..1c4b4b33797 100644 --- a/src/compiler/nir/nir_lower_int64.c +++ b/src/compiler/nir/nir_lower_int64.c @@ -830,8 +830,13 @@ lower_int64_impl(nir_function_impl *impl, nir_lower_int64_options options) } } - if (progress) + if (progress) { nir_metadata_preserve(impl, nir_metadata_none); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif + } return progress; } diff --git a/src/compiler/nir/nir_lower_load_const_to_scalar.c b/src/compiler/nir/nir_lower_load_const_to_scalar.c index b62d32e483e..a821a77e90d 100644 --- a/src/compiler/nir/nir_lower_load_const_to_scalar.c +++ b/src/compiler/nir/nir_lower_load_const_to_scalar.c @@ -95,9 +95,14 @@ nir_lower_load_const_to_scalar_impl(nir_function_impl *impl) } } - if (progress) + if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif + } return progress; } diff --git a/src/compiler/nir/nir_lower_returns.c b/src/compiler/nir/nir_lower_returns.c index 292671ea8cb..e166a7cc32a 100644 --- a/src/compiler/nir/nir_lower_returns.c +++ b/src/compiler/nir/nir_lower_returns.c @@ -274,6 +274,10 @@ nir_lower_returns_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_none); nir_repair_ssa_impl(impl); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif } return progress; diff --git a/src/compiler/nir/nir_lower_var_copies.c b/src/compiler/nir/nir_lower_var_copies.c index e72f7efcecb..1e7ad784934 100644 --- a/src/compiler/nir/nir_lower_var_copies.c +++ b/src/compiler/nir/nir_lower_var_copies.c @@ -140,9 +140,14 @@ lower_var_copies_impl(nir_function_impl *impl) } } - if (progress) + if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif + } return progress; } diff --git a/src/compiler/nir/nir_lower_vars_to_ssa.c b/src/compiler/nir/nir_lower_vars_to_ssa.c index 98f3169f6ac..9c8f75f1083 100644 --- a/src/compiler/nir/nir_lower_vars_to_ssa.c +++ b/src/compiler/nir/nir_lower_vars_to_ssa.c @@ -698,8 +698,12 @@ nir_lower_vars_to_ssa_impl(nir_function_impl *impl) foreach_deref_node_match(path, lower_copies_to_load_store, &state); } - if (!progress) + if (!progress) { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif return false; + } nir_metadata_require(impl, nir_metadata_dominance); diff --git a/src/compiler/nir/nir_opt_constant_folding.c b/src/compiler/nir/nir_opt_constant_folding.c index 5097a3bcc36..83be0d78dbd 100644 --- a/src/compiler/nir/nir_opt_constant_folding.c +++ b/src/compiler/nir/nir_opt_constant_folding.c @@ -193,9 +193,14 @@ nir_opt_constant_folding_impl(nir_function_impl *impl) progress |= constant_fold_block(block, mem_ctx); } - if (progress) + if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif + } return progress; } diff --git a/src/compiler/nir/nir_opt_copy_prop_vars.c b/src/compiler/nir/nir_opt_copy_prop_vars.c index 28c93d35910..069fcad7199 100644 --- a/src/compiler/nir/nir_opt_copy_prop_vars.c +++ b/src/compiler/nir/nir_opt_copy_prop_vars.c @@ -876,6 +876,10 @@ nir_copy_prop_vars_impl(nir_function_impl *impl) if (state.progress) { nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif } ralloc_free(mem_ctx); diff --git a/src/compiler/nir/nir_opt_copy_propagate.c b/src/compiler/nir/nir_opt_copy_propagate.c index fcb85d15535..534f127c0d3 100644 --- a/src/compiler/nir/nir_opt_copy_propagate.c +++ b/src/compiler/nir/nir_opt_copy_propagate.c @@ -307,6 +307,10 @@ nir_copy_prop_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif } return progress; diff --git a/src/compiler/nir/nir_opt_cse.c b/src/compiler/nir/nir_opt_cse.c index db6bb9a4a22..bf42a6a33dc 100644 --- a/src/compiler/nir/nir_opt_cse.c +++ b/src/compiler/nir/nir_opt_cse.c @@ -70,9 +70,14 @@ nir_opt_cse_impl(nir_function_impl *impl) bool progress = cse_block(nir_start_block(impl), instr_set); - if (progress) + if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif + } nir_instr_set_destroy(instr_set); return progress; diff --git a/src/compiler/nir/nir_opt_dce.c b/src/compiler/nir/nir_opt_dce.c index 70532be33d7..724cf3f2034 100644 --- a/src/compiler/nir/nir_opt_dce.c +++ b/src/compiler/nir/nir_opt_dce.c @@ -145,9 +145,14 @@ nir_opt_dce_impl(nir_function_impl *impl) } } - if (progress) + if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif + } return progress; } diff --git a/src/compiler/nir/nir_opt_dead_cf.c b/src/compiler/nir/nir_opt_dead_cf.c index b547ab600bb..14986732096 100644 --- a/src/compiler/nir/nir_opt_dead_cf.c +++ b/src/compiler/nir/nir_opt_dead_cf.c @@ -339,8 +339,13 @@ opt_dead_cf_impl(nir_function_impl *impl) bool dummy; bool progress = dead_cf_list(&impl->body, &dummy); - if (progress) + if (progress) { nir_metadata_preserve(impl, nir_metadata_none); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif + } return progress; } diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c index d7a7bb2bb26..c2f945d4d59 100644 --- a/src/compiler/nir/nir_opt_if.c +++ b/src/compiler/nir/nir_opt_if.c @@ -873,6 +873,10 @@ nir_opt_if(nir_shader *shader) nir_lower_regs_to_ssa_impl(function->impl); progress = true; + } else { + #ifndef NDEBUG + function->impl->valid_metadata &= ~nir_metadata_not_properly_reset; + #endif } } diff --git a/src/compiler/nir/nir_opt_peephole_select.c b/src/compiler/nir/nir_opt_peephole_select.c index b27cdd28a99..1deb02a380e 100644 --- a/src/compiler/nir/nir_opt_peephole_select.c +++ b/src/compiler/nir/nir_opt_peephole_select.c @@ -282,8 +282,13 @@ nir_opt_peephole_select_impl(nir_function_impl *impl, unsigned limit, expensive_alu_ok); } - if (progress) + if (progress) { nir_metadata_preserve(impl, nir_metadata_none); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif + } return progress; } diff --git a/src/compiler/nir/nir_opt_remove_phis.c b/src/compiler/nir/nir_opt_remove_phis.c index d7ca2fe7179..9efbf422624 100644 --- a/src/compiler/nir/nir_opt_remove_phis.c +++ b/src/compiler/nir/nir_opt_remove_phis.c @@ -153,6 +153,10 @@ nir_opt_remove_phis_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif } return progress; diff --git a/src/compiler/nir/nir_opt_undef.c b/src/compiler/nir/nir_opt_undef.c index c26158dab7e..bdebf5540d6 100644 --- a/src/compiler/nir/nir_opt_undef.c +++ b/src/compiler/nir/nir_opt_undef.c @@ -154,10 +154,15 @@ nir_opt_undef(nir_shader *shader) } } - if (progress) + if (progress) { nir_metadata_preserve(function->impl, nir_metadata_block_index | nir_metadata_dominance); + } else { +#ifndef NDEBUG + function->impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif + } } } diff --git a/src/compiler/nir/nir_split_var_copies.c b/src/compiler/nir/nir_split_var_copies.c index 5ac1c33dde5..6260a8d7bfa 100644 --- a/src/compiler/nir/nir_split_var_copies.c +++ b/src/compiler/nir/nir_split_var_copies.c @@ -113,6 +113,10 @@ split_var_copies_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); + } else { +#ifndef NDEBUG + impl->valid_metadata &= ~nir_metadata_not_properly_reset; +#endif } return progress; |