Skip to content

Commit 98f07fc

Browse files
authored
Fix more issues reported in GH-15852
* Fix incorrect register allocation * Avoid IR binding/spilling conflict * Add missing type guard
1 parent ab99161 commit 98f07fc

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,14 @@ static bool zend_jit_spilling_may_cause_conflict(zend_jit_ctx *jit, int var, ir_
12981298
&& EX_VAR_TO_NUM(jit->ctx.ir_base[jit->ctx.ir_base[jit->ctx.ir_base[val].op2].op2].val.addr) < jit->current_op_array->last_var) {
12991299
/* binding between different CVs may cause spill conflict */
13001300
return 1;
1301+
} else if (jit->ssa->vars[var].definition >= 0
1302+
&& jit->ssa->ops[jit->ssa->vars[var].definition].op1_def == var
1303+
&& jit->ssa->ops[jit->ssa->vars[var].definition].op1_use >= 0
1304+
&& jit->ssa->vars[jit->ssa->ops[jit->ssa->vars[var].definition].op1_use].no_val
1305+
&& jit->ssa->vars[jit->ssa->ops[jit->ssa->vars[var].definition].op1_use].definition_phi
1306+
&& (jit->ssa->cfg.blocks[jit->ssa->vars[jit->ssa->ops[jit->ssa->vars[var].definition].op1_use].definition_phi->block].flags & ZEND_BB_LOOP_HEADER)) {
1307+
/* Avoid moving spill store out of loop */
1308+
return 1;
13011309
}
13021310
return 0;
13031311
}

ext/opcache/jit/zend_jit_trace.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3295,9 +3295,7 @@ static zend_jit_reg_var* zend_jit_trace_allocate_registers(zend_jit_trace_rec *t
32953295
RA_REG_FLAGS(def) |= ZREG_LOAD;
32963296
}
32973297
}
3298-
} else if (RA_HAS_REG(use)
3299-
&& (!ssa->vars[def].no_val
3300-
)) {
3298+
} else if (RA_HAS_REG(use)) {
33013299
if (ssa->vars[use].use_chain >= 0) {
33023300
RA_REG_FLAGS(use) |= ZREG_STORE; // TODO: ext/opcache/tests/jit/reg_alloc_00[67].phpt ???
33033301
} else {
@@ -4206,7 +4204,6 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
42064204
&& (trace_buffer->stop == ZEND_JIT_TRACE_STOP_LOOP
42074205
|| trace_buffer->stop == ZEND_JIT_TRACE_STOP_RECURSIVE_CALL
42084206
|| (trace_buffer->stop == ZEND_JIT_TRACE_STOP_RECURSIVE_RET
4209-
&& (opline-1)->result_type == IS_VAR
42104207
&& EX_VAR_TO_NUM((opline-1)->result.var) == i))
42114208
&& (ssa->vars[i].use_chain != -1
42124209
|| (ssa->vars[i].phi_use_chain

0 commit comments

Comments
 (0)