Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -6276,6 +6276,13 @@ static int zend_jit_assign_op(zend_jit_ctx *jit,
ir_ref if_op1_typed = IR_UNUSED;
binary_op_type binary_op = get_binary_op(opline->extended_value);

if (Z_MODE(op2_addr) == IS_REG
&& Z_LOAD(op2_addr)
&& jit->ra[Z_SSA_VAR(op2_addr)].ref == IR_NULL) {
/* Force load, so that the register is defined on all paths */
zend_jit_use_reg(jit, op2_addr);
}

ref = jit_ZVAL_ADDR(jit, op1_addr);
if_op1_ref = jit_if_Z_TYPE_ref(jit, ref, ir_CONST_U8(IS_REFERENCE));
ir_IF_FALSE(if_op1_ref);
Expand Down
34 changes: 34 additions & 0 deletions ext/opcache/tests/jit/gh24386.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--TEST--
GH-24386 (register operand must be loaded before the typed reference check)
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.jit=tracing
opcache.jit_hot_func=2
--FILE--
<?php
class C {
public int $prop = 0;
}

function f($n) {
global $g, $h;
$g += $n;
$h += $n;
}

f(2);
var_dump($g, $h);

$c = new C;
$g =& $c->prop;
f(3);
var_dump($c->prop, $h);
?>
--EXPECT--
int(2)
int(2)
int(3)
int(5)
Loading