Skip to content

Commit 029b735

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
2 parents b06f05b + 61a38bb commit 029b735

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

ext/opcache/Optimizer/sccp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,6 +2331,14 @@ static int try_remove_definition(sccp_ctx *ctx, int var_num, zend_ssa_var *var,
23312331
zend_ssa_remove_result_def(ssa, ssa_op);
23322332
if (opline->opcode == ZEND_DO_ICALL) {
23332333
removed_ops = remove_call(ctx, opline, ssa_op);
2334+
} else if (opline->opcode == ZEND_TYPE_CHECK
2335+
&& !value_known(&ctx->values[ssa_op->op1_use])) {
2336+
/* For TYPE_CHECK we may compute the result value without knowing the
2337+
* operand, based on type inference information. Make sure the operand is
2338+
* freed and leave further cleanup to DCE. */
2339+
opline->opcode = ZEND_FREE;
2340+
opline->result_type = IS_UNUSED;
2341+
removed_ops++;
23342342
} else {
23352343
zend_ssa_remove_instr(ssa, opline, ssa_op);
23362344
removed_ops++;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
SCCP 030: TYPE_CHECK inferred from type inference info
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
opcache.opt_debug_level=0
8+
--SKIPIF--
9+
<?php require_once('skipif.inc'); ?>
10+
--FILE--
11+
<?php
12+
13+
var_dump(is_string(sys_get_temp_dir()));
14+
15+
?>
16+
--EXPECT--
17+
bool(true)

0 commit comments

Comments
 (0)