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 <kenneth@whitecape.org> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user