Skip to content

Commit 006b5f9

Browse files
committed
JIT: Fix TSSA of ZEND_FE_FETCH_R with key operand
1 parent 43b56c9 commit 006b5f9

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

ext/opcache/jit/zend_jit_trace.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,6 +2359,9 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
23592359
if (ssa_ops[idx].op2_use >= 0 && ssa_ops[idx].op2_def >= 0) {
23602360
ssa_var_info[ssa_ops[idx].op2_def] = ssa_var_info[ssa_ops[idx].op2_use];
23612361
}
2362+
if (ssa_ops[idx].result_use >= 0 && ssa_ops[idx].result_def >= 0) {
2363+
ssa_var_info[ssa_ops[idx].result_def] = ssa_var_info[ssa_ops[idx].result_use];
2364+
}
23622365
} else {
23632366
if (zend_update_type_info(op_array, tssa, script, (zend_op*)opline, ssa_ops + idx, ssa_opcodes, optimization_level) == FAILURE) {
23642367
// TODO:

ext/opcache/tests/jit/gh22004.phpt

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
--TEST--
2+
GH-22004: ZEND_FE_FETCH_R with key operand
3+
--CREDITS--
4+
YuanchengJiang
5+
--FILE--
6+
<?php
7+
8+
function doRandom($iter) {
9+
for ($i = 0; $i < $iter; $i++) {
10+
$lines = [];
11+
for ($j = 0; $j < $nLines; $j++) {
12+
$lines[] = $line;
13+
}
14+
foreach ($lines as $i => $line) {
15+
}
16+
}
17+
}
18+
$iter = 20;
19+
doRandom($iter);
20+
21+
?>
22+
==DONE==
23+
--EXPECTF--
24+
Warning: Undefined variable $nLines in %s on line %d
25+
26+
Warning: Undefined variable $nLines in %s on line %d
27+
28+
Warning: Undefined variable $nLines in %s on line %d
29+
30+
Warning: Undefined variable $nLines in %s on line %d
31+
32+
Warning: Undefined variable $nLines in %s on line %d
33+
34+
Warning: Undefined variable $nLines in %s on line %d
35+
36+
Warning: Undefined variable $nLines in %s on line %d
37+
38+
Warning: Undefined variable $nLines in %s on line %d
39+
40+
Warning: Undefined variable $nLines in %s on line %d
41+
42+
Warning: Undefined variable $nLines in %s on line %d
43+
44+
Warning: Undefined variable $nLines in %s on line %d
45+
46+
Warning: Undefined variable $nLines in %s on line %d
47+
48+
Warning: Undefined variable $nLines in %s on line %d
49+
50+
Warning: Undefined variable $nLines in %s on line %d
51+
52+
Warning: Undefined variable $nLines in %s on line %d
53+
54+
Warning: Undefined variable $nLines in %s on line %d
55+
56+
Warning: Undefined variable $nLines in %s on line %d
57+
58+
Warning: Undefined variable $nLines in %s on line %d
59+
60+
Warning: Undefined variable $nLines in %s on line %d
61+
62+
Warning: Undefined variable $nLines in %s on line %d
63+
==DONE==

0 commit comments

Comments
 (0)