freedreno/ir3: Set up the block predecessors for a3xx TF
authorEric Anholt <eric@anholt.net>
Fri, 1 May 2020 00:30:02 +0000 (17:30 -0700)
committerMarge Bot <eric+marge@anholt.net>
Fri, 1 May 2020 16:26:31 +0000 (16:26 +0000)
Fixes a segfault in ir3_legalize.

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

src/freedreno/ir3/ir3.c
src/freedreno/ir3/ir3_compiler_nir.c

index d4fcd995ed08995704ae272b191d924228554021..cb7418bf2e0dcfdcf655eaaa3cca6eb7850627e0 100644 (file)
@@ -1023,6 +1023,7 @@ struct ir3_block * ir3_block_create(struct ir3 *shader)
        block->shader = shader;
        list_inithead(&block->node);
        list_inithead(&block->instr_list);
+       block->predecessors = _mesa_pointer_set_create(block);
        return block;
 }
 
index 5f55596bb6382bf07b2788a0dc50ed13d30d43c5..9c42efd67adcc78feeef8db5f2bcfe0038277cd2 100644 (file)
@@ -2644,7 +2644,6 @@ get_block(struct ir3_context *ctx, const nir_block *nblock)
        block->nblock = nblock;
        _mesa_hash_table_insert(ctx->block_ht, nblock, block);
 
-       block->predecessors = _mesa_pointer_set_create(block);
        set_foreach(nblock->predecessors, sentry) {
                _mesa_set_add(block->predecessors, get_block(ctx, sentry->key));
        }
@@ -2758,10 +2757,12 @@ emit_cf_list(struct ir3_context *ctx, struct exec_list *list)
  *      // succs: blockStreamOut, blockNewEnd
  *   }
  *   blockStreamOut {
+ *      // preds: blockOrigEnd
  *      ... stream-out instructions ...
  *      // succs: blockNewEnd
  *   }
  *   blockNewEnd {
+ *      // preds: blockOrigEnd, blockStreamOut
  *   }
  */
 static void
@@ -2787,7 +2788,6 @@ emit_stream_out(struct ir3_context *ctx)
         */
        orig_end_block = ctx->block;
 
-// TODO these blocks need to update predecessors..
 // maybe w/ store_global intrinsic, we could do this
 // stuff in nir->nir pass
 
@@ -2799,7 +2799,12 @@ emit_stream_out(struct ir3_context *ctx)
 
        orig_end_block->successors[0] = stream_out_block;
        orig_end_block->successors[1] = new_end_block;
+
        stream_out_block->successors[0] = new_end_block;
+       _mesa_set_add(stream_out_block->predecessors, orig_end_block);
+
+       _mesa_set_add(new_end_block->predecessors, orig_end_block);
+       _mesa_set_add(new_end_block->predecessors, stream_out_block);
 
        /* setup 'if (vtxcnt < maxvtxcnt)' condition: */
        cond = ir3_CMPS_S(ctx->block, vtxcnt, 0, maxvtxcnt, 0);