mirror of
https://github.com/php/php-src.git
synced 2026-04-05 07:02:33 +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:
@@ -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
|
||||
Reference in New Issue
Block a user