@@ -69,13 +69,9 @@ static inline zend_bool is_bad_mod(const zend_ssa *ssa, int use, int def) {
69
69
}
70
70
71
71
static inline zend_bool may_have_side_effects (
72
- const context * ctx , const zend_op * opline , const zend_ssa_op * ssa_op ) {
73
- zend_op_array * op_array = ctx -> op_array ;
74
- zend_ssa * ssa = ctx -> ssa ;
75
- if (zend_may_throw (opline , op_array , ssa )) {
76
- return 1 ;
77
- }
78
-
72
+ zend_op_array * op_array , zend_ssa * ssa ,
73
+ const zend_op * opline , const zend_ssa_op * ssa_op ,
74
+ zend_bool reorder_dtor_effects ) {
79
75
switch (opline -> opcode ) {
80
76
case ZEND_NOP :
81
77
case ZEND_IS_IDENTICAL :
@@ -154,15 +150,10 @@ static inline zend_bool may_have_side_effects(
154
150
return 1 ;
155
151
case ZEND_ASSIGN :
156
152
{
157
- uint32_t t1 = OP1_INFO ();
158
153
if (is_bad_mod (ssa , ssa_op -> op1_use , ssa_op -> op1_def )) {
159
154
return 1 ;
160
155
}
161
- if (!ctx -> reorder_dtor_effects ) {
162
- if (t1 & MAY_HAVE_DTOR ) {
163
- /* DCE might extend lifetime */
164
- return 1 ;
165
- }
156
+ if (!reorder_dtor_effects ) {
166
157
if (opline -> op2_type != IS_CONST && (OP2_INFO () & MAY_HAVE_DTOR )) {
167
158
/* DCE might shorten lifetime */
168
159
return 1 ;
@@ -183,10 +174,6 @@ static inline zend_bool may_have_side_effects(
183
174
* is a reference, because unset breaks references. */
184
175
return 1 ;
185
176
}
186
- if (!ctx -> reorder_dtor_effects && (t1 & MAY_HAVE_DTOR )) {
187
- /* DCE might extend lifetime */
188
- return 1 ;
189
- }
190
177
return 0 ;
191
178
}
192
179
case ZEND_PRE_INC :
@@ -481,7 +468,9 @@ int dce_optimize_op_array(zend_op_array *op_array, zend_ssa *ssa, zend_bool reor
481
468
482
469
/* Mark instruction with side effects as live */
483
470
FOREACH_INSTR_NUM (i ) {
484
- if (may_have_side_effects (& ctx , & op_array -> opcodes [i ], & ssa -> ops [i ]) || has_varargs ) {
471
+ if (may_have_side_effects (op_array , ssa , & op_array -> opcodes [i ], & ssa -> ops [i ], ctx .reorder_dtor_effects )
472
+ || zend_may_throw (& op_array -> opcodes [i ], op_array , ssa )
473
+ || has_varargs ) {
485
474
zend_bitset_excl (ctx .instr_dead , i );
486
475
add_operands_to_worklists (& ctx , & op_array -> opcodes [i ], & ssa -> ops [i ]);
487
476
}
0 commit comments