summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/tests/remove_predecessor_of_pi_node.phpt14
-rw-r--r--ext/opcache/Optimizer/zend_ssa.c2
2 files changed, 15 insertions, 1 deletions
diff --git a/Zend/tests/remove_predecessor_of_pi_node.phpt b/Zend/tests/remove_predecessor_of_pi_node.phpt
new file mode 100644
index 0000000000..6231f08b3f
--- /dev/null
+++ b/Zend/tests/remove_predecessor_of_pi_node.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Regression test for incorrect update of pi node users when removing a predecessor block
+--FILE--
+<?php
+
+function test() {
+ for (; $n--; )
+ C;
+}
+test();
+
+?>
+--EXPECTF--
+Warning: Undefined variable $n in %s on line %d
diff --git a/ext/opcache/Optimizer/zend_ssa.c b/ext/opcache/Optimizer/zend_ssa.c
index 79de1e2f66..28a39823b5 100644
--- a/ext/opcache/Optimizer/zend_ssa.c
+++ b/ext/opcache/Optimizer/zend_ssa.c
@@ -1409,7 +1409,7 @@ void zend_ssa_remove_predecessor(zend_ssa *ssa, int from, int to) /* {{{ */
for (phi = next_ssa_block->phis; phi; phi = phi->next) {
if (phi->pi >= 0) {
if (phi->pi == from) {
- zend_ssa_remove_uses_of_var(ssa, phi->ssa_var);
+ zend_ssa_rename_var_uses(ssa, phi->ssa_var, phi->sources[0], /* update_types */ 0);
zend_ssa_remove_phi(ssa, phi);
}
} else {