Skip to content

Commit 37adfcc

Browse files
committed
Escpaing objects can't have destructors, so their assignment don't make side effects and may be eliminated.
1 parent 1778169 commit 37adfcc

File tree

1 file changed

+7
-2
lines changed
  • ext/opcache/Optimizer

1 file changed

+7
-2
lines changed

ext/opcache/Optimizer/dce.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ static inline zend_bool may_have_side_effects(
166166
return 1;
167167
}
168168
if (!reorder_dtor_effects) {
169-
if (opline->op2_type != IS_CONST && (OP2_INFO() & MAY_HAVE_DTOR)) {
169+
if (opline->op2_type != IS_CONST
170+
&& (OP2_INFO() & MAY_HAVE_DTOR)
171+
&& ssa->vars[ssa_op->op2_use].escape_state != ESCAPE_STATE_NO_ESCAPE) {
170172
/* DCE might shorten lifetime */
171173
return 1;
172174
}
@@ -215,7 +217,10 @@ static inline zend_bool may_have_side_effects(
215217
}
216218
if (!reorder_dtor_effects) {
217219
opline++;
218-
if (opline->op1_type != IS_CONST && (OP1_INFO() & MAY_HAVE_DTOR)) {
220+
ssa_op++;
221+
if (opline->op1_type != IS_CONST
222+
&& (OP1_INFO() & MAY_HAVE_DTOR)
223+
&& ssa->vars[ssa_op->op1_use].escape_state != ESCAPE_STATE_NO_ESCAPE) {
219224
/* DCE might shorten lifetime */
220225
return 1;
221226
}

0 commit comments

Comments
 (0)