summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir/nir_control_flow.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl/nir/nir_control_flow.c')
-rw-r--r--src/glsl/nir/nir_control_flow.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/glsl/nir/nir_control_flow.c b/src/glsl/nir/nir_control_flow.c
index 96395a4..33b06d0 100644
--- a/src/glsl/nir/nir_control_flow.c
+++ b/src/glsl/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);
@@ -746,6 +749,12 @@ nir_cf_extract(nir_cf_list *extracted, nir_cursor begin, nir_cursor end)
{
nir_block *block_begin, *block_end, *block_before, *block_after;
+ if (nir_cursors_equal(begin, end)) {
+ exec_list_make_empty(&extracted->list);
+ extracted->impl = NULL; /* we shouldn't need this */
+ return;
+ }
+
/* In the case where begin points to an instruction in some basic block and
* end points to the end of the same basic block, we rely on the fact that
* splitting on an instruction moves earlier instructions into a new basic
@@ -785,6 +794,9 @@ nir_cf_reinsert(nir_cf_list *cf_list, nir_cursor cursor)
{
nir_block *before, *after;
+ if (exec_list_is_empty(&cf_list->list))
+ return;
+
split_block_cursor(cursor, &before, &after);
foreach_list_typed_safe(nir_cf_node, node, node, &cf_list->list) {