summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/opcache/Optimizer/zend_dfg.c6
-rw-r--r--ext/opcache/tests/verify_return_dfg.phpt16
2 files changed, 19 insertions, 3 deletions
diff --git a/ext/opcache/Optimizer/zend_dfg.c b/ext/opcache/Optimizer/zend_dfg.c
index 374c8146c8..f39c6368cd 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 0000000000..f2e66511ed
--- /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===