com php-src: Fix DFG construction for VERIFY_RETURN: ext/ opcache/Optimizer/zend_dfg.c ext/opcache/tests/verify_r eturn_dfg.phpt
| From: | Nikita Popov | Date: | Fri, 21 Jul 2017 21:20:56 +0000 |
| Subject: | com php-src: Fix DFG construction for VERIFY_RETURN: ext/ opcache/Optimizer/zend_dfg.c ext/opcache/tests/verify_r eturn_dfg.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98705@lists.php.net to get a copy of this message | ||
Commit: 69ec51eb0221c76802a5a23e1c86cad1483faed2
Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 21 Jul 2017 23:13:44 +0200
Parents: a8f98fc7f7c795eb6585e71160655a3cc06a9300
Branches: PHP-7.1 PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=69ec51eb0221c76802a5a23e1c86cad1483faed2
Log:
Fix DFG construction for VERIFY_RETURN
use only contains uses prior to definition. This was not
honoured for VERIFY_RETURN with a temporary operand.
The test case only breaks on PHP 7.2.
Changed paths:
M ext/opcache/Optimizer/zend_dfg.c
A ext/opcache/tests/verify_return_dfg.phpt
Diff:
diff --git a/ext/opcache/Optimizer/zend_dfg.c b/ext/opcache/Optimizer/zend_dfg.c
index 374c814..f39c636 100644
--- a/ext/opcache/Optimizer/zend_dfg.c
+++ b/ext/opcache/Optimizer/zend_dfg.c
@@ -144,11 +144,11 @@ op1_use:
}
} else if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) {
var_num = EX_VAR_TO_NUM(opline->op1.var);
- if (opline->opcode == ZEND_VERIFY_RETURN_TYPE) {
+ if (!DFG_ISSET(def, set_size, j, var_num)) {
DFG_SET(use, set_size, j, var_num);
+ }
+ if (opline->opcode == ZEND_VERIFY_RETURN_TYPE) {
DFG_SET(def, set_size, j, var_num);
- } else if (!DFG_ISSET(def, set_size, j, var_num)) {
- DFG_SET(use, set_size, j, var_num);
}
}
if (opline->op2_type == IS_CV) {
diff --git a/ext/opcache/tests/verify_return_dfg.phpt b/ext/opcache/tests/verify_return_dfg.phpt
new file mode 100644
index 0000000..f2e6651
--- /dev/null
+++ b/ext/opcache/tests/verify_return_dfg.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Incorrect liveness computation for verify-return
+--FILE--
+<?php
+function test($foo): string
+{
+ switch ($foo) {
+ default: $bar = 'x'; break;
+ case 'z': $bar = 'y'; break;
+ }
+ return (string)$bar;
+}
+?>
+===DONE===
+--EXPECT--
+===DONE===