summaryrefslogtreecommitdiff
path: root/src/compiler/nir/nir_clone.c
diff options
context:
space:
mode:
authorRhys Perry <pendingchaos02@gmail.com>2021-09-08 15:24:10 +0100
committerMarge Bot <emma+marge@anholt.net>2022-08-30 18:21:44 +0000
commitd09b658dbd936822a1517be53450988a4c8ee456 (patch)
treea9a79c78d8db059164a4097533688602bc89aacc /src/compiler/nir/nir_clone.c
parent69ba1c4d596a453530553b8b004a157d8c7292d7 (diff)
downloadmesa-d09b658dbd936822a1517be53450988a4c8ee456.tar.gz
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 <pendingchaos02@gmail.com> Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com> Reviewed-by: Emma Anholt <emma@anholt.net> Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5034 Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12910>
Diffstat (limited to 'src/compiler/nir/nir_clone.c')
-rw-r--r--src/compiler/nir/nir_clone.c10
1 files changed, 2 insertions, 8 deletions
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 */