Repository navigation
Commit cdf1a4f
committed
Fix zend_optimizer_replace_by_const() leaving stale OP2 uses behind
For opcodes that do not consume their OP1 operand, the constant is propagated
into every use of the temporary rather than just the first one. That loop only
ever looked at OP1, so a use of the same temporary as an OP2 operand was left
referring to a temporary that no longer has a definition:
function test($v) {
switch ($v) {
case [$x] = (int)1.5:
break;
}
}
The ZEND_CAST is folded and rewritten into the ZEND_FETCH_LIST_R of the list
assignment, but the comparison emitted for the case expression uses the same
temporary as its OP2 and keeps the dangling reference, which makes SSA
construction fail its integrity check.
An OP2 operand is always consumed (ZEND_FE_FETCH_R/RW, where OP2 is a def
rather than a use, is the sole exception), so such a use is the last one and
the loop can stop there.
Assisted-By: Claude <noreply@anthropic.com>1 parent 8723e66 commit cdf1a4f
2 files changed
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
669 | 680 | | |
670 | 681 | | |
671 | 682 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
0 commit comments