Skip to content

Commit ec60fee

Browse files
committed
Merge branch 'PHP-7.2'
* PHP-7.2: Fixed SSA reconstruction
2 parents 9ecafd9 + 251a559 commit ec60fee

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

ext/opcache/Optimizer/zend_ssa.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,14 +1224,14 @@ static inline zend_ssa_phi **zend_ssa_next_use_phi_ptr(zend_ssa *ssa, int var, z
12241224

12251225
/* May be called even if source is not used in the phi (useful when removing uses in a phi
12261226
* with multiple identical operands) */
1227-
static inline void zend_ssa_remove_use_of_phi_source(zend_ssa *ssa, zend_ssa_phi *phi, int source) /* {{{ */
1227+
static inline void zend_ssa_remove_use_of_phi_source(zend_ssa *ssa, zend_ssa_phi *phi, int source, zend_ssa_phi *next_use_phi) /* {{{ */
12281228
{
12291229
zend_ssa_phi **cur = &ssa->vars[source].phi_use_chain;
12301230
while (*cur && *cur != phi) {
12311231
cur = zend_ssa_next_use_phi_ptr(ssa, source, *cur);
12321232
}
12331233
if (*cur) {
1234-
*cur = zend_ssa_next_use_phi(ssa, source, *cur);
1234+
*cur = next_use_phi;
12351235
}
12361236
}
12371237
/* }}} */
@@ -1240,7 +1240,7 @@ static void zend_ssa_remove_uses_of_phi_sources(zend_ssa *ssa, zend_ssa_phi *phi
12401240
{
12411241
int source;
12421242
FOREACH_PHI_SOURCE(phi, source) {
1243-
zend_ssa_remove_use_of_phi_source(ssa, phi, source);
1243+
zend_ssa_remove_use_of_phi_source(ssa, phi, source, zend_ssa_next_use_phi(ssa, source, phi));
12441244
} FOREACH_PHI_SOURCE_END();
12451245
}
12461246
/* }}} */
@@ -1300,7 +1300,7 @@ static inline void zend_ssa_remove_phi_source(zend_ssa *ssa, zend_ssa_phi *phi,
13001300
}
13011301

13021302
/* Variable only used in one operand, remove the phi from the use chain. */
1303-
zend_ssa_remove_use_of_phi_source(ssa, phi, var_num);
1303+
zend_ssa_remove_use_of_phi_source(ssa, phi, var_num, phi->use_chains[pred_offset]);
13041304
phi->use_chains[pred_offset] = NULL;
13051305
}
13061306
/* }}} */

ext/opcache/tests/ssa_bug_008.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Incorrect CFG/SSA reconstruction
3+
--FILE--
4+
<?php
5+
if (!is_int($info = gc_collect_cycles()) || ($info < 100)) {
6+
echo gettype($info)."\n";
7+
}
8+
--EXPECT--
9+
integer
10+

0 commit comments

Comments
 (0)