mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix DCE of unreachable phi in cycle
This commit is contained in:
commit
b7ec15f7fe
2 changed files with 23 additions and 2 deletions
|
@ -464,13 +464,19 @@ static inline int get_common_phi_source(zend_ssa *ssa, zend_ssa_phi *phi) {
|
|||
int common_source = -1;
|
||||
int source;
|
||||
FOREACH_PHI_SOURCE(phi, source) {
|
||||
if (source == phi->ssa_var) {
|
||||
continue;
|
||||
}
|
||||
if (common_source == -1) {
|
||||
common_source = source;
|
||||
} else if (common_source != source && source != phi->ssa_var) {
|
||||
} else if (common_source != source) {
|
||||
return -1;
|
||||
}
|
||||
} FOREACH_PHI_SOURCE_END();
|
||||
ZEND_ASSERT(common_source != -1);
|
||||
|
||||
/* If all sources are phi->ssa_var this phi must be in an unreachable cycle.
|
||||
* We can't easily drop the phi in that case, as we don't have something to replace it with.
|
||||
* Ideally SCCP would eliminate the whole cycle. */
|
||||
return common_source;
|
||||
}
|
||||
|
||||
|
|
15
Zend/tests/unreachable_phi_cycle.phpt
Normal file
15
Zend/tests/unreachable_phi_cycle.phpt
Normal file
|
@ -0,0 +1,15 @@
|
|||
--TEST--
|
||||
Unreachable phi cycle
|
||||
--FILE--
|
||||
<?php
|
||||
// The inner loop is dead, but SCCP reachability analysis doesn't realize this,
|
||||
// as this is determined based on type information.
|
||||
function test() {
|
||||
for (; $i--;) {
|
||||
for(; x;);
|
||||
}
|
||||
}
|
||||
test();
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Undefined variable $i in %s on line %d
|
Loading…
Add table
Add a link
Reference in a new issue