From b99efb8af06539e999018826f86f413fce3222f3 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Wed, 7 Jul 2021 12:46:49 -0700 Subject: [PATCH] nir: Pull the instr list free function out to a helper. With the de-rallocing, we're going to have some more places that free a list of instrs. Reviewed-by: Matt Turner Part-of: --- src/compiler/nir/nir.c | 16 +++++++++++----- src/compiler/nir/nir.h | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) 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)