@@ -10128,7 +10128,7 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen
10128
10128
ir_GUARD_NOT(
10129
10129
ir_AND_U32(
10130
10130
ir_LOAD_U32(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))),
10131
- ir_CONST_U32(ZEND_ACC_DEPRECATED)),
10131
+ ir_CONST_U32(ZEND_ACC_DEPRECATED|ZEND_ACC_NODISCARD )),
10132
10132
ir_CONST_ADDR(exit_addr));
10133
10133
}
10134
10134
}
@@ -10168,16 +10168,46 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen
10168
10168
}
10169
10169
ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10170
10170
ir_MERGE_WITH_EMPTY_FALSE(if_deprecated);
10171
+
10172
+ if (!RETURN_VALUE_USED(opline)) {
10173
+ ir_ref if_nodiscard, ret;
10174
+
10175
+ if_nodiscard = ir_IF(ir_AND_U32(
10176
+ ir_LOAD_U32(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))),
10177
+ ir_CONST_U32(ZEND_ACC_NODISCARD)));
10178
+ ir_IF_TRUE_cold(if_nodiscard);
10179
+
10180
+ if (GCC_GLOBAL_REGS) {
10181
+ ret = ir_CALL(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_nodiscard_helper));
10182
+ } else {
10183
+ ret = ir_CALL_1(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_nodiscard_helper), rx);
10184
+ }
10185
+ ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10186
+ ir_MERGE_WITH_EMPTY_FALSE(if_nodiscard);
10187
+ }
10171
10188
}
10172
- } else if (func->common.fn_flags & ZEND_ACC_DEPRECATED) {
10173
- ir_ref ret;
10189
+ } else {
10190
+ if (func->common.fn_flags & ZEND_ACC_DEPRECATED) {
10191
+ ir_ref ret;
10174
10192
10175
- if (GCC_GLOBAL_REGS) {
10176
- ret = ir_CALL(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_deprecated_helper));
10177
- } else {
10178
- ret = ir_CALL_1(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_deprecated_helper), rx);
10193
+ if (GCC_GLOBAL_REGS) {
10194
+ ret = ir_CALL(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_deprecated_helper));
10195
+ } else {
10196
+ ret = ir_CALL_1(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_deprecated_helper), rx);
10197
+ }
10198
+ ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10199
+ }
10200
+
10201
+ if ((func->common.fn_flags & ZEND_ACC_NODISCARD) && !RETURN_VALUE_USED(opline)) {
10202
+ ir_ref ret;
10203
+
10204
+ if (GCC_GLOBAL_REGS) {
10205
+ ret = ir_CALL(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_nodiscard_helper));
10206
+ } else {
10207
+ ret = ir_CALL_1(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_nodiscard_helper), rx);
10208
+ }
10209
+ ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10179
10210
}
10180
- ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10181
10211
}
10182
10212
}
10183
10213
0 commit comments