Skip to content

Commit f7abb1e

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
2 parents e0e5d26 + da7add3 commit f7abb1e

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

ext/opcache/Optimizer/zend_ssa.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ static zend_bool needs_pi(const zend_op_array *op_array, zend_dfg *dfg, zend_ssa
5454
return 0;
5555
}
5656

57+
/* Make sure that both sucessors of the from block aren't the same. Pi nodes are associated
58+
* with predecessor blocks, so we can't distinguish which edge the pi belongs to. */
59+
from_block = &ssa->cfg.blocks[from];
60+
ZEND_ASSERT(from_block->successors_count == 2);
61+
if (from_block->successors[0] == from_block->successors[1]) {
62+
return 0;
63+
}
64+
5765
to_block = &ssa->cfg.blocks[to];
5866
if (to_block->predecessors_count == 1) {
5967
/* Always place pi if one predecessor (an if branch) */
@@ -62,8 +70,6 @@ static zend_bool needs_pi(const zend_op_array *op_array, zend_dfg *dfg, zend_ssa
6270

6371
/* Check that the other successor of the from block does not dominate all other predecessors.
6472
* If it does, we'd probably end up annihilating a positive+negative pi assertion. */
65-
from_block = &ssa->cfg.blocks[from];
66-
ZEND_ASSERT(from_block->successors_count == 2);
6773
other_successor = from_block->successors[0] == to
6874
? from_block->successors[1] : from_block->successors[0];
6975
return !dominates_other_predecessors(&ssa->cfg, to_block, other_successor, from);

ext/opcache/tests/bug77743.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
Bug #77743: Incorrect pi node insertion for jmpznz with identical successors
3+
--FILE--
4+
<?php
5+
class Toto
6+
{
7+
public function process1()
8+
{
9+
$keep_products = [1, 2, 3, 4];
10+
foreach ($keep_products as $k => $v)
11+
{
12+
$id_country = myRet(45);
13+
if ($id_country === false && false)
14+
{
15+
}
16+
17+
var_dump($id_country === false);
18+
}
19+
}
20+
}
21+
22+
function myRet($x){
23+
return $x;
24+
}
25+
26+
$toto = new Toto();
27+
$toto->process1();
28+
29+
?>
30+
--EXPECT--
31+
bool(false)
32+
bool(false)
33+
bool(false)
34+
bool(false)

0 commit comments

Comments
 (0)