Skip to content

Commit 3761293

Browse files
committed
Fix pi node removal when removing predecessor
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.
1 parent 9560e3b commit 3761293

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Regression test for incorrect update of pi node users when removing a predecessor block
3+
--FILE--
4+
<?php
5+
6+
function test() {
7+
for (; $n--; )
8+
C;
9+
}
10+
test();
11+
12+
?>
13+
--EXPECTF--
14+
Notice: Undefined variable: n in %s on line %d

ext/opcache/Optimizer/zend_ssa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ void zend_ssa_remove_predecessor(zend_ssa *ssa, int from, int to) /* {{{ */
13881388
for (phi = next_ssa_block->phis; phi; phi = phi->next) {
13891389
if (phi->pi >= 0) {
13901390
if (phi->pi == from) {
1391-
zend_ssa_remove_uses_of_var(ssa, phi->ssa_var);
1391+
zend_ssa_rename_var_uses(ssa, phi->ssa_var, phi->sources[0], /* update_types */ 0);
13921392
zend_ssa_remove_phi(ssa, phi);
13931393
}
13941394
} else {

0 commit comments

Comments
 (0)