Skip to content

Commit 9ddff66

Browse files
committed
Fix YIELD_FROM dce without result
1 parent ce61886 commit 9ddff66

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Zend/Optimizer/dce.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,16 @@ static inline bool may_have_side_effects(
163163
case ZEND_EXT_FCALL_END:
164164
case ZEND_TICKS:
165165
case ZEND_YIELD:
166-
case ZEND_YIELD_FROM:
167166
case ZEND_VERIFY_NEVER_TYPE:
168167
/* Intrinsic side effects */
169168
return true;
169+
case ZEND_YIELD_FROM: {
170+
uint32_t t1 = OP1_INFO();
171+
if ((t1 & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY && MAY_BE_EMPTY_ONLY(t1)) {
172+
return false;
173+
}
174+
return true;
175+
}
170176
case ZEND_DO_FCALL:
171177
case ZEND_DO_FCALL_BY_NAME:
172178
case ZEND_DO_ICALL:

Zend/Optimizer/zend_inference.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5337,6 +5337,13 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
53375337
return 1;
53385338
}
53395339
return 0;
5340+
case ZEND_YIELD_FROM: {
5341+
uint32_t t1 = OP1_INFO();
5342+
if ((t1 & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY && MAY_BE_EMPTY_ONLY(t1)) {
5343+
return false;
5344+
}
5345+
return true;
5346+
}
53405347
default:
53415348
return 1;
53425349
}

0 commit comments

Comments
 (0)