Skip to content

Commit 313371a

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: JIT: Fix register allocation
2 parents 9406198 + cd4e886 commit 313371a

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3343,7 +3343,9 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace
33433343
intervals[use]->used_as_hint = NULL;
33443344
intervals[use]->list_next = NULL;
33453345
}
3346-
} else if (intervals[use] && !ssa->vars[phi->ssa_var].no_val) {
3346+
} else if (intervals[use]
3347+
&& (!ssa->vars[def].no_val
3348+
|| ssa->var_info[def].type != ssa->var_info[use].type)) {
33473349
if (ssa->vars[use].use_chain >= 0) {
33483350
intervals[use]->flags |= ZREG_STORE;
33493351
} else {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
Register Alloction 006: Incorrect type store elimination
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 foo() {
11+
$a = 0;
12+
for($i=0; $i < 6; $i++) {
13+
$y - $b = $a ? $b : $y;
14+
$a = $b = 7;
15+
}
16+
}
17+
foo()
18+
?>
19+
DONE
20+
--EXPECTF--
21+
Warning: Undefined variable $y in %sreg_alloc_006.php on line 5
22+
23+
Warning: Undefined variable $y in %sreg_alloc_006.php on line 5
24+
25+
Warning: Undefined variable $y in %sreg_alloc_006.php on line 5
26+
27+
Warning: Undefined variable $y in %sreg_alloc_006.php on line 5
28+
29+
Warning: Undefined variable $y in %sreg_alloc_006.php on line 5
30+
31+
Warning: Undefined variable $y in %sreg_alloc_006.php on line 5
32+
33+
Warning: Undefined variable $y in %sreg_alloc_006.php on line 5
34+
DONE

0 commit comments

Comments
 (0)