@@ -72,7 +72,7 @@ static inline bool is_bad_mod(const zend_ssa *ssa, int use, int def) {
7272}
7373
7474static 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 ,
7676 const zend_op * opline , const zend_ssa_op * ssa_op ,
7777 bool reorder_dtor_effects ) {
7878 switch (opline -> opcode ) {
@@ -271,8 +271,8 @@ static inline bool may_have_side_effects(
271271 }
272272}
273273
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 ];
276276 if (var -> definition >= 0 ) {
277277 if (!check || zend_bitset_in (ctx -> instr_dead , var -> definition )) {
278278 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
284284 }
285285}
286286
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 ];
289289 if (var -> definition_phi && zend_bitset_in (ctx -> phi_dead , var_num )) {
290290 zend_bitset_incl (ctx -> phi_worklist_no_val , var_num );
291291 }
292292}
293293
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 ) {
295295 if (ssa_op -> result_use >= 0 ) {
296296 add_to_worklists (ctx , ssa_op -> result_use , check );
297297 }
@@ -315,16 +315,16 @@ static zend_always_inline void add_operands_to_worklists(context *ctx, zend_op *
315315 }
316316}
317317
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 ;
320320 int source ;
321321 FOREACH_PHI_SOURCE (phi , source ) {
322322 add_to_worklists (ctx , source , check );
323323 } FOREACH_PHI_SOURCE_END ();
324324}
325325
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 ];
328328 if (var -> definition_phi ) {
329329 return zend_bitset_in (ctx -> phi_dead , var_num );
330330 } else if (var -> definition >= 0 ) {
@@ -338,7 +338,7 @@ static inline bool is_var_dead(context *ctx, int var_num) {
338338}
339339
340340// 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 ) {
342342 if (use_chain >= 0 ) {
343343 return false;
344344 }
@@ -394,7 +394,7 @@ static zend_always_inline bool may_be_refcounted(uint32_t type) {
394394 return (type & (MAY_BE_STRING |MAY_BE_ARRAY |MAY_BE_OBJECT |MAY_BE_RESOURCE |MAY_BE_REF )) != 0 ;
395395}
396396
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 ) {
398398 switch (opline -> opcode ) {
399399 case ZEND_FREE :
400400 /* 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
411411}
412412
413413/* 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 ;
416416 int free_var = -1 ;
417417 uint8_t free_var_type ;
418418
@@ -464,7 +464,7 @@ static bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
464464 return true;
465465}
466466
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 ) {
468468 int common_source = -1 ;
469469 int source ;
470470 FOREACH_PHI_SOURCE (phi , source ) {
@@ -484,7 +484,7 @@ static inline int get_common_phi_source(zend_ssa *ssa, zend_ssa_phi *phi) {
484484 return common_source ;
485485}
486486
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 ) {
488488 zend_ssa * ssa = ctx -> ssa ;
489489 if (phi -> pi < 0 ) {
490490 /* Phi assignment with identical source operands */
@@ -567,7 +567,7 @@ int dce_optimize_op_array(zend_op_array *op_array, zend_optimizer_ctx *optimizer
567567 int op_data = -1 ;
568568
569569 b -- ;
570- zend_basic_block * block = & ssa -> cfg .blocks [b ];
570+ const zend_basic_block * block = & ssa -> cfg .blocks [b ];
571571 if (!(block -> flags & ZEND_BB_REACHABLE )) {
572572 continue ;
573573 }
0 commit comments