Skip to content

Commit 87691e7

Browse files
committed
Fix DCE with FE_FETCH
For now, don't treat FE_FETCH op2 as no-val use. See GH-4982.
1 parent 17a9f14 commit 87691e7

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

ext/opcache/Optimizer/zend_ssa.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,10 @@ static zend_always_inline zend_bool zend_ssa_is_no_val_use(const zend_op *opline
217217
if (opline->opcode == ZEND_ASSIGN || opline->opcode == ZEND_UNSET_CV) {
218218
return ssa_op->op1_use == var && ssa_op->op2_use != var;
219219
}
220-
if (opline->opcode == ZEND_FE_FETCH_R) {
220+
// TODO: Reenable this after changing the SSA structure.
221+
/*if (opline->opcode == ZEND_FE_FETCH_R) {
221222
return ssa_op->op2_use == var && ssa_op->op1_use != var;
222-
}
223+
}*/
223224
if (ssa_op->result_use == var && opline->opcode != ZEND_ADD_ARRAY_ELEMENT) {
224225
return ssa_op->op1_use != var && ssa_op->op2_use != var;
225226
}

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)