We can't just remove the uses, we need to replace uses.
The test case only fails on master with SSA integrity violations,
but I believe the root issue also existed previously.
--- /dev/null
+--TEST--
+Regression test for incorrect update of pi node users when removing a predecessor block
+--FILE--
+<?php
+
+function test() {
+ for (; $n--; )
+ C;
+}
+test();
+
+?>
+--EXPECTF--
+Notice: Undefined variable: n in %s on line %d
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 {