From: Dmitry Stogov Date: Thu, 10 Oct 2019 08:48:31 +0000 (+0300) Subject: Fixed edge cases introduced by 170ed1f5a7b2f2f052445761080c96a3a3cfa884 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0cb977a69129056b4ee71f67dd1a63fdc883de67;p=php Fixed edge cases introduced by 170ed1f5a7b2f2f052445761080c96a3a3cfa884 --- diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c index 46ec6c0769..983d5cf1a9 100644 --- a/ext/opcache/Optimizer/block_pass.c +++ b/ext/opcache/Optimizer/block_pass.c @@ -892,7 +892,12 @@ optimize_const_unary_op: !zend_bitset_in(used_ext, VAR_NUM(opline->op1.var))) { /* T1 = ..., T2 = QM_ASSIGN(T1) to T2 = ..., NOP */ src = VAR_SOURCE(opline->op1); - if (src) { + if (src && + src->opcode != ZEND_COPY_TMP && + src->opcode != ZEND_ADD_ARRAY_ELEMENT && + src->opcode != ZEND_ADD_ARRAY_UNPACK && + (src->opcode != ZEND_DECLARE_LAMBDA_FUNCTION || + src == opline -1)) { src->result.var = opline->result.var; VAR_SOURCE(opline->op1) = NULL; VAR_SOURCE(opline->result) = src; diff --git a/ext/opcache/tests/opt/block_pass_001.phpt b/ext/opcache/tests/opt/block_pass_001.phpt new file mode 100644 index 0000000000..788994ea4e --- /dev/null +++ b/ext/opcache/tests/opt/block_pass_001.phpt @@ -0,0 +1,24 @@ +--TEST-- +Block Pass 001: QM_ASSIGN and DECLARE_LAMBDA_FUNCTION +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +--SKIPIF-- + +--FILE-- +make($callback) + ->join(...$args); + }; + } +} +?> +OK +--EXPECT-- +OK diff --git a/ext/opcache/tests/opt/block_pass_002.phpt b/ext/opcache/tests/opt/block_pass_002.phpt new file mode 100644 index 0000000000..ef7bf479c5 --- /dev/null +++ b/ext/opcache/tests/opt/block_pass_002.phpt @@ -0,0 +1,19 @@ +--TEST-- +Block Pass 002: QM_ASSIGN and INIT_ARRAY +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +--SKIPIF-- + +--FILE-- + +OK +--EXPECT-- +OK