From 0c2da827ad44d9e4767f0a3fc32070577f7f6e63 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Wed, 6 Mar 2024 20:20:49 +0100 Subject: [PATCH] Fix JIT QM_ASSIGN may be optimized out when op1 is null Co-authored-by: Dmitry Stogov --- ext/opcache/jit/zend_jit_trace.c | 3 +- ext/opcache/tests/jit/qm_assign_004.phpt | 39 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 ext/opcache/tests/jit/qm_assign_004.phpt diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index f6da28375b74d..c1ed5d80a666a 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -5070,8 +5070,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par CHECK_OP1_TRACE_TYPE(); res_info = RES_INFO(); res_use_info = zend_jit_trace_type_to_info( - STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->result.var))) - & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE); + STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->result.var))); res_addr = RES_REG_ADDR(); if (Z_MODE(res_addr) != IS_REG && STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var)) != diff --git a/ext/opcache/tests/jit/qm_assign_004.phpt b/ext/opcache/tests/jit/qm_assign_004.phpt new file mode 100644 index 0000000000000..975d46be41cec --- /dev/null +++ b/ext/opcache/tests/jit/qm_assign_004.phpt @@ -0,0 +1,39 @@ +--TEST-- +JIT QM_ASSIGN: 004 missing type store +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +--FILE-- + +DONE +--EXPECT-- +array(2) { + [0]=> + string(0) "" + [1]=> + string(0) "" +} +array(2) { + [0]=> + string(0) "" + [1]=> + string(0) "" +} +DONE