pan/midgard: Use standard list traversal to find initial tag
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 31 Jul 2019 22:49:30 +0000 (15:49 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 1 Aug 2019 23:23:03 +0000 (16:23 -0700)
Fixes a hang (and abort) on empty shaders, which you shouldn't have
anyway but better safe than sorry. DCE going on the fritz is no reason
to freeze the system.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/midgard_compile.c

index d36caa3193d15211040dee9c8ef73dca9cfd1bb3..a35b43faee795885dff0006878e23e05e99dce17 100644 (file)
@@ -2229,19 +2229,16 @@ midgard_get_first_tag_from_block(compiler_context *ctx, unsigned block_idx)
 
         unsigned first_tag = 0;
 
-        do {
-                midgard_bundle *initial_bundle = util_dynarray_element(&initial_block->bundles, midgard_bundle, 0);
+        mir_foreach_block_from(ctx, initial_block, v) {
+                midgard_bundle *initial_bundle =
+                        util_dynarray_element(&v->bundles, midgard_bundle, 0);
 
                 if (initial_bundle) {
                         first_tag = initial_bundle->tag;
                         break;
                 }
+        }
 
-                /* Initial block is empty, try the next block */
-                initial_block = list_first_entry(&(initial_block->link), midgard_block, link);
-        } while(initial_block != NULL);
-
-        assert(first_tag);
         return first_tag;
 }