pan/midgard: Localize `visited` tracking
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 11 Mar 2020 12:03:28 +0000 (08:03 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 11 Mar 2020 20:28:20 +0000 (20:28 +0000)
Instead of a property on the block, just track it within the function to
minimize IR dependencies.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4150>

src/panfrost/midgard/compiler.h
src/panfrost/midgard/midgard_liveness.c

index fee1ba9d50424e0c26363b48de81956f9856300b..cf9420bf42842928b21c8614959285b4124941ec 100644 (file)
@@ -190,13 +190,6 @@ typedef struct midgard_block {
 
         struct set *predecessors;
 
-        /* The successors pointer form a graph, and in the case of
-         * complex control flow, this graph has a cycles. To aid
-         * traversal during liveness analysis, we have a visited?
-         * boolean for passes to use as they see fit, provided they
-         * clean up later */
-        bool visited;
-
         /* In liveness analysis, these are live masks (per-component) for
          * indices for the block. Scalar compilers have the luxury of using
          * simple bit fields, but for us, liveness is a vector idea. */
index fd93339ed9437382ce45e8f161ffa097548bbfc7..a1cb8436f111a1fad9ba2bb916692103d6160fbc 100644 (file)
@@ -129,11 +129,15 @@ mir_compute_liveness(compiler_context *ctx)
                         _mesa_hash_pointer,
                         _mesa_key_pointer_equal);
 
+        struct set *visited = _mesa_set_create(ctx,
+                        _mesa_hash_pointer,
+                        _mesa_key_pointer_equal);
+
         /* Allocate */
 
         mir_foreach_block(ctx, block) {
-                block->live_in = rzalloc_array(ctx, uint16_t, ctx->temp_count);
-                block->live_out = rzalloc_array(ctx, uint16_t, ctx->temp_count);
+                block->live_in = rzalloc_array(NULL, uint16_t, ctx->temp_count);
+                block->live_out = rzalloc_array(NULL, uint16_t, ctx->temp_count);
         }
 
         /* Initialize the work list with the exit block */
@@ -154,20 +158,19 @@ mir_compute_liveness(compiler_context *ctx)
 
                 /* If we made progress, we need to process the predecessors */
 
-                if (progress || !blk->visited) {
+                if (progress || !_mesa_set_search(visited, blk)) {
                         mir_foreach_predecessor(blk, pred)
                                 _mesa_set_add(work_list, pred);
                 }
 
-                blk->visited = true;
+                _mesa_set_add(visited, blk);
         } while((cur = _mesa_set_next_entry(work_list, NULL)) != NULL);
 
+        _mesa_set_destroy(visited, NULL);
+        _mesa_set_destroy(work_list, NULL);
+
         /* Liveness is now valid */
         ctx->metadata |= MIDGARD_METADATA_LIVENESS;
-
-        mir_foreach_block(ctx, block) {
-                block->visited = false;
-        }
 }
 
 /* Once liveness data is no longer valid, call this */