From 203c1b807e484ea26d3f3dfd504555a42bd367e8 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 10 Nov 2021 11:10:44 +0300 Subject: [PATCH] Tracing JIT: Fixed incorrect tracing type inference There are some cases when IS_VAR/IS_TMP_VAR variables are set to IS_UNDEF. TODO: It would be better to switch to IS_NULL in master. --- ext/opcache/jit/zend_jit_trace.c | 6 ++++ ext/opcache/tests/jit/fe_reset_001.phpt | 37 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 ext/opcache/tests/jit/fe_reset_001.phpt diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index ced7df20f7a..726f6251ea3 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -1436,6 +1436,12 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin if (op_type != IS_UNKNOWN) { ssa_var_info[i].type &= zend_jit_trace_type_to_info(op_type); + if (!ssa_var_info[i].type + && op_type == IS_UNDEF + && i >= op_array->last_var) { + // TODO: It's better to use NULL instead of UNDEF for temporary variables + ssa_var_info[i].type |= MAY_BE_UNDEF; + } } } i++; diff --git a/ext/opcache/tests/jit/fe_reset_001.phpt b/ext/opcache/tests/jit/fe_reset_001.phpt new file mode 100644 index 00000000000..164e5731ead --- /dev/null +++ b/ext/opcache/tests/jit/fe_reset_001.phpt @@ -0,0 +1,37 @@ +--TEST-- +FE_RESET: 001 undef $$ operand +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +--FILE-- + +OK +--EXPECTF-- +Warning: Undefined variable $0 in %sfe_reset_001.php on line 4 + +Warning: foreach() argument must be of type array|object, null given in %sfe_reset_001.php on line 4 + +Warning: Undefined variable $1 in %sfe_reset_001.php on line 4 + +Warning: foreach() argument must be of type array|object, null given in %sfe_reset_001.php on line 4 + +Warning: Undefined variable $2 in %sfe_reset_001.php on line 4 + +Warning: foreach() argument must be of type array|object, null given in %sfe_reset_001.php on line 4 + +Warning: Undefined variable $3 in %sfe_reset_001.php on line 4 + +Warning: foreach() argument must be of type array|object, null given in %sfe_reset_001.php on line 4 + +Warning: Undefined variable $4 in %sfe_reset_001.php on line 4 + +Warning: foreach() argument must be of type array|object, null given in %sfe_reset_001.php on line 4 +OK +