freedreno/ir3: Validate physical successors
authorRob Clark <robdclark@chromium.org>
Tue, 7 Sep 2021 21:21:40 +0000 (14:21 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 8 Sep 2021 08:53:39 +0000 (08:53 +0000)
Each block's physical successors should be a superset of the logical
successors.

Also validate that the successors are sane (ie. we shouldn't have the
2nd one if we don't have the first)

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12742>

src/freedreno/ir3/ir3_validate.c

index 08f2df4..51955b8 100644 (file)
@@ -336,6 +336,15 @@ validate_instr(struct ir3_validate_ctx *ctx, struct ir3_instruction *instr)
    }
 }
 
+static bool
+is_physical_successor(struct ir3_block *block, struct ir3_block *succ)
+{
+   for (unsigned i = 0; i < ARRAY_SIZE(block->physical_successors); i++)
+      if (block->physical_successors[i] == succ)
+         return true;
+   return false;
+}
+
 void
 ir3_validate(struct ir3 *ir)
 {
@@ -375,9 +384,16 @@ ir3_validate(struct ir3 *ir)
       }
 
       for (unsigned i = 0; i < 2; i++) {
-         if (block->successors[i])
+         if (block->successors[i]) {
             validate_phi_src(ctx, block->successors[i], block);
+
+            /* Each logical successor should also be a physical successor: */
+            validate_assert(ctx, is_physical_successor(block, block->successors[i]));
+         }
       }
+
+      validate_assert(ctx, block->successors[0] || !block->successors[1]);
+      validate_assert(ctx, block->physical_successors[0] || !block->physical_successors[1]);
    }
 
    ralloc_free(ctx);