ir3/ra: Reinitialize interval when inserting
authorConnor Abbott <cwabbott0@gmail.com>
Fri, 23 Jul 2021 09:50:46 +0000 (11:50 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 20 Aug 2021 10:37:36 +0000 (10:37 +0000)
Otherwise when an interval is removed and then re-inserted it could
have an invalid/corrupted parent link and child tree. I think RA
happened to never do this, but spilling will.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12033>

src/freedreno/ir3/ir3_ra.c

index dd8d4ad..a30455e 100644 (file)
@@ -175,6 +175,17 @@ void
 ir3_reg_interval_insert(struct ir3_reg_ctx *ctx,
                         struct ir3_reg_interval *interval)
 {
+   rb_tree_init(&interval->children);
+   interval->parent = NULL;
+   interval_insert(ctx, &ctx->intervals, interval);
+}
+
+/* Call after ir3_reg_interval_remove_temp() to reinsert the interval */
+static void
+ir3_reg_interval_reinsert(struct ir3_reg_ctx *ctx,
+                          struct ir3_reg_interval *interval)
+{
+   interval->parent = NULL;
    interval_insert(ctx, &ctx->intervals, interval);
 }
 
@@ -669,7 +680,7 @@ ra_push_interval(struct ra_ctx *ctx, struct ra_file *file,
    interval->physreg_start = dst;
    interval->physreg_end = dst + removed->size;
 
-   ir3_reg_interval_insert(&file->reg_ctx, &interval->interval);
+   ir3_reg_interval_reinsert(&file->reg_ctx, &interval->interval);
 }
 
 /* Pick up the interval and place it at "dst". */