com php-src: Fix incorrect propagation of ZEND_BOOL in pa ss 1: ext/opcache/Optimizer/pass1_5.c ext/opc ache/tests/bool_cp_in_pass1.phpt
| From: | Nikita Popov | Date: | Sat, 22 Jul 2017 15:23:50 +0000 |
| Subject: | com php-src: Fix incorrect propagation of ZEND_BOOL in pa ss 1: ext/opcache/Optimizer/pass1_5.c ext/opc ache/tests/bool_cp_in_pass1.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98717@lists.php.net to get a copy of this message | ||
Commit: 4672411ef5f600b6e64e92098b98708351a65535
Author: Nikita Popov <nikita.ppv@gmail.com> Sat, 22 Jul 2017 17:21:48 +0200
Parents: 96665fbfe0d520035f672dc7919b541b288806ca
Branches: PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4672411ef5f600b6e64e92098b98708351a65535
Log:
Fix incorrect propagation of ZEND_BOOL in pass 1
BOOL (next to QM_ASSIGN) is one of the opcodes that can assign to
a temporary that is assigned in multiple branches. Pass 1 does
not check for this, so we should not try to handle it at that
point. Block pass and sccp will be able to treat this correctly.
Changed paths:
M ext/opcache/Optimizer/pass1_5.c
A ext/opcache/tests/bool_cp_in_pass1.phpt
Diff:
diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c
index 5374a18..7697fb1 100644
--- a/ext/opcache/Optimizer/pass1_5.c
+++ b/ext/opcache/Optimizer/pass1_5.c
@@ -115,7 +115,6 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
case ZEND_BW_NOT:
case ZEND_BOOL_NOT:
- case ZEND_BOOL:
if (opline->op1_type == IS_CONST) {
/* unary operation on constant operand */
zval result;
diff --git a/ext/opcache/tests/bool_cp_in_pass1.phpt b/ext/opcache/tests/bool_cp_in_pass1.phpt
new file mode 100644
index 0000000..3857c4d
--- /dev/null
+++ b/ext/opcache/tests/bool_cp_in_pass1..phpt
@@ -0,0 +1,15 @@
+--TEST--
+Incorrect constant propagation on BOOL in pass 1
+--FILE--
+<?php
+function test($foo) {
+ $bar = 0;
+ if ($bar === 1 && $foo && PHP_SAPI !== 'cgi') {
+ echo "bar\n";
+ }
+ echo "foo\n";
+}
+test(1);
+?>
+--EXPECT--
+foo