microsoft/clc: Fix usage of nir_builder_at

nir_builder_at requires a block to chase back to the function impl,
but for an empty function impl, the previous code produced a cursor
with a null pointer. It was also just extra complicated.

While I'm here, use the new foreach helper since this code needs an impl.

Fixes: 12a268ea ("microsoft: Use nir_builder_at")
Reviewed-by: Eric Engestrom <eric@igalia.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24042>
This commit is contained in:
Jesse Natalie
2023-07-07 09:39:11 -07:00
committed by Marge Bot
parent 511116d630
commit ea3c73b33c

View File

@@ -230,11 +230,11 @@ clc_lower_printf_base(nir_shader *nir, unsigned uav_id)
{
nir_variable *printf_var = NULL;
nir_ssa_def *printf_deref = NULL;
nir_foreach_function(func, nir) {
nir_builder b = nir_builder_at(nir_before_instr(nir_block_first_instr(nir_start_block(func->impl))));
nir_foreach_function_impl(impl, nir) {
nir_builder b = nir_builder_at(nir_before_block(nir_start_block(impl)));
bool progress = false;
nir_foreach_block(block, func->impl) {
nir_foreach_block(block, impl) {
nir_foreach_instr_safe(instr, block) {
if (instr->type != nir_instr_type_intrinsic)
continue;
@@ -253,11 +253,11 @@ clc_lower_printf_base(nir_shader *nir, unsigned uav_id)
}
if (progress)
nir_metadata_preserve(func->impl, nir_metadata_loop_analysis |
nir_metadata_block_index |
nir_metadata_dominance);
nir_metadata_preserve(impl, nir_metadata_loop_analysis |
nir_metadata_block_index |
nir_metadata_dominance);
else
nir_metadata_preserve(func->impl, nir_metadata_all);
nir_metadata_preserve(impl, nir_metadata_all);
}
return printf_var != NULL;