Skip to content

Commit

Permalink
Fixed SSA reconstruction
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Sep 7, 2017
1 parent d01453b commit 251a559
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ext/opcache/Optimizer/zend_ssa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,14 +1213,14 @@ static inline zend_ssa_phi **zend_ssa_next_use_phi_ptr(zend_ssa *ssa, int var, z

/* May be called even if source is not used in the phi (useful when removing uses in a phi
* with multiple identical operands) */
static inline void zend_ssa_remove_use_of_phi_source(zend_ssa *ssa, zend_ssa_phi *phi, int source) /* {{{ */
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) /* {{{ */
{
zend_ssa_phi **cur = &ssa->vars[source].phi_use_chain;
while (*cur && *cur != phi) {
cur = zend_ssa_next_use_phi_ptr(ssa, source, *cur);
}
if (*cur) {
*cur = zend_ssa_next_use_phi(ssa, source, *cur);
*cur = next_use_phi;
}
}
/* }}} */
Expand All @@ -1229,7 +1229,7 @@ static void zend_ssa_remove_uses_of_phi_sources(zend_ssa *ssa, zend_ssa_phi *phi
{
int source;
FOREACH_PHI_SOURCE(phi, source) {
zend_ssa_remove_use_of_phi_source(ssa, phi, source);
zend_ssa_remove_use_of_phi_source(ssa, phi, source, zend_ssa_next_use_phi(ssa, source, phi));
} FOREACH_PHI_SOURCE_END();
}
/* }}} */
Expand Down Expand Up @@ -1289,7 +1289,7 @@ static inline void zend_ssa_remove_phi_source(zend_ssa *ssa, zend_ssa_phi *phi,
}

/* Variable only used in one operand, remove the phi from the use chain. */
zend_ssa_remove_use_of_phi_source(ssa, phi, var_num);
zend_ssa_remove_use_of_phi_source(ssa, phi, var_num, phi->use_chains[pred_offset]);
phi->use_chains[pred_offset] = NULL;
}
/* }}} */
Expand Down
10 changes: 10 additions & 0 deletions ext/opcache/tests/ssa_bug_008.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--TEST--
Incorrect CFG/SSA reconstruction
--FILE--
<?php
if (!is_int($info = gc_collect_cycles()) || ($info < 100)) {
echo gettype($info)."\n";
}
--EXPECT--
integer

0 comments on commit 251a559

Please sign in to comment.