@@ -10137,7 +10137,7 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen
10137
10137
ir_GUARD_NOT(
10138
10138
ir_AND_U32(
10139
10139
ir_LOAD_U32(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))),
10140
- ir_CONST_U32(ZEND_ACC_DEPRECATED)),
10140
+ ir_CONST_U32(ZEND_ACC_DEPRECATED|ZEND_ACC_NODISCARD )),
10141
10141
ir_CONST_ADDR(exit_addr));
10142
10142
}
10143
10143
}
@@ -10177,16 +10177,46 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen
10177
10177
}
10178
10178
ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10179
10179
ir_MERGE_WITH_EMPTY_FALSE(if_deprecated);
10180
+
10181
+ if (!RETURN_VALUE_USED(opline)) {
10182
+ ir_ref if_nodiscard, ret;
10183
+
10184
+ if_nodiscard = ir_IF(ir_AND_U32(
10185
+ ir_LOAD_U32(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, fn_flags))),
10186
+ ir_CONST_U32(ZEND_ACC_NODISCARD)));
10187
+ ir_IF_TRUE_cold(if_nodiscard);
10188
+
10189
+ if (GCC_GLOBAL_REGS) {
10190
+ ret = ir_CALL(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_nodiscard_helper));
10191
+ } else {
10192
+ ret = ir_CALL_1(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_nodiscard_helper), rx);
10193
+ }
10194
+ ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10195
+ ir_MERGE_WITH_EMPTY_FALSE(if_nodiscard);
10196
+ }
10180
10197
}
10181
- } else if (func->common.fn_flags & ZEND_ACC_DEPRECATED) {
10182
- ir_ref ret;
10198
+ } else {
10199
+ if (func->common.fn_flags & ZEND_ACC_DEPRECATED) {
10200
+ ir_ref ret;
10183
10201
10184
- if (GCC_GLOBAL_REGS) {
10185
- ret = ir_CALL(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_deprecated_helper));
10186
- } else {
10187
- ret = ir_CALL_1(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_deprecated_helper), rx);
10202
+ if (GCC_GLOBAL_REGS) {
10203
+ ret = ir_CALL(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_deprecated_helper));
10204
+ } else {
10205
+ ret = ir_CALL_1(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_deprecated_helper), rx);
10206
+ }
10207
+ ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10208
+ }
10209
+
10210
+ if ((func->common.fn_flags & ZEND_ACC_NODISCARD) && !RETURN_VALUE_USED(opline)) {
10211
+ ir_ref ret;
10212
+
10213
+ if (GCC_GLOBAL_REGS) {
10214
+ ret = ir_CALL(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_nodiscard_helper));
10215
+ } else {
10216
+ ret = ir_CALL_1(IR_BOOL, ir_CONST_FC_FUNC(zend_jit_nodiscard_helper), rx);
10217
+ }
10218
+ ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10188
10219
}
10189
- ir_GUARD(ret, jit_STUB_ADDR(jit, jit_stub_exception_handler));
10190
10220
}
10191
10221
}
10192
10222
0 commit comments