com php-src: Fix block removal if there are duplicate successors: ext/opcache/Optimizer/zend_ssa.c ext/opcache/tests/block
_removal_with_duplicate_successors.phpt
| From: | Nikita Popov | Date: | Sat, 22 Jul 2017 12:53:23 +0000 |
| Subject: | com php-src: Fix block removal if there are duplicate successors: ext/opcache/Optimizer/zend_ssa.c ext/opcache/tests/block _removal_with_duplicate_successors.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98716@lists.php.net to get a copy of this message | ||
Commit: 96665fbfe0d520035f672dc7919b541b288806ca
Author: Nikita Popov <nikita.ppv@gmail.com> Sat, 22 Jul 2017 14:53:23 +0200
Parents: 1e9ad4a30720c14939837d352b953636b4002818
Branches: PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=96665fbfe0d520035f672dc7919b541b288806ca
Log:
Fix block removal if there are duplicate successors
Changed paths:
M ext/opcache/Optimizer/zend_ssa.c
A ext/opcache/tests/block_removal_with_duplicate_successors.phpt
Diff:
diff --git a/ext/opcache/Optimizer/zend_ssa.c b/ext/opcache/Optimizer/zend_ssa.c
index b0c087b..a82d7ff 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 0000000..750a169
--- /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--
+<?php
+function test($foo) {
+ $bar = 0;
+ if ($bar === 1 && $foo && PHP_SAPI !== 'cli') {
+ echo "foo\n";
+ }
+ echo "bar\n";
+}
+test(1);
+?>
+--EXPECT--
+bar