Skip to content

Commit c124d20

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix DCE with FE_FETCH
2 parents 9563449 + 7e028a4 commit c124d20

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

ext/opcache/Optimizer/zend_ssa.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,15 @@ static zend_always_inline zend_bool zend_ssa_is_no_val_use(const zend_op *opline
215215
if (opline->opcode == ZEND_ASSIGN || opline->opcode == ZEND_UNSET_CV) {
216216
return ssa_op->op1_use == var && ssa_op->op2_use != var;
217217
}
218-
if (opline->opcode == ZEND_FE_FETCH_R) {
218+
// TODO: Reenable this after changing the SSA structure.
219+
/*if (opline->opcode == ZEND_FE_FETCH_R) {
219220
return ssa_op->op2_use == var && ssa_op->op1_use != var;
220-
}
221+
}*/
221222
if (ssa_op->result_use == var
222223
&& opline->opcode != ZEND_ADD_ARRAY_ELEMENT
223224
&& opline->opcode != ZEND_ADD_ARRAY_UNPACK) {
225+
}
226+
if (ssa_op->result_use == var && opline->opcode != ZEND_ADD_ARRAY_ELEMENT) {
224227
return ssa_op->op1_use != var && ssa_op->op2_use != var;
225228
}
226229
return 0;

ext/opcache/tests/fe_fetch_dce.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Incorrect DCE with FE_FETCH
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--FILE--
8+
<?php
9+
10+
function test() {
11+
$a = ["3"];
12+
$x = 1;
13+
foreach ($a as $x) {
14+
$x = 2.0;
15+
}
16+
var_dump($x);
17+
}
18+
test();
19+
20+
?>
21+
--EXPECT--
22+
float(2)

0 commit comments

Comments
 (0)