Skip to content

Commit

Permalink
Fix block removal if there are duplicate successors
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Jul 22, 2017
1 parent 1e9ad4a commit 96665fb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ext/opcache/Optimizer/zend_ssa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 15 additions & 0 deletions ext/opcache/tests/block_removal_with_duplicate_successors.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Removing a block that has duplicate successors
--FILE--
<?php
function test($foo) {
$bar = 0;
if ($bar === 1 && $foo && PHP_SAPI !== 'cli') {
echo "foo\n";
}
echo "bar\n";
}
test(1);
?>
--EXPECT--
bar

0 comments on commit 96665fb

Please sign in to comment.