Skip to content

Commit 251a559

Browse files
committed
Fixed SSA reconstruction
1 parent d01453b commit 251a559

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
@@ -1213,14 +1213,14 @@ static inline zend_ssa_phi **zend_ssa_next_use_phi_ptr(zend_ssa *ssa, int var, z
12131213

12141214
/* May be called even if source is not used in the phi (useful when removing uses in a phi
12151215
* with multiple identical operands) */
1216-
static inline void zend_ssa_remove_use_of_phi_source(zend_ssa *ssa, zend_ssa_phi *phi, int source) /* {{{ */
1216+
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) /* {{{ */
12171217
{
12181218
zend_ssa_phi **cur = &ssa->vars[source].phi_use_chain;
12191219
while (*cur && *cur != phi) {
12201220
cur = zend_ssa_next_use_phi_ptr(ssa, source, *cur);
12211221
}
12221222
if (*cur) {
1223-
*cur = zend_ssa_next_use_phi(ssa, source, *cur);
1223+
*cur = next_use_phi;
12241224
}
12251225
}
12261226
/* }}} */
@@ -1229,7 +1229,7 @@ static void zend_ssa_remove_uses_of_phi_sources(zend_ssa *ssa, zend_ssa_phi *phi
12291229
{
12301230
int source;
12311231
FOREACH_PHI_SOURCE(phi, source) {
1232-
zend_ssa_remove_use_of_phi_source(ssa, phi, source);
1232+
zend_ssa_remove_use_of_phi_source(ssa, phi, source, zend_ssa_next_use_phi(ssa, source, phi));
12331233
} FOREACH_PHI_SOURCE_END();
12341234
}
12351235
/* }}} */
@@ -1289,7 +1289,7 @@ static inline void zend_ssa_remove_phi_source(zend_ssa *ssa, zend_ssa_phi *phi,
12891289
}
12901290

12911291
/* Variable only used in one operand, remove the phi from the use chain. */
1292-
zend_ssa_remove_use_of_phi_source(ssa, phi, var_num);
1292+
zend_ssa_remove_use_of_phi_source(ssa, phi, var_num, phi->use_chains[pred_offset]);
12931293
phi->use_chains[pred_offset] = NULL;
12941294
}
12951295
/* }}} */

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)