From 69ec51eb0221c76802a5a23e1c86cad1483faed2 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 21 Jul 2017 23:13:44 +0200 Subject: [PATCH] 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. --- ext/opcache/Optimizer/zend_dfg.c | 6 +++--- ext/opcache/tests/verify_return_dfg.phpt | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 ext/opcache/tests/verify_return_dfg.phpt 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-- + +===DONE=== +--EXPECT-- +===DONE=== -- 2.50.1