1
0
mirror of https://github.com/php/php-src.git synced 2026-04-02 13:43:02 +02:00

Merge branch 'PHP-8.2'

* PHP-8.2:
  Fix SSA construction and type inference
This commit is contained in:
Dmitry Stogov
2022-09-19 15:46:08 +03:00
3 changed files with 39 additions and 7 deletions

View File

@@ -2305,7 +2305,13 @@ static zend_always_inline zend_result _zend_update_type_info(
* unreachable code. Propagate the empty result early, so that that the following
* code may assume that operands have at least one type. */
if (!(t1 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS))
|| !(t2 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS))) {
|| !(t2 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS))
|| ((opline->opcode == ZEND_ASSIGN_DIM_OP
|| opline->opcode == ZEND_ASSIGN_OBJ_OP
|| opline->opcode == ZEND_ASSIGN_STATIC_PROP_OP
|| opline->opcode == ZEND_ASSIGN_DIM
|| opline->opcode == ZEND_ASSIGN_OBJ)
&& !(OP1_DATA_INFO() & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS)) /*&& 0*/)) {
tmp = 0;
if (ssa_op->result_def >= 0 && !(ssa_var_info[ssa_op->result_def].type & MAY_BE_REF)) {
UPDATE_SSA_TYPE(tmp, ssa_op->result_def);
@@ -2316,6 +2322,15 @@ static zend_always_inline zend_result _zend_update_type_info(
if (ssa_op->op2_def >= 0 && !(ssa_var_info[ssa_op->op2_def].type & MAY_BE_REF)) {
UPDATE_SSA_TYPE(tmp, ssa_op->op2_def);
}
if (opline->opcode == ZEND_ASSIGN_OP
|| opline->opcode == ZEND_ASSIGN_DIM_OP
|| opline->opcode == ZEND_ASSIGN_OBJ_OP
|| opline->opcode == ZEND_ASSIGN_DIM
|| opline->opcode == ZEND_ASSIGN_OBJ) {
if ((ssa_op+1)->op1_def >= 0 && !(ssa_var_info[(ssa_op+1)->op1_def].type & MAY_BE_REF)) {
UPDATE_SSA_TYPE(tmp, (ssa_op+1)->op1_def);
}
}
return SUCCESS;
}

View File

@@ -588,12 +588,6 @@ add_op1_def:
break;
case ZEND_ASSIGN_DIM:
case ZEND_ASSIGN_OBJ:
if (opline->op1_type == IS_CV) {
ssa_ops[k].op1_def = ssa_vars_count;
var[EX_VAR_TO_NUM(opline->op1.var)] = ssa_vars_count;
ssa_vars_count++;
//NEW_SSA_VAR(opline->op1.var)
}
next = opline + 1;
if (next->op1_type & (IS_CV|IS_VAR|IS_TMP_VAR)) {
ssa_ops[k + 1].op1_use = var[EX_VAR_TO_NUM(next->op1.var)];
@@ -605,6 +599,12 @@ add_op1_def:
//NEW_SSA_VAR(next->op1.var)
}
}
if (opline->op1_type == IS_CV) {
ssa_ops[k].op1_def = ssa_vars_count;
var[EX_VAR_TO_NUM(opline->op1.var)] = ssa_vars_count;
ssa_vars_count++;
//NEW_SSA_VAR(opline->op1.var)
}
break;
case ZEND_ASSIGN_OBJ_REF:
if (opline->op1_type == IS_CV) {

View File

@@ -0,0 +1,17 @@
--TEST--
Type inference 020;
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
--FILE--
<?php
function y() {
for(;;) {
$y = $y[] += 3/6 - ~$y;
}
}
?>
DONE
--EXPECT--
DONE