nir: Add nir_foreach_function_safe and use it

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23902>
This commit is contained in:
Yonggang Luo
2023-06-29 01:05:45 +08:00
committed by Marge Bot
parent 0fbec6dd79
commit c4d3bc03c4
3 changed files with 5 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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)
{