Skip to content

Commit

Permalink
Fixed assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Nov 2, 2023
1 parent 4489d17 commit 77312d8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 7 deletions.
15 changes: 8 additions & 7 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,13 +1301,14 @@ static void zend_jit_def_reg(zend_jit_ctx *jit, zend_jit_addr addr, ir_ref val)

if (jit->ra[dst_phi->ssa_var].ref > 0) {
ir_insn *phi_insn = &jit->ctx.ir_base[jit->ra[dst_phi->ssa_var].ref];
ZEND_ASSERT(phi_insn->op == IR_PHI);
// ZEND_ASSERT(ir_operands_count(ctx, phi_insn) == n + 1);
bb = &jit->ssa->cfg.blocks[dst_phi->block];
n = bb->predecessors_count;
for (j = 0, p = &dst_phi->sources[0], q = phi_insn->ops + 2; j < n; j++, p++, q++) {
if (*p == src_var) {
*q = val;
if (phi_insn->op == IR_PHI) {
// ZEND_ASSERT(ir_operands_count(ctx, phi_insn) == n + 1);
bb = &jit->ssa->cfg.blocks[dst_phi->block];
n = bb->predecessors_count;
for (j = 0, p = &dst_phi->sources[0], q = phi_insn->ops + 2; j < n; j++, p++, q++) {
if (*p == src_var) {
*q = val;
}
}
}
}
Expand Down
48 changes: 48 additions & 0 deletions ext/opcache/tests/jit/reg_alloc_023.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--TEST--
Register Alloction 023: PI to PHI forwarding
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--FILE--
<?php
class test {
public function foo(string $key, int $start, int $end, ?string $type = null): void
{
if (isset($this->a[$key])) {
foreach ($this->a[$key] as $i => $data) {
if ($data->from >= $start && $data->from <= $end) {
if ($type === null || $type === $data->type) {
unset($this->a[$key][$i]);
}
}
}
}
if (isset($this->type_map[$key])) {
foreach ($this->b[$key] as $map_start => $_) {
if ($map_start >= $start && $map_start <= $end) {
unset($this->b[$key][$map_start]);
}
}
}
if (isset($this->c[$key])) {
foreach ($this->c[$key] as $map_start => $_) {
if ($map_start >= $start && $map_start <= $end) {
unset($this->c[$key][$map_start]);
}
}
}
if (isset($this->d[$key])) {
foreach ($this->d[$key] as $map_start => $_) {
if ($map_start >= $start && $map_start <= $end) {
unset($this->d[$key][$map_start]);
}
}
}
}
}
?>
DONE
--EXPECT--
DONE

0 comments on commit 77312d8

Please sign in to comment.