Skip to content

Commit 77312d8

Browse files
committed
Fixed assertion
1 parent 4489d17 commit 77312d8

File tree

2 files changed

+56
-7
lines changed

2 files changed

+56
-7
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,13 +1301,14 @@ static void zend_jit_def_reg(zend_jit_ctx *jit, zend_jit_addr addr, ir_ref val)
13011301

13021302
if (jit->ra[dst_phi->ssa_var].ref > 0) {
13031303
ir_insn *phi_insn = &jit->ctx.ir_base[jit->ra[dst_phi->ssa_var].ref];
1304-
ZEND_ASSERT(phi_insn->op == IR_PHI);
1305-
// ZEND_ASSERT(ir_operands_count(ctx, phi_insn) == n + 1);
1306-
bb = &jit->ssa->cfg.blocks[dst_phi->block];
1307-
n = bb->predecessors_count;
1308-
for (j = 0, p = &dst_phi->sources[0], q = phi_insn->ops + 2; j < n; j++, p++, q++) {
1309-
if (*p == src_var) {
1310-
*q = val;
1304+
if (phi_insn->op == IR_PHI) {
1305+
// ZEND_ASSERT(ir_operands_count(ctx, phi_insn) == n + 1);
1306+
bb = &jit->ssa->cfg.blocks[dst_phi->block];
1307+
n = bb->predecessors_count;
1308+
for (j = 0, p = &dst_phi->sources[0], q = phi_insn->ops + 2; j < n; j++, p++, q++) {
1309+
if (*p == src_var) {
1310+
*q = val;
1311+
}
13111312
}
13121313
}
13131314
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
--TEST--
2+
Register Alloction 023: PI to PHI forwarding
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+
class test {
11+
public function foo(string $key, int $start, int $end, ?string $type = null): void
12+
{
13+
if (isset($this->a[$key])) {
14+
foreach ($this->a[$key] as $i => $data) {
15+
if ($data->from >= $start && $data->from <= $end) {
16+
if ($type === null || $type === $data->type) {
17+
unset($this->a[$key][$i]);
18+
}
19+
}
20+
}
21+
}
22+
if (isset($this->type_map[$key])) {
23+
foreach ($this->b[$key] as $map_start => $_) {
24+
if ($map_start >= $start && $map_start <= $end) {
25+
unset($this->b[$key][$map_start]);
26+
}
27+
}
28+
}
29+
if (isset($this->c[$key])) {
30+
foreach ($this->c[$key] as $map_start => $_) {
31+
if ($map_start >= $start && $map_start <= $end) {
32+
unset($this->c[$key][$map_start]);
33+
}
34+
}
35+
}
36+
if (isset($this->d[$key])) {
37+
foreach ($this->d[$key] as $map_start => $_) {
38+
if ($map_start >= $start && $map_start <= $end) {
39+
unset($this->d[$key][$map_start]);
40+
}
41+
}
42+
}
43+
}
44+
}
45+
?>
46+
DONE
47+
--EXPECT--
48+
DONE

0 commit comments

Comments
 (0)