diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 824042b3303..924f50eaa94 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -1096,6 +1096,16 @@ void nir_instr_free(nir_instr *instr) ralloc_free(instr); } +void +nir_instr_free_list(struct exec_list *list) +{ + struct exec_node *node; + while ((node = exec_list_pop_head(list))) { + nir_instr *removed_instr = exec_node_data(nir_instr, node, node); + nir_instr_free(removed_instr); + } +} + static bool nir_instr_free_and_dce_live_cb(nir_ssa_def *def, void *state) { bool *live = state; @@ -1179,11 +1189,7 @@ nir_instr_free_and_dce(nir_instr *instr) exec_list_push_tail(&to_free, &dce_instr->node); } - struct exec_node *node; - while ((node = exec_list_pop_head(&to_free))) { - nir_instr *removed_instr = exec_node_data(nir_instr, node, node); - nir_instr_free(removed_instr); - } + nir_instr_free_list(&to_free); nir_instr_worklist_destroy(worklist); diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 392fad34e6b..0d9e09b41dc 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4226,6 +4226,7 @@ nir_instr_insert_after_cf_list(struct exec_list *list, nir_instr *after) void nir_instr_remove_v(nir_instr *instr); void nir_instr_free(nir_instr *instr); +void nir_instr_free_list(struct exec_list *list); static inline nir_cursor nir_instr_remove(nir_instr *instr)