From 96665fbfe0d520035f672dc7919b541b288806ca Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 22 Jul 2017 14:53:23 +0200 Subject: [PATCH] Fix block removal if there are duplicate successors --- ext/opcache/Optimizer/zend_ssa.c | 7 ++++++- .../block_removal_with_duplicate_successors.phpt | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 ext/opcache/tests/block_removal_with_duplicate_successors.phpt diff --git a/ext/opcache/Optimizer/zend_ssa.c b/ext/opcache/Optimizer/zend_ssa.c index b0c087b1bd..a82d7ff225 100644 --- a/ext/opcache/Optimizer/zend_ssa.c +++ b/ext/opcache/Optimizer/zend_ssa.c @@ -1382,7 +1382,12 @@ void zend_ssa_remove_block(zend_op_array *op_array, zend_ssa *ssa, int i) /* {{{ break; } } - ZEND_ASSERT(pred_offset != -1); + + /* If there are duplicate successors, the predecessors may have been removed in + * a previous iteration already. */ + if (pred_offset == -1) { + continue; + } /* For phis in successor blocks, remove the operands associated with this block */ for (phi = next_ssa_block->phis; phi; phi = phi->next) { diff --git a/ext/opcache/tests/block_removal_with_duplicate_successors.phpt b/ext/opcache/tests/block_removal_with_duplicate_successors.phpt new file mode 100644 index 0000000000..750a169014 --- /dev/null +++ b/ext/opcache/tests/block_removal_with_duplicate_successors.phpt @@ -0,0 +1,15 @@ +--TEST-- +Removing a block that has duplicate successors +--FILE-- + +--EXPECT-- +bar -- 2.50.1