summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorConnor Abbott <[email protected]>2015-07-21 19:54:29 -0700
committerKenneth Graunke <[email protected]>2015-08-24 13:31:42 -0700
commit6f5c81f86f9b1b08b57435562be657fb2d220408 (patch)
tree3aa3f3b284a73f6354169d76bcd3f27e191a7da6 /src
parent6d028749ac593b6c724ab86a42bf969da47cc569 (diff)
nir/cf: fix link_blocks() when there are no successors
When we insert a single basic block A into another basic block B, we will split B into C and D, insert A in the middle, and then splice together C, A, and D. When we splice together C and A, we need to move the successors of A into C -- except A has no successors, since it hasn't been inserted yet. So in move_successors(), we need to handle the case where the block whose successors are to be moved doesn't have any successors. Fixing link_blocks() here prevents a segfault and makes it work correctly. Signed-off-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/nir/nir_control_flow.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/glsl/nir/nir_control_flow.c b/src/glsl/nir/nir_control_flow.c
index 91788adb85f..9ae113f3959 100644
--- a/src/glsl/nir/nir_control_flow.c
+++ b/src/glsl/nir/nir_control_flow.c
@@ -57,7 +57,8 @@ static void
link_blocks(nir_block *pred, nir_block *succ1, nir_block *succ2)
{
pred->successors[0] = succ1;
- block_add_pred(succ1, pred);
+ if (succ1 != NULL)
+ block_add_pred(succ1, pred);
pred->successors[1] = succ2;
if (succ2 != NULL)