summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_control_flow.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-12-18 11:27:00 -0800
committerJason Ekstrand <[email protected]>2016-03-24 15:20:44 -0700
commit124f229ece8ffa7d1f8d530771f183f7803d6cdc (patch)
treeec6c2d058ad6bebcbafbbfda56f5f187c324d486 /src/compiler/nir/nir_control_flow.c
parent364212f1ede4b2ecf4361e27e24e3d84e19aa54d (diff)
nir/cf: Handle relinking top-level blocks
This can happen if a function ends in a return instruction and you remove the return. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_control_flow.c')
-rw-r--r--src/compiler/nir/nir_control_flow.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/compiler/nir/nir_control_flow.c b/src/compiler/nir/nir_control_flow.c
index 96395a41615..ecd9cbd4173 100644
--- a/src/compiler/nir/nir_control_flow.c
+++ b/src/compiler/nir/nir_control_flow.c
@@ -336,8 +336,7 @@ block_add_normal_succs(nir_block *block)
nir_block *next_block = nir_cf_node_as_block(next);
link_blocks(block, next_block, NULL);
- } else {
- assert(parent->type == nir_cf_node_loop);
+ } else if (parent->type == nir_cf_node_loop) {
nir_loop *loop = nir_cf_node_as_loop(parent);
nir_cf_node *head = nir_loop_first_cf_node(loop);
@@ -346,6 +345,10 @@ block_add_normal_succs(nir_block *block)
link_blocks(block, head_block, NULL);
insert_phi_undef(head_block, block);
+ } else {
+ assert(parent->type == nir_cf_node_function);
+ nir_function_impl *impl = nir_cf_node_as_function(parent);
+ link_blocks(block, impl->end_block, NULL);
}
} else {
nir_cf_node *next = nir_cf_node_next(&block->cf_node);