summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-03-18 10:50:39 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-03-18 10:51:00 +0100
commitda7add3525d78181f15dcabc4025d5a972e23b57 (patch)
tree9254a9d80a0ed5ee3fb610151f5a228c0f96319a
parentad2d2e41de3a8ac243a73ec447f4107f0ba56aac (diff)
parent54bf8c820f4ac2c9204cd09b66fbe99c3db5939b (diff)
downloadphp-git-da7add3525d78181f15dcabc4025d5a972e23b57.tar.gz
Merge branch 'PHP-7.2' into PHP-7.3
-rw-r--r--NEWS4
-rw-r--r--ext/opcache/Optimizer/zend_ssa.c10
-rw-r--r--ext/opcache/tests/bug77743.phpt34
3 files changed, 46 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 18dbcf3f34..f6f51119dc 100644
--- a/NEWS
+++ b/NEWS
@@ -34,6 +34,10 @@ PHP NEWS
- MySQLi:
. Fixed bug #77597 (mysqli_fetch_field hangs scripts). (Nikita)
+- Opcache:
+ . Fixed bug #77743 (Incorrect pi node insertion for jmpznz with identical
+ successors). (Nikita)
+
- Phar:
. Fxied bug #77697 (Crash on Big_Endian platform). (Laruence)
diff --git a/ext/opcache/Optimizer/zend_ssa.c b/ext/opcache/Optimizer/zend_ssa.c
index ea387bb95f..ce85f1483a 100644
--- a/ext/opcache/Optimizer/zend_ssa.c
+++ b/ext/opcache/Optimizer/zend_ssa.c
@@ -54,6 +54,14 @@ static zend_bool needs_pi(const zend_op_array *op_array, zend_dfg *dfg, zend_ssa
return 0;
}
+ /* Make sure that both sucessors of the from block aren't the same. Pi nodes are associated
+ * with predecessor blocks, so we can't distinguish which edge the pi belongs to. */
+ from_block = &ssa->cfg.blocks[from];
+ ZEND_ASSERT(from_block->successors_count == 2);
+ if (from_block->successors[0] == from_block->successors[1]) {
+ return 0;
+ }
+
to_block = &ssa->cfg.blocks[to];
if (to_block->predecessors_count == 1) {
/* 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
/* Check that the other successor of the from block does not dominate all other predecessors.
* If it does, we'd probably end up annihilating a positive+negative pi assertion. */
- from_block = &ssa->cfg.blocks[from];
- ZEND_ASSERT(from_block->successors_count == 2);
other_successor = from_block->successors[0] == to
? from_block->successors[1] : from_block->successors[0];
return !dominates_other_predecessors(&ssa->cfg, to_block, other_successor, from);
diff --git a/ext/opcache/tests/bug77743.phpt b/ext/opcache/tests/bug77743.phpt
new file mode 100644
index 0000000000..61627b198d
--- /dev/null
+++ b/ext/opcache/tests/bug77743.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Bug #77743: Incorrect pi node insertion for jmpznz with identical successors
+--FILE--
+<?php
+class Toto
+{
+ public function process1()
+ {
+ $keep_products = [1, 2, 3, 4];
+ foreach ($keep_products as $k => $v)
+ {
+ $id_country = myRet(45);
+ if ($id_country === false && false)
+ {
+ }
+
+ var_dump($id_country === false);
+ }
+ }
+}
+
+function myRet($x){
+ return $x;
+}
+
+$toto = new Toto();
+$toto->process1();
+
+?>
+--EXPECT--
+bool(false)
+bool(false)
+bool(false)
+bool(false)