@@ -10153,7 +10153,7 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen
10153
10153
ir_GUARD_NOT(
10154
10154
ir_AND_U32(
10155
10155
ir_LOAD_U32(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))),
10156
- ir_CONST_U32(ZEND_ACC_DEPRECATED)),
10156
+ ir_CONST_U32(ZEND_ACC_DEPRECATED|ZEND_ACC_NODISCARD )),
10157
10157
ir_CONST_ADDR(exit_addr));
10158
10158
}
10159
10159
}
@@ -10193,16 +10193,46 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen
10193
10193
}
10194
10194
ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10195
10195
ir_MERGE_WITH_EMPTY_FALSE(if_deprecated);
10196
+
10197
+ if (!RETURN_VALUE_USED(opline)) {
10198
+ ir_ref if_nodiscard, ret;
10199
+
10200
+ if_nodiscard = ir_IF(ir_AND_U32(
10201
+ ir_LOAD_U32(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))),
10202
+ ir_CONST_U32(ZEND_ACC_NODISCARD)));
10203
+ ir_IF_TRUE_cold(if_nodiscard);
10204
+
10205
+ if (GCC_GLOBAL_REGS) {
10206
+ ret = ir_CALL(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_nodiscard_helper));
10207
+ } else {
10208
+ ret = ir_CALL_1(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_nodiscard_helper), rx);
10209
+ }
10210
+ ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10211
+ ir_MERGE_WITH_EMPTY_FALSE(if_nodiscard);
10212
+ }
10196
10213
}
10197
- } else if (func->common.fn_flags & ZEND_ACC_DEPRECATED) {
10198
- ir_ref ret;
10214
+ } else {
10215
+ if (func->common.fn_flags & ZEND_ACC_DEPRECATED) {
10216
+ ir_ref ret;
10199
10217
10200
- if (GCC_GLOBAL_REGS) {
10201
- ret = ir_CALL(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_deprecated_helper));
10202
- } else {
10203
- ret = ir_CALL_1(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_deprecated_helper), rx);
10218
+ if (GCC_GLOBAL_REGS) {
10219
+ ret = ir_CALL(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_deprecated_helper));
10220
+ } else {
10221
+ ret = ir_CALL_1(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_deprecated_helper), rx);
10222
+ }
10223
+ ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10224
+ }
10225
+
10226
+ if ((func->common.fn_flags & ZEND_ACC_NODISCARD) && !RETURN_VALUE_USED(opline)) {
10227
+ ir_ref ret;
10228
+
10229
+ if (GCC_GLOBAL_REGS) {
10230
+ ret = ir_CALL(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_nodiscard_helper));
10231
+ } else {
10232
+ ret = ir_CALL_1(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_nodiscard_helper), rx);
10233
+ }
10234
+ ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10204
10235
}
10205
- ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10206
10236
}
10207
10237
}
10208
10238
0 commit comments