diff --git a/src/.clang-format b/src/.clang-format index 7de8b4661b7..c7a1f1aecfc 100644 --- a/src/.clang-format +++ b/src/.clang-format @@ -145,6 +145,7 @@ ForEachMacros: - nir_foreach_phi_safe - nir_foreach_function + - nir_foreach_function_safe - nir_foreach_function_with_impl - nir_foreach_function_impl diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index cc424f54463..e488a799671 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -3735,7 +3735,7 @@ void nir_remove_sysval_output(nir_intrinsic_instr *intr) void nir_remove_non_entrypoints(nir_shader *nir) { - foreach_list_typed_safe(nir_function, func, node, &nir->functions) { + nir_foreach_function_safe(func, nir) { if (!func->is_entrypoint) exec_node_remove(&func->node); } diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 910b8e67644..5e06f163b81 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4005,6 +4005,9 @@ typedef struct nir_shader { #define nir_foreach_function(func, shader) \ foreach_list_typed(nir_function, func, node, &(shader)->functions) +#define nir_foreach_function_safe(func, shader) \ + foreach_list_typed_safe(nir_function, func, node, &(shader)->functions) + static inline nir_function * nir_foreach_function_with_impl_first(const nir_shader *shader) {