@@ -62,13 +62,13 @@ typedef struct {
6262static inline bool is_bad_mod (const zend_ssa * ssa , int use , int def ) {
6363 if (def < 0 ) {
6464 /* This modification is not tracked by SSA, assume the worst */
65- return 1 ;
65+ return true ;
6666 }
6767 if (ssa -> var_info [use ].type & MAY_BE_REF ) {
6868 /* Modification of reference may have side-effect */
69- return 1 ;
69+ return true ;
7070 }
71- return 0 ;
71+ return false ;
7272}
7373
7474static inline bool may_have_side_effects (
@@ -125,18 +125,18 @@ static inline bool may_have_side_effects(
125125 case ZEND_FUNC_GET_ARGS :
126126 case ZEND_ARRAY_KEY_EXISTS :
127127 /* No side effects */
128- return 0 ;
128+ return false ;
129129 case ZEND_FREE :
130130 return opline -> extended_value == ZEND_FREE_VOID_CAST ;
131131 case ZEND_ADD_ARRAY_ELEMENT :
132132 /* TODO: We can't free two vars. Keep instruction alive. <?php [0, "$a" => "$b"]; */
133133 if ((opline -> op1_type & (IS_VAR |IS_TMP_VAR )) && (opline -> op2_type & (IS_VAR |IS_TMP_VAR ))) {
134- return 1 ;
134+ return true ;
135135 }
136- return 0 ;
136+ return false ;
137137 case ZEND_ROPE_END :
138138 /* TODO: Rope dce optimization, see #76446 */
139- return 1 ;
139+ return true ;
140140 case ZEND_JMP :
141141 case ZEND_JMPZ :
142142 case ZEND_JMPNZ :
@@ -149,7 +149,7 @@ static inline bool may_have_side_effects(
149149 case ZEND_BIND_INIT_STATIC_OR_JMP :
150150 case ZEND_JMP_FRAMELESS :
151151 /* For our purposes a jumps and branches are side effects. */
152- return 1 ;
152+ return true ;
153153 case ZEND_BEGIN_SILENCE :
154154 case ZEND_END_SILENCE :
155155 case ZEND_ECHO :
@@ -164,7 +164,7 @@ static inline bool may_have_side_effects(
164164 case ZEND_YIELD_FROM :
165165 case ZEND_VERIFY_NEVER_TYPE :
166166 /* Intrinsic side effects */
167- return 1 ;
167+ return true ;
168168 case ZEND_DO_FCALL :
169169 case ZEND_DO_FCALL_BY_NAME :
170170 case ZEND_DO_ICALL :
@@ -174,31 +174,31 @@ static inline bool may_have_side_effects(
174174 case ZEND_FRAMELESS_ICALL_2 :
175175 case ZEND_FRAMELESS_ICALL_3 :
176176 /* For now assume all calls have side effects */
177- return 1 ;
177+ return true ;
178178 case ZEND_RECV :
179179 case ZEND_RECV_INIT :
180180 /* Even though RECV_INIT can be side-effect free, these cannot be simply dropped
181181 * due to the prologue skipping code. */
182- return 1 ;
182+ return true ;
183183 case ZEND_ASSIGN_REF :
184- return 1 ;
184+ return true ;
185185 case ZEND_ASSIGN :
186186 {
187187 if (is_bad_mod (ssa , ssa_op -> op1_use , ssa_op -> op1_def )) {
188- return 1 ;
188+ return true ;
189189 }
190190 if (!reorder_dtor_effects ) {
191191 if (opline -> op2_type != IS_CONST
192192 && (OP2_INFO () & MAY_HAVE_DTOR )
193193 && ssa -> vars [ssa_op -> op2_use ].escape_state != ESCAPE_STATE_NO_ESCAPE ) {
194194 /* DCE might shorten lifetime */
195- return 1 ;
195+ return true ;
196196 }
197197 }
198- return 0 ;
198+ return false ;
199199 }
200200 case ZEND_UNSET_VAR :
201- return 1 ;
201+ return true ;
202202 case ZEND_UNSET_CV :
203203 {
204204 uint32_t t1 = OP1_INFO ();
@@ -207,9 +207,9 @@ static inline bool may_have_side_effects(
207207 * an unset may be considered dead even if there is a later assignment to the
208208 * variable. Removing the unset in this case would not be correct if the variable
209209 * is a reference, because unset breaks references. */
210- return 1 ;
210+ return true ;
211211 }
212- return 0 ;
212+ return false ;
213213 }
214214 case ZEND_PRE_INC :
215215 case ZEND_POST_INC :
@@ -223,41 +223,41 @@ static inline bool may_have_side_effects(
223223 case ZEND_ASSIGN_OBJ :
224224 if (is_bad_mod (ssa , ssa_op -> op1_use , ssa_op -> op1_def )
225225 || ssa -> vars [ssa_op -> op1_def ].escape_state != ESCAPE_STATE_NO_ESCAPE ) {
226- return 1 ;
226+ return true ;
227227 }
228228 if (!reorder_dtor_effects ) {
229229 opline ++ ;
230230 ssa_op ++ ;
231231 if (opline -> op1_type != IS_CONST
232232 && (OP1_INFO () & MAY_HAVE_DTOR )) {
233233 /* DCE might shorten lifetime */
234- return 1 ;
234+ return true ;
235235 }
236236 }
237- return 0 ;
237+ return false ;
238238 case ZEND_PRE_INC_OBJ :
239239 case ZEND_PRE_DEC_OBJ :
240240 case ZEND_POST_INC_OBJ :
241241 case ZEND_POST_DEC_OBJ :
242242 if (is_bad_mod (ssa , ssa_op -> op1_use , ssa_op -> op1_def )
243243 || ssa -> vars [ssa_op -> op1_def ].escape_state != ESCAPE_STATE_NO_ESCAPE ) {
244- return 1 ;
244+ return true ;
245245 }
246- return 0 ;
246+ return false ;
247247 case ZEND_BIND_STATIC :
248248 if (op_array -> static_variables ) {
249249 /* Implicit and Explicit bind static is effectively prologue of closure so
250250 report it has side effects like RECV, RECV_INIT; This allows us to
251251 reflect on the closure and discover used variable at runtime */
252252 if ((opline -> extended_value & (ZEND_BIND_IMPLICIT |ZEND_BIND_EXPLICIT ))) {
253- return 1 ;
253+ return true ;
254254 }
255255 /* Modifies static variables which are observable through reflection */
256256 if ((opline -> extended_value & ZEND_BIND_REF ) && opline -> op2_type != IS_UNUSED ) {
257- return 1 ;
257+ return true ;
258258 }
259259 }
260- return 0 ;
260+ return false ;
261261 case ZEND_CHECK_VAR :
262262 return (OP1_INFO () & MAY_BE_UNDEF ) != 0 ;
263263 case ZEND_FE_RESET_R :
@@ -267,7 +267,7 @@ static inline bool may_have_side_effects(
267267 return (OP1_INFO () & MAY_BE_ANY ) != MAY_BE_ARRAY ;
268268 default :
269269 /* For everything we didn't handle, assume a side-effect */
270- return 1 ;
270+ return true ;
271271 }
272272}
273273
@@ -340,7 +340,7 @@ static inline bool is_var_dead(context *ctx, int var_num) {
340340// Sometimes we can mark the var as EXT_UNUSED
341341static bool try_remove_var_def (context * ctx , int free_var , int use_chain , zend_op * opline ) {
342342 if (use_chain >= 0 ) {
343- return 0 ;
343+ return false ;
344344 }
345345 zend_ssa_var * var = & ctx -> ssa -> vars [free_var ];
346346 int def = var -> definition ;
@@ -381,13 +381,13 @@ static bool try_remove_var_def(context *ctx, int free_var, int use_chain, zend_o
381381 def_opline -> result .var = 0 ;
382382 def_op -> result_def = -1 ;
383383 var -> definition = -1 ;
384- return 1 ;
384+ return true ;
385385 default :
386386 break ;
387387 }
388388 }
389389 }
390- return 0 ;
390+ return false ;
391391}
392392
393393static zend_always_inline bool may_be_refcounted (uint32_t type ) {
@@ -400,13 +400,13 @@ static inline bool is_free_of_live_var(context *ctx, zend_op *opline, zend_ssa_o
400400 /* It is always safe to remove FREEs of non-refcounted values, even if they are live. */
401401 if ((ctx -> ssa -> var_info [ssa_op -> op1_use ].type & (MAY_BE_REF |MAY_BE_ANY |MAY_BE_UNDEF )) != 0
402402 && !may_be_refcounted (ctx -> ssa -> var_info [ssa_op -> op1_use ].type )) {
403- return 0 ;
403+ return false ;
404404 }
405405 ZEND_FALLTHROUGH ;
406406 case ZEND_FE_FREE :
407407 return !is_var_dead (ctx , ssa_op -> op1_use );
408408 default :
409- return 0 ;
409+ return false ;
410410 }
411411}
412412
@@ -417,12 +417,12 @@ static bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
417417 uint8_t free_var_type ;
418418
419419 if (opline -> opcode == ZEND_NOP ) {
420- return 0 ;
420+ return false ;
421421 }
422422
423423 /* We mark FREEs as dead, but they're only really dead if the destroyed var is dead */
424424 if (is_free_of_live_var (ctx , opline , ssa_op )) {
425- return 0 ;
425+ return false ;
426426 }
427427
428428 if ((opline -> op1_type & (IS_VAR |IS_TMP_VAR ))&& !is_var_dead (ctx , ssa_op -> op1_use )) {
@@ -440,7 +440,7 @@ static bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
440440 if (free_var >= 0 ) {
441441 // TODO: We can't free two vars. Keep instruction alive.
442442 zend_bitset_excl (ctx -> instr_dead , opline - ctx -> op_array -> opcodes );
443- return 0 ;
443+ return false ;
444444 }
445445 free_var = ssa_op -> op2_use ;
446446 free_var_type = opline -> op2_type ;
@@ -459,9 +459,9 @@ static bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
459459 ssa_op -> op1_use = free_var ;
460460 ssa_op -> op1_use_chain = ssa -> vars [free_var ].use_chain ;
461461 ssa -> vars [free_var ].use_chain = ssa_op - ssa -> ops ;
462- return 0 ;
462+ return false ;
463463 }
464- return 1 ;
464+ return true ;
465465}
466466
467467static inline int get_common_phi_source (zend_ssa * ssa , zend_ssa_phi * phi ) {
@@ -507,17 +507,17 @@ static void try_remove_trivial_phi(context *ctx, zend_ssa_phi *phi) {
507507static inline bool may_break_varargs (const zend_op_array * op_array , const zend_ssa * ssa , const zend_ssa_op * ssa_op ) {
508508 if (ssa_op -> op1_def >= 0
509509 && ssa -> vars [ssa_op -> op1_def ].var < op_array -> num_args ) {
510- return 1 ;
510+ return true ;
511511 }
512512 if (ssa_op -> op2_def >= 0
513513 && ssa -> vars [ssa_op -> op2_def ].var < op_array -> num_args ) {
514- return 1 ;
514+ return true ;
515515 }
516516 if (ssa_op -> result_def >= 0
517517 && ssa -> vars [ssa_op -> result_def ].var < op_array -> num_args ) {
518- return 1 ;
518+ return true ;
519519 }
520- return 0 ;
520+ return false ;
521521}
522522
523523static inline bool may_throw_dce_exception (const zend_op * opline ) {
0 commit comments