[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
| From: | ndossche | Date: | Mon, 19 Oct 2026 20:38:36 +0000 |
| Subject: | [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142471@lists.php.net to get a copy of this message | ||
Author: ndossche (ndossche)
Date: 2026-10-19T22:38:18+02:00
Commit: https://github.com/php/php-src/commit/ee374693e3cb78cc8217045b2d525183b7287bfe
Raw diff: https://github.com/php/php-src/commit/ee374693e3cb78cc8217045b2d525183b7287bfe.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
Fix GH-24386: JIT: register operand must be loaded before the typed reference check
Changed paths:
A ext/opcache/tests/jit/gh24386.phpt
M NEWS
M ext/opcache/jit/zend_jit_ir.c
Diff:
diff --git a/NEWS b/NEWS
index c09e7c14ec9f..5ae657ceb034 100644
--- a/NEWS
+++ b/NEWS
@@ -65,6 +65,8 @@ PHP NEWS
case 0). (ndossche)
. Fixed bug GH-24206 (Tracing JIT loses loop-carried CV when its loop PHI
is reloaded from memory). (ndossche)
+ . Fixed bug GH-24386 (JIT: register operand must be loaded before the typed
+ reference check). (ndossche)
- PDO:
. Fixed a duplicate warning when ATTR_STATEMENT_CLASS is rejected on a
diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c
index 3d2e6198a294..d46a7c650a2c 100644
--- a/ext/opcache/jit/zend_jit_ir.c
+++ b/ext/opcache/jit/zend_jit_ir.c
@@ -6185,6 +6185,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);
diff --git a/ext/opcache/tests/jit/gh24386.phpt b/ext/opcache/tests/jit/gh24386.phpt
new file mode 100644
index 000000000000..cbf540b6bab5
--- /dev/null
+++ b/ext/opcache/tests/jit/gh24386.phpt
@@ -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)