From d09b658dbd936822a1517be53450988a4c8ee456 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Wed, 8 Sep 2021 15:24:10 +0100 Subject: nir: use a GC context for instructions Gives an roughly -15% change in compile-time for RADV/ACO. Memory usage increase seems to be 5-6%. Signed-off-by: Rhys Perry Reviewed-by: Jason Ekstrand Reviewed-by: Emma Anholt Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5034 Part-of: --- src/compiler/nir/nir_clone.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/compiler/nir/nir_clone.c') diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c index 69569d17010..700f1b4ddb7 100644 --- a/src/compiler/nir/nir_clone.c +++ b/src/compiler/nir/nir_clone.c @@ -244,7 +244,7 @@ __clone_src(clone_state *state, void *ninstr_or_if, } else { nsrc->reg.reg = remap_reg(state, src->reg.reg); if (src->reg.indirect) { - nsrc->reg.indirect = malloc(sizeof(nir_src)); + nsrc->reg.indirect = gc_alloc(state->ns->gctx, nir_src, 1); __clone_src(state, ninstr_or_if, nsrc->reg.indirect, src->reg.indirect); } nsrc->reg.base_offset = src->reg.base_offset; @@ -264,7 +264,7 @@ __clone_dst(clone_state *state, nir_instr *ninstr, } else { ndst->reg.reg = remap_reg(state, dst->reg.reg); if (dst->reg.indirect) { - ndst->reg.indirect = malloc(sizeof(nir_src)); + ndst->reg.indirect = gc_alloc(state->ns->gctx, nir_src, 1); __clone_src(state, ninstr, ndst->reg.indirect, dst->reg.indirect); } ndst->reg.base_offset = dst->reg.base_offset; @@ -814,10 +814,6 @@ nir_shader_replace(nir_shader *dst, nir_shader *src) ralloc_adopt(dead_ctx, dst); ralloc_free(dead_ctx); - list_for_each_entry_safe(nir_instr, instr, &dst->gc_list, gc_node) { - nir_instr_free(instr); - } - /* Re-parent all of src's ralloc children to dst */ ralloc_adopt(dst, src); @@ -826,8 +822,6 @@ nir_shader_replace(nir_shader *dst, nir_shader *src) /* We have to move all the linked lists over separately because we need the * pointers in the list elements to point to the lists in dst and not src. */ - list_replace(&src->gc_list, &dst->gc_list); - list_inithead(&src->gc_list); exec_list_move_nodes_to(&src->variables, &dst->variables); /* Now move the functions over. This takes a tiny bit more work */ -- cgit v1.2.1