Skip to content

Commit 5877b84

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix register allocation (missing store)
2 parents da28a6b + ed652a5 commit 5877b84

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,6 +2688,7 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace
26882688
const zend_ssa *op_array_ssa;
26892689
const zend_ssa_op *ssa_op;
26902690
int i, j, idx, count, level;
2691+
int last_idx = -1;
26912692
int *start, *end;
26922693
uint8_t *flags;
26932694
const zend_op_array **vars_op_array;
@@ -3092,6 +3093,7 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace
30923093
}
30933094
}
30943095
} else {
3096+
last_idx = idx;
30953097
for (i = 0; i < op_array->last_var; i++) {
30963098
zend_jit_close_var(stack, i, start, end, flags, idx);
30973099
}
@@ -3401,6 +3403,14 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace
34013403
}
34023404
phi = phi->next;
34033405
}
3406+
} else {
3407+
for (i = 0; i < ssa->vars_count; i++) {
3408+
if (intervals[i]
3409+
&& intervals[i]->range.end == last_idx
3410+
&& !(intervals[i]->flags & (ZREG_LOAD|ZREG_STORE))) {
3411+
intervals[i]->flags |= ZREG_STORE;
3412+
}
3413+
}
34043414
}
34053415

34063416
if (!count) {
Lines changed: 21 additions & 0 deletions
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)