panfrost: add lcra_free() to free lcra state
authorUrja Rannikko <urjaman@gmail.com>
Fri, 6 Dec 2019 02:41:31 +0000 (02:41 +0000)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 6 Dec 2019 15:26:13 +0000 (15:26 +0000)
Signed-off-by: Urja Rannikko <urjaman@gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/lcra.c
src/panfrost/midgard/lcra.h
src/panfrost/midgard/midgard_schedule.c

index f5e2ff2d8fec14e619d5cc4cdae3d334ab9dfc5a..7c0a3a96bab6a1d8d6ead0e89253e04ccccbf284 100644 (file)
@@ -66,6 +66,22 @@ lcra_alloc_equations(
         return l;
 }
 
+void
+lcra_free(struct lcra_state *l)
+{
+        free(l->alignment);
+        free(l->linear);
+        free(l->modulus);
+        free(l->class);
+        free(l->class_start);
+        free(l->class_disjoint);
+        free(l->class_size);
+        free(l->spill_cost);
+        free(l->solutions);
+
+        free(l);
+}
+
 void
 lcra_set_alignment(struct lcra_state *l, unsigned node, unsigned align_log2)
 {
index a9bdd57026ca0e2aa8fa4ad9dccc076ae5899936..68afc4a848e5acec38bf9815fae5478555cac724 100644 (file)
@@ -85,6 +85,8 @@ lcra_alloc_equations(
                 unsigned min_alignment, unsigned max_alignment,
                 unsigned bound, unsigned class_count);
 
+void
+lcra_free(struct lcra_state *l);
 
 void
 lcra_set_disjoint_class(struct lcra_state *l, unsigned c1, unsigned c2);
index 5e6ac15e539fb11e7209ed0e8d1eb24cae7e8767..dcf3764d688d904b44632f7100d18b5794c27934 100644 (file)
@@ -1427,7 +1427,11 @@ schedule_program(compiler_context *ctx)
                 mir_squeeze_index(ctx);
                 mir_invalidate_liveness(ctx);
 
-                l = NULL;
+                if (l) {
+                        lcra_free(l);
+                        l = NULL;
+                }
+
                 l = allocate_registers(ctx, &spilled);
         } while(spilled && ((iter_count--) > 0));
 
@@ -1442,4 +1446,6 @@ schedule_program(compiler_context *ctx)
         ctx->tls_size = spill_count * 16;
 
         install_registers(ctx, l);
+
+        lcra_free(l);
 }