Skip to content

Commit 69e6a94

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix register allocation (missing store)
2 parents effba18 + 4164d2d commit 69e6a94

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

ext/opcache/jit/zend_jit_trace.c

+10
Original file line numberDiff line numberDiff line change
@@ -2699,6 +2699,7 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace
26992699
const zend_ssa *op_array_ssa;
27002700
const zend_ssa_op *ssa_op;
27012701
int i, j, idx, count, level;
2702+
int last_idx = -1;
27022703
int *start, *end;
27032704
uint8_t *flags;
27042705
const zend_op_array **vars_op_array;
@@ -3103,6 +3104,7 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace
31033104
}
31043105
}
31053106
} else {
3107+
last_idx = idx;
31063108
for (i = 0; i < op_array->last_var; i++) {
31073109
zend_jit_close_var(stack, i, start, end, flags, idx);
31083110
}
@@ -3412,6 +3414,14 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace
34123414
}
34133415
phi = phi->next;
34143416
}
3417+
} else {
3418+
for (i = 0; i < ssa->vars_count; i++) {
3419+
if (intervals[i]
3420+
&& intervals[i]->range.end == last_idx
3421+
&& !(intervals[i]->flags & (ZREG_LOAD|ZREG_STORE))) {
3422+
intervals[i]->flags |= ZREG_STORE;
3423+
}
3424+
}
34153425
}
34163426

34173427
if (!count) {
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Register Alloction 017: Missing store
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
function test() {
11+
for($i = 0; $i < 10; $i++) {
12+
$a = $b = $a + !$a = !$a;
13+
$c = $c = $a;
14+
$c % $a;
15+
}
16+
}
17+
@test();
18+
?>
19+
DONE
20+
--EXPECT--
21+
DONE

0 commit comments

Comments
 (0)