summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-10-19 15:13:40 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-10-19 15:13:53 +0200
commitd3812ca41b8ff40cc2d38fb4d2a79ae1902761cb (patch)
tree7976852eb078f6143c974f844a348425df4cba72
parentc97da0f819730c00905f9618aba0c54e8d592f74 (diff)
downloadphp-git-d3812ca41b8ff40cc2d38fb4d2a79ae1902761cb.tar.gz
Fixed bug #80255
This was a copy&paste mistake, target_block was used where follow_block was intended. Also update copy&paste mistakes in the comments.
-rw-r--r--NEWS3
-rw-r--r--Zend/tests/bug80255.phpt24
-rw-r--r--ext/opcache/Optimizer/block_pass.c8
3 files changed, 31 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 736ae5e0a3..54948f1134 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,9 @@ PHP NEWS
- IMAP:
. Fixed bug #80239 (imap_rfc822_write_address() leaks memory). (cmb)
+- Opcache:
+ . Fixed bug #80255 (Opcache bug (bad condition result) in 8.0.0rc1). (Nikita)
+
15 Oct 2020, PHP 8.0.0RC2
- Core:
diff --git a/Zend/tests/bug80255.phpt b/Zend/tests/bug80255.phpt
new file mode 100644
index 0000000000..d3fc6b7abe
--- /dev/null
+++ b/Zend/tests/bug80255.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #80255: Opcache bug (bad condition result) in 8.0.0rc1
+--FILE--
+<?php
+
+function test($a, $b, $c) {
+ do {
+ if ($a && !$b) {
+ break;
+ } else if ($b) {
+ echo "foo\n";
+ }
+ echo "bar\n";
+ } while ($c);
+ echo "baz\n";
+}
+
+test(true, true, false);
+
+?>
+--EXPECT--
+foo
+bar
+baz
diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c
index 5b6870ed0a..bad814ed6e 100644
--- a/ext/opcache/Optimizer/block_pass.c
+++ b/ext/opcache/Optimizer/block_pass.c
@@ -1516,16 +1516,16 @@ optimize_jmpznz:
target = op_array->opcodes + follow_block->start;
if (target->opcode == ZEND_JMP) {
- /* JMPZNZ(X, L1, L2), L1: JMP(L3) -> JMPZNZ(X, L3, L2) */
+ /* JMPZNZ(X, L1, L2), L2: JMP(L3) -> JMPZNZ(X, L1, L3) */
next = follow_block->successors[0];
} else if (target->opcode == ZEND_JMPNZ &&
SAME_VAR(target->op1, last_op->op1)) {
- /* JMPZNZ(X, L1, L2), L1: X = JMPNZ(X, L3) -> JMPZNZ(X, L1+1, L2) */
+ /* JMPZNZ(X, L1, L2), L2: X = JMPNZ(X, L3) -> JMPZNZ(X, L1, L3) */
next = follow_block->successors[0];
} else if ((target->opcode == ZEND_JMPZ || target->opcode == ZEND_JMPZNZ) &&
SAME_VAR(target->op1, last_op->op1)) {
- /* JMPZNZ(X, L1, L2), L1: JMPZ(X, L3) -> JMPZNZ(X, L3, L2) */
- next = target_block->successors[1];
+ /* JMPZNZ(X, L1, L2), L2: JMPZ(X, L3) -> JMPZNZ(X, L1, L2+1) */
+ next = follow_block->successors[1];
} else {
break;
}