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 <mattst88@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11776>
This commit is contained in:
+11
-5
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user