pan/bi: Validate phi ordering
authorAlyssa Rosenzweig <alyssa@collabora.com>
Fri, 13 May 2022 21:53:53 +0000 (17:53 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 2 Sep 2022 16:03:23 +0000 (16:03 +0000)
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17794>

src/panfrost/bifrost/bi_validate.c

index 1c6e8b3..3a2c51d 100644 (file)
@@ -170,6 +170,26 @@ bi_validate_dest(bi_context *ctx)
         return succ;
 }
 
+/*
+ * Validate that phis only appear at the beginning of blocks.
+ */
+static bool
+bi_validate_phi_ordering(bi_context *ctx)
+{
+        bi_foreach_block(ctx, block) {
+                bool start = true;
+
+                bi_foreach_instr_in_block(block, I) {
+                        if (start)
+                                start = I->op == BI_OPCODE_PHI;
+                        else if (I->op == BI_OPCODE_PHI)
+                                return false;
+                }
+        }
+
+        return true;
+}
+
 void
 bi_validate(bi_context *ctx, const char *after)
 {
@@ -198,6 +218,11 @@ bi_validate(bi_context *ctx, const char *after)
                 fail = true;
         }
 
+        if (!bi_validate_phi_ordering(ctx)) {
+                fprintf(stderr, "Unexpected phi ordering after %s\n", after);
+                fail = true;
+        }
+
         if (fail) {
                 bi_print_shader(ctx, stderr);
                 exit(1);