@@ -72,7 +72,7 @@ static inline bool is_bad_mod(const zend_ssa *ssa, int use, int def) {
72
72
}
73
73
74
74
static inline bool may_have_side_effects (
75
- zend_op_array * op_array , zend_ssa * ssa ,
75
+ const zend_op_array * op_array , const zend_ssa * ssa ,
76
76
const zend_op * opline , const zend_ssa_op * ssa_op ,
77
77
bool reorder_dtor_effects ) {
78
78
switch (opline -> opcode ) {
@@ -271,8 +271,8 @@ static inline bool may_have_side_effects(
271
271
}
272
272
}
273
273
274
- static zend_always_inline void add_to_worklists (context * ctx , int var_num , int check ) {
275
- zend_ssa_var * var = & ctx -> ssa -> vars [var_num ];
274
+ static zend_always_inline void add_to_worklists (const context * ctx , int var_num , int check ) {
275
+ const zend_ssa_var * var = & ctx -> ssa -> vars [var_num ];
276
276
if (var -> definition >= 0 ) {
277
277
if (!check || zend_bitset_in (ctx -> instr_dead , var -> definition )) {
278
278
zend_bitset_incl (ctx -> instr_worklist , var -> definition );
@@ -284,14 +284,14 @@ static zend_always_inline void add_to_worklists(context *ctx, int var_num, int c
284
284
}
285
285
}
286
286
287
- static inline void add_to_phi_worklist_no_val (context * ctx , int var_num ) {
288
- zend_ssa_var * var = & ctx -> ssa -> vars [var_num ];
287
+ static inline void add_to_phi_worklist_no_val (const context * ctx , int var_num ) {
288
+ const zend_ssa_var * var = & ctx -> ssa -> vars [var_num ];
289
289
if (var -> definition_phi && zend_bitset_in (ctx -> phi_dead , var_num )) {
290
290
zend_bitset_incl (ctx -> phi_worklist_no_val , var_num );
291
291
}
292
292
}
293
293
294
- static zend_always_inline void add_operands_to_worklists (context * ctx , zend_op * opline , zend_ssa_op * ssa_op , zend_ssa * ssa , int check ) {
294
+ static zend_always_inline void add_operands_to_worklists (const context * ctx , const zend_op * opline , const zend_ssa_op * ssa_op , const zend_ssa * ssa , int check ) {
295
295
if (ssa_op -> result_use >= 0 ) {
296
296
add_to_worklists (ctx , ssa_op -> result_use , check );
297
297
}
@@ -315,16 +315,16 @@ static zend_always_inline void add_operands_to_worklists(context *ctx, zend_op *
315
315
}
316
316
}
317
317
318
- static zend_always_inline void add_phi_sources_to_worklists (context * ctx , zend_ssa_phi * phi , int check ) {
319
- zend_ssa * ssa = ctx -> ssa ;
318
+ static zend_always_inline void add_phi_sources_to_worklists (const context * ctx , zend_ssa_phi * phi , int check ) {
319
+ const zend_ssa * ssa = ctx -> ssa ;
320
320
int source ;
321
321
FOREACH_PHI_SOURCE (phi , source ) {
322
322
add_to_worklists (ctx , source , check );
323
323
} FOREACH_PHI_SOURCE_END ();
324
324
}
325
325
326
- static inline bool is_var_dead (context * ctx , int var_num ) {
327
- zend_ssa_var * var = & ctx -> ssa -> vars [var_num ];
326
+ static inline bool is_var_dead (const context * ctx , int var_num ) {
327
+ const zend_ssa_var * var = & ctx -> ssa -> vars [var_num ];
328
328
if (var -> definition_phi ) {
329
329
return zend_bitset_in (ctx -> phi_dead , var_num );
330
330
} else if (var -> definition >= 0 ) {
@@ -338,7 +338,7 @@ static inline bool is_var_dead(context *ctx, int var_num) {
338
338
}
339
339
340
340
// Sometimes we can mark the var as EXT_UNUSED
341
- static bool try_remove_var_def (context * ctx , int free_var , int use_chain , zend_op * opline ) {
341
+ static bool try_remove_var_def (const context * ctx , int free_var , int use_chain , const zend_op * opline ) {
342
342
if (use_chain >= 0 ) {
343
343
return false;
344
344
}
@@ -394,7 +394,7 @@ static zend_always_inline bool may_be_refcounted(uint32_t type) {
394
394
return (type & (MAY_BE_STRING |MAY_BE_ARRAY |MAY_BE_OBJECT |MAY_BE_RESOURCE |MAY_BE_REF )) != 0 ;
395
395
}
396
396
397
- static inline bool is_free_of_live_var (context * ctx , zend_op * opline , zend_ssa_op * ssa_op ) {
397
+ static inline bool is_free_of_live_var (const context * ctx , const zend_op * opline , const zend_ssa_op * ssa_op ) {
398
398
switch (opline -> opcode ) {
399
399
case ZEND_FREE :
400
400
/* It is always safe to remove FREEs of non-refcounted values, even if they are live. */
@@ -411,8 +411,8 @@ static inline bool is_free_of_live_var(context *ctx, zend_op *opline, zend_ssa_o
411
411
}
412
412
413
413
/* Returns whether the instruction has been DCEd */
414
- static bool dce_instr (context * ctx , zend_op * opline , zend_ssa_op * ssa_op ) {
415
- zend_ssa * ssa = ctx -> ssa ;
414
+ static bool dce_instr (const context * ctx , zend_op * opline , zend_ssa_op * ssa_op ) {
415
+ const zend_ssa * ssa = ctx -> ssa ;
416
416
int free_var = -1 ;
417
417
uint8_t free_var_type ;
418
418
@@ -464,7 +464,7 @@ static bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
464
464
return true;
465
465
}
466
466
467
- static inline int get_common_phi_source (zend_ssa * ssa , zend_ssa_phi * phi ) {
467
+ static inline int get_common_phi_source (const zend_ssa * ssa , zend_ssa_phi * phi ) {
468
468
int common_source = -1 ;
469
469
int source ;
470
470
FOREACH_PHI_SOURCE (phi , source ) {
@@ -484,7 +484,7 @@ static inline int get_common_phi_source(zend_ssa *ssa, zend_ssa_phi *phi) {
484
484
return common_source ;
485
485
}
486
486
487
- static void try_remove_trivial_phi (context * ctx , zend_ssa_phi * phi ) {
487
+ static void try_remove_trivial_phi (const context * ctx , zend_ssa_phi * phi ) {
488
488
zend_ssa * ssa = ctx -> ssa ;
489
489
if (phi -> pi < 0 ) {
490
490
/* Phi assignment with identical source operands */
@@ -567,7 +567,7 @@ int dce_optimize_op_array(zend_op_array *op_array, zend_optimizer_ctx *optimizer
567
567
int op_data = -1 ;
568
568
569
569
b -- ;
570
- zend_basic_block * block = & ssa -> cfg .blocks [b ];
570
+ const zend_basic_block * block = & ssa -> cfg .blocks [b ];
571
571
if (!(block -> flags & ZEND_BB_REACHABLE )) {
572
572
continue ;
573
573
}
0 commit comments