summaryrefslogtreecommitdiffstats
path: root/src/panfrost/midgard/compiler.h
diff options
context:
space:
mode:
authorBoris Brezillon <[email protected]>2019-08-28 09:17:21 +0200
committerBoris Brezillon <[email protected]>2019-08-28 17:50:01 +0200
commit938c5b0148688f426235e81d6573f25e5021ceb7 (patch)
tree819b1716d1ece65028d330222b6b48c5cd22bbd2 /src/panfrost/midgard/compiler.h
parent6e01575b6817d4e3b243a09b0cea90fdb5d40d2f (diff)
panfrost: Use ralloc() to allocate instructions to avoid leaking those objs
Instructions attached to blocks are never explicitly freed. Let's use ralloc() to attach those objects to the compiler context so that they are automatically freed when the ctx object is freed. Signed-off-by: Boris Brezillon <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/panfrost/midgard/compiler.h')
-rw-r--r--src/panfrost/midgard/compiler.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h
index f9ba31b5959..68716f92b0b 100644
--- a/src/panfrost/midgard/compiler.h
+++ b/src/panfrost/midgard/compiler.h
@@ -288,9 +288,9 @@ typedef struct compiler_context {
/* Append instruction to end of current block */
static inline midgard_instruction *
-mir_upload_ins(struct midgard_instruction ins)
+mir_upload_ins(struct compiler_context *ctx, struct midgard_instruction ins)
{
- midgard_instruction *heap = malloc(sizeof(ins));
+ midgard_instruction *heap = ralloc(ctx, struct midgard_instruction);
memcpy(heap, &ins, sizeof(ins));
return heap;
}
@@ -298,15 +298,17 @@ mir_upload_ins(struct midgard_instruction ins)
static inline midgard_instruction *
emit_mir_instruction(struct compiler_context *ctx, struct midgard_instruction ins)
{
- midgard_instruction *u = mir_upload_ins(ins);
+ midgard_instruction *u = mir_upload_ins(ctx, ins);
list_addtail(&u->link, &ctx->current_block->instructions);
return u;
}
static inline struct midgard_instruction *
-mir_insert_instruction_before(struct midgard_instruction *tag, struct midgard_instruction ins)
+mir_insert_instruction_before(struct compiler_context *ctx,
+ struct midgard_instruction *tag,
+ struct midgard_instruction ins)
{
- struct midgard_instruction *u = mir_upload_ins(ins);
+ struct midgard_instruction *u = mir_upload_ins(ctx, ins);
list_addtail(&u->link, &tag->link);
return u;
}
@@ -315,7 +317,6 @@ static inline void
mir_remove_instruction(struct midgard_instruction *ins)
{
list_del(&ins->link);
- free(ins);
}
static inline midgard_instruction*