From 77312d8ea1a8ace127a2bfa50a0f9b93a603ab02 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 3 Nov 2023 02:16:08 +0300 Subject: [PATCH] Fixed assertion --- ext/opcache/jit/zend_jit_ir.c | 15 ++++---- ext/opcache/tests/jit/reg_alloc_023.phpt | 48 ++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 ext/opcache/tests/jit/reg_alloc_023.phpt diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 79cdd340c47a1..bea6c5f6651fe 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -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; + } } } } diff --git a/ext/opcache/tests/jit/reg_alloc_023.phpt b/ext/opcache/tests/jit/reg_alloc_023.phpt new file mode 100644 index 0000000000000..cdc935a0df3a9 --- /dev/null +++ b/ext/opcache/tests/jit/reg_alloc_023.phpt @@ -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-- +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