diff options
author | Jason Ekstrand <[email protected]> | 2019-09-02 12:53:16 -0500 |
---|---|---|
committer | Dylan Baker <[email protected]> | 2019-09-09 09:14:34 -0700 |
commit | 2c6e34ac9357a9acdf7dc59598e8f1863586bac8 (patch) | |
tree | db8258cae80b21c304ef91239f0de9f282d344fb /src | |
parent | 23bc3a401d36ae48b324ebc28a2e69a72c573580 (diff) |
nir: Add a block_is_unreachable helper
Cc: [email protected]
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
(cherry picked from commit f81a2623d82ccad6177fe1fe5b80a6398df29b6e)
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/nir/nir.h | 1 | ||||
-rw-r--r-- | src/compiler/nir/nir_dominance.c | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 0462fd89a04..5ad2d40f96a 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3378,6 +3378,7 @@ void nir_calc_dominance(nir_shader *shader); nir_block *nir_dominance_lca(nir_block *b1, nir_block *b2); bool nir_block_dominates(nir_block *parent, nir_block *child); +bool nir_block_is_unreachable(nir_block *block); void nir_dump_dom_tree_impl(nir_function_impl *impl, FILE *fp); void nir_dump_dom_tree(nir_shader *shader, FILE *fp); diff --git a/src/compiler/nir/nir_dominance.c b/src/compiler/nir/nir_dominance.c index c678727b471..8369c28984d 100644 --- a/src/compiler/nir/nir_dominance.c +++ b/src/compiler/nir/nir_dominance.c @@ -239,6 +239,20 @@ nir_block_dominates(nir_block *parent, nir_block *child) child->dom_post_index <= parent->dom_post_index; } +bool +nir_block_is_unreachable(nir_block *block) +{ + assert(nir_cf_node_get_function(&block->cf_node)->valid_metadata & + nir_metadata_dominance); + assert(nir_cf_node_get_function(&block->cf_node)->valid_metadata & + nir_metadata_block_index); + + /* Unreachable blocks have no dominator. The only reachable block with no + * dominator is the start block which has index 0. + */ + return block->index > 0 && block->imm_dom == NULL; +} + void nir_dump_dom_tree_impl(nir_function_impl *impl, FILE *fp) { |