summaryrefslogtreecommitdiffstats
path: root/src/panfrost
diff options
context:
space:
mode:
authorBoris Brezillon <[email protected]>2019-08-14 01:56:30 +0200
committerBoris Brezillon <[email protected]>2019-08-27 16:50:52 +0200
commit5882e0def97a47aff050f5a3f412b97a7f440e27 (patch)
tree8f251b95b063de2f8f97de7125d9f9ddd9ee75f1 /src/panfrost
parent3ac49f135a104ea0420972403cbb53d94b1ab45f (diff)
panfrost: Free all block/instruction objects before leaving midgard_compile_shader_nir()
Right now we're leaking all block and instruction objects allocated by the compiler. Let's clean things up before leaving midgard_compile_shader_nir(). Signed-off-by: Boris Brezillon <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/panfrost')
-rw-r--r--src/panfrost/midgard/compiler.h12
-rw-r--r--src/panfrost/midgard/midgard_compile.c3
2 files changed, 15 insertions, 0 deletions
diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h
index f9ba31b5959..d131bb8c191 100644
--- a/src/panfrost/midgard/compiler.h
+++ b/src/panfrost/midgard/compiler.h
@@ -333,6 +333,9 @@ mir_next_op(struct midgard_instruction *ins)
#define mir_foreach_block(ctx, v) \
list_for_each_entry(struct midgard_block, v, &ctx->blocks, link)
+#define mir_foreach_block_safe(ctx, v) \
+ list_for_each_entry_safe(struct midgard_block, v, &ctx->blocks, link)
+
#define mir_foreach_block_from(ctx, from, v) \
list_for_each_entry_from(struct midgard_block, v, from, &ctx->blocks, link)
@@ -392,6 +395,15 @@ mir_next_op(struct midgard_instruction *ins)
#define mir_foreach_src(ins, v) \
for (unsigned v = 0; v < ARRAY_SIZE(ins->src); ++v)
+static inline void mir_remove_block(struct midgard_block *block)
+{
+ mir_foreach_instr_in_block_safe(block, ins)
+ mir_remove_instruction(ins);
+
+ list_del(&block->link);
+ free(block);
+}
+
static inline midgard_instruction *
mir_last_in_block(struct midgard_block *block)
{
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index 74511b278d1..56a75243314 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -2835,6 +2835,9 @@ midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midga
ctx->spills, ctx->fills);
}
+ mir_foreach_block_safe(ctx, block)
+ mir_remove_block(block);
+
ralloc_free(ctx);
return 0;