Lines Matching refs:ssa
41 int zend_dfa_analyze_op_array(zend_op_array *op_array, zend_optimizer_ctx *ctx, zend_ssa *ssa) in zend_dfa_analyze_op_array() argument
51 memset(ssa, 0, sizeof(zend_ssa)); in zend_dfa_analyze_op_array()
53 if (zend_build_cfg(&ctx->arena, op_array, ZEND_CFG_NO_ENTRY_PREDECESSORS, &ssa->cfg) != SUCCESS) { in zend_dfa_analyze_op_array()
57 if ((ssa->cfg.flags & ZEND_FUNC_INDIRECT_VAR_ACCESS)) { in zend_dfa_analyze_op_array()
62 if (zend_cfg_build_predecessors(&ctx->arena, &ssa->cfg) != SUCCESS) { in zend_dfa_analyze_op_array()
67 zend_dump_op_array(op_array, ZEND_DUMP_CFG, "dfa cfg", &ssa->cfg); in zend_dfa_analyze_op_array()
71 if (zend_cfg_compute_dominators_tree(op_array, &ssa->cfg) != SUCCESS) { in zend_dfa_analyze_op_array()
76 if (zend_cfg_identify_loops(op_array, &ssa->cfg) != SUCCESS) { in zend_dfa_analyze_op_array()
81 zend_dump_dominators(op_array, &ssa->cfg); in zend_dfa_analyze_op_array()
91 if (zend_build_ssa(&ctx->arena, ctx->script, op_array, build_flags, ssa) != SUCCESS) { in zend_dfa_analyze_op_array()
96 zend_dump_op_array(op_array, ZEND_DUMP_SSA, "dfa ssa", ssa); in zend_dfa_analyze_op_array()
100 if (zend_ssa_compute_use_def_chains(&ctx->arena, op_array, ssa) != SUCCESS){ in zend_dfa_analyze_op_array()
104 if (zend_ssa_find_false_dependencies(op_array, ssa) != SUCCESS) { in zend_dfa_analyze_op_array()
108 if (zend_ssa_find_sccs(op_array, ssa) != SUCCESS){ in zend_dfa_analyze_op_array()
112 …if (zend_ssa_inference(&ctx->arena, op_array, ctx->script, ssa, ctx->optimization_level) != SUCCES… in zend_dfa_analyze_op_array()
116 if (zend_ssa_escape_analysis(ctx->script, op_array, ssa) != SUCCESS) { in zend_dfa_analyze_op_array()
121 zend_dump_ssa_variables(op_array, ssa, 0); in zend_dfa_analyze_op_array()
127 static void zend_ssa_remove_nops(zend_op_array *op_array, zend_ssa *ssa, zend_optimizer_ctx *ctx) in zend_ssa_remove_nops() argument
129 zend_basic_block *blocks = ssa->cfg.blocks; in zend_ssa_remove_nops()
130 zend_basic_block *blocks_end = blocks + ssa->cfg.blocks_count; in zend_ssa_remove_nops()
177 ssa->ops[target] = ssa->ops[i]; in zend_ssa_remove_nops()
178 ssa->cfg.map[target] = b - blocks; in zend_ssa_remove_nops()
214 for (j = 0; j < ssa->vars_count; j++) { in zend_ssa_remove_nops()
215 if (ssa->vars[j].definition >= 0) { in zend_ssa_remove_nops()
216 ssa->vars[j].definition -= shiftlist[ssa->vars[j].definition]; in zend_ssa_remove_nops()
218 if (ssa->vars[j].use_chain >= 0) { in zend_ssa_remove_nops()
219 ssa->vars[j].use_chain -= shiftlist[ssa->vars[j].use_chain]; in zend_ssa_remove_nops()
223 if (ssa->ops[i].op1_use_chain >= 0) { in zend_ssa_remove_nops()
224 ssa->ops[i].op1_use_chain -= shiftlist[ssa->ops[i].op1_use_chain]; in zend_ssa_remove_nops()
226 if (ssa->ops[i].op2_use_chain >= 0) { in zend_ssa_remove_nops()
227 ssa->ops[i].op2_use_chain -= shiftlist[ssa->ops[i].op2_use_chain]; in zend_ssa_remove_nops()
229 if (ssa->ops[i].res_use_chain >= 0) { in zend_ssa_remove_nops()
230 ssa->ops[i].res_use_chain -= shiftlist[ssa->ops[i].res_use_chain]; in zend_ssa_remove_nops()
294 const zend_script *script, zend_op_array *op_array, zend_ssa *ssa, zend_ssa_op *ssa_op) { in can_elide_return_type_check() argument
296 zend_ssa_var_info *use_info = &ssa->var_info[ssa_op->op1_use]; in can_elide_return_type_check()
336 zend_op_array *op_array, zend_ssa *ssa, zend_op *opline, int src_var, uint32_t cv_var) { in opline_supports_assign_contraction() argument
346 uint32_t type = ssa->var_info[src_var].type; in opline_supports_assign_contraction()
377 && zend_may_throw(opline, &ssa->ops[ssa->vars[src_var].definition], op_array, ssa)) { in opline_supports_assign_contraction()
384 static bool variable_defined_or_used_in_range(zend_ssa *ssa, int var, int start, int end) in variable_defined_or_used_in_range() argument
387 const zend_ssa_op *ssa_op = &ssa->ops[start]; in variable_defined_or_used_in_range()
388 if ((ssa_op->op1_def >= 0 && ssa->vars[ssa_op->op1_def].var == var) || in variable_defined_or_used_in_range()
389 (ssa_op->op2_def >= 0 && ssa->vars[ssa_op->op2_def].var == var) || in variable_defined_or_used_in_range()
390 (ssa_op->result_def >= 0 && ssa->vars[ssa_op->result_def].var == var) || in variable_defined_or_used_in_range()
391 (ssa_op->op1_use >= 0 && ssa->vars[ssa_op->op1_use].var == var) || in variable_defined_or_used_in_range()
392 (ssa_op->op2_use >= 0 && ssa->vars[ssa_op->op2_use].var == var) || in variable_defined_or_used_in_range()
393 (ssa_op->result_use >= 0 && ssa->vars[ssa_op->result_use].var == var) in variable_defined_or_used_in_range()
402 int zend_dfa_optimize_calls(zend_op_array *op_array, zend_ssa *ssa) in zend_dfa_optimize_calls() argument
476 zend_ssa_op *ssa_op = ssa->ops + op_num; in zend_dfa_optimize_calls()
481 zend_ssa_var *var = ssa->vars + var_num; in zend_dfa_optimize_calls()
484 zend_ssa_unlink_use_chain(ssa, op_num, ssa_op->op1_use); in zend_dfa_optimize_calls()
488 ssa_op = ssa->ops + op_num; in zend_dfa_optimize_calls()
512 ssa_op = ssa->ops + op_num; in zend_dfa_optimize_calls()
515 int use = ssa->vars[var].use_chain; in zend_dfa_optimize_calls()
520 if (ssa->vars[var].phi_use_chain == NULL in zend_dfa_optimize_calls()
521 && ssa->ops[use].op1_use == var in zend_dfa_optimize_calls()
522 && ssa->ops[use].op1_use_chain == -1 in zend_dfa_optimize_calls()
539 static zend_always_inline void take_successor_0(zend_ssa *ssa, int block_num, zend_basic_block *blo… in take_successor_0() argument
543 zend_ssa_remove_predecessor(ssa, block_num, block->successors[1]); in take_successor_0()
549 static zend_always_inline void take_successor_1(zend_ssa *ssa, int block_num, zend_basic_block *blo… in take_successor_1() argument
553 zend_ssa_remove_predecessor(ssa, block_num, block->successors[0]); in take_successor_1()
560 static zend_always_inline void take_successor_ex(zend_ssa *ssa, int block_num, zend_basic_block *bl… in take_successor_ex() argument
566 zend_ssa_remove_predecessor(ssa, block_num, block->successors[i]); in take_successor_ex()
586 static void replace_predecessor(zend_ssa *ssa, int block_id, int old_pred, int new_pred) { in replace_predecessor() argument
587 zend_basic_block *block = &ssa->cfg.blocks[block_id]; in replace_predecessor()
588 int *predecessors = &ssa->cfg.predecessors[block->predecessor_offset]; in replace_predecessor()
617 for (phi = ssa->blocks[block_id].phis; phi; phi = phi->next) { in replace_predecessor()
621 ssa, phi->ssa_var, phi->sources[0], /* update_types */ 0); in replace_predecessor()
622 zend_ssa_remove_phi(ssa, phi); in replace_predecessor()
637 static void zend_ssa_replace_control_link(zend_op_array *op_array, zend_ssa *ssa, int from, int to,… in zend_ssa_replace_control_link() argument
639 zend_basic_block *src = &ssa->cfg.blocks[from]; in zend_ssa_replace_control_link()
640 zend_basic_block *old = &ssa->cfg.blocks[to]; in zend_ssa_replace_control_link()
641 zend_basic_block *dst = &ssa->cfg.blocks[new_to]; in zend_ssa_replace_control_link()
710 replace_predecessor(ssa, new_to, to, from); in zend_ssa_replace_control_link()
713 static void zend_ssa_unlink_block(zend_op_array *op_array, zend_ssa *ssa, zend_basic_block *block, … in zend_ssa_unlink_block() argument
715 if (block->predecessors_count == 1 && ssa->blocks[block_num].phis == NULL) { in zend_ssa_unlink_block()
720 predecessors = &ssa->cfg.predecessors[block->predecessor_offset]; in zend_ssa_unlink_block()
722 zend_basic_block *pred_block = &ssa->cfg.blocks[predecessors[0]]; in zend_ssa_unlink_block()
733 zend_ssa_replace_control_link(op_array, ssa, predecessors[i], block_num, block->successors[0]); in zend_ssa_unlink_block()
735 zend_ssa_remove_block(op_array, ssa, block_num); in zend_ssa_unlink_block()
738 int ssa_var = ssa->ops[fe_fetch_block->start + fe_fetch_block->len - 1].op2_def; in zend_ssa_unlink_block()
740 zend_ssa_remove_uses_of_var(ssa, ssa_var); in zend_ssa_unlink_block()
746 static int zend_dfa_optimize_jmps(zend_op_array *op_array, zend_ssa *ssa) in zend_dfa_optimize_jmps() argument
751 for (block_num = 1; block_num < ssa->cfg.blocks_count; block_num++) { in zend_dfa_optimize_jmps()
752 zend_basic_block *block = &ssa->cfg.blocks[block_num]; in zend_dfa_optimize_jmps()
759 zend_ssa_unlink_block(op_array, ssa, block, block_num); in zend_dfa_optimize_jmps()
764 while (block_num < ssa->cfg.blocks_count in zend_dfa_optimize_jmps()
765 && !(ssa->cfg.blocks[block_num].flags & ZEND_BB_REACHABLE)) { in zend_dfa_optimize_jmps()
768 while (block_num < ssa->cfg.blocks_count) { in zend_dfa_optimize_jmps()
770 zend_basic_block *block = &ssa->cfg.blocks[block_num]; in zend_dfa_optimize_jmps()
776 while (next_block_num < ssa->cfg.blocks_count in zend_dfa_optimize_jmps()
777 && !(ssa->cfg.blocks[next_block_num].flags & ZEND_BB_REACHABLE)) { in zend_dfa_optimize_jmps()
778 if (ssa->cfg.blocks[next_block_num].flags & ZEND_BB_UNREACHABLE_FREE) { in zend_dfa_optimize_jmps()
787 ssa_op = ssa->ops + op_num; in zend_dfa_optimize_jmps()
804 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
809 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
814 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
819 zend_ssa_remove_instr(ssa, opline, ssa_op); in zend_dfa_optimize_jmps()
835 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
840 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
845 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
850 zend_ssa_remove_instr(ssa, opline, ssa_op); in zend_dfa_optimize_jmps()
865 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
869 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
877 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
883 zend_ssa_remove_instr(ssa, opline, ssa_op); in zend_dfa_optimize_jmps()
892 zend_ssa_unlink_use_chain(ssa, op_num, ssa_op->op1_use); in zend_dfa_optimize_jmps()
904 if (ssa->vars[ssa_op->result_def].use_chain < 0 in zend_dfa_optimize_jmps()
905 && ssa->vars[ssa_op->result_def].phi_use_chain == NULL) { in zend_dfa_optimize_jmps()
908 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
913 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
918 if (ssa->vars[ssa_op->result_def].use_chain < 0 in zend_dfa_optimize_jmps()
919 && ssa->vars[ssa_op->result_def].phi_use_chain == NULL) { in zend_dfa_optimize_jmps()
922 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
927 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
932 if (ssa->vars[ssa_op->result_def].use_chain < 0 in zend_dfa_optimize_jmps()
933 && ssa->vars[ssa_op->result_def].phi_use_chain == NULL) { in zend_dfa_optimize_jmps()
936 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
942 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
943 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
950 zend_ssa_var *var = &ssa->vars[ssa_op->result_def]; in zend_dfa_optimize_jmps()
954 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
957 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
962 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
964 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
972 zend_ssa_var *var = &ssa->vars[ssa_op->result_def]; in zend_dfa_optimize_jmps()
978 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
980 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
983 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
986 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
1011 take_successor_ex(ssa, block_num, block, block->successors[block->successors_count - 1]); in zend_dfa_optimize_jmps()
1036 take_successor_ex(ssa, block_num, block, ssa->cfg.map[target]); in zend_dfa_optimize_jmps()
1045 zend_ssa_unlink_block(op_array, ssa, block, block_num); in zend_dfa_optimize_jmps()
1050 && !(ssa->cfg.blocks[block_num].flags & ZEND_BB_REACHABLE)); in zend_dfa_optimize_jmps()
1068 static int zend_dfa_try_to_replace_result(zend_op_array *op_array, zend_ssa *ssa, int def, int cv_v… in zend_dfa_try_to_replace_result() argument
1070 int result_var = ssa->ops[def].result_def; in zend_dfa_try_to_replace_result()
1071 int cv = EX_NUM_TO_VAR(ssa->vars[cv_var].var); in zend_dfa_try_to_replace_result()
1074 && !(ssa->var_info[cv_var].type & MAY_BE_REF) in zend_dfa_try_to_replace_result()
1075 && ssa->vars[cv_var].alias == NO_ALIAS in zend_dfa_try_to_replace_result()
1076 && ssa->vars[result_var].phi_use_chain == NULL in zend_dfa_try_to_replace_result()
1077 && ssa->vars[result_var].sym_use_chain == NULL) { in zend_dfa_try_to_replace_result()
1078 int use = ssa->vars[result_var].use_chain; in zend_dfa_try_to_replace_result()
1081 && zend_ssa_next_use(ssa->ops, result_var, use) < 0 in zend_dfa_try_to_replace_result()
1102 ssa->vars[result_var].definition = -1; in zend_dfa_try_to_replace_result()
1103 ssa->vars[result_var].use_chain = -1; in zend_dfa_try_to_replace_result()
1104 ssa->ops[def].result_def = -1; in zend_dfa_try_to_replace_result()
1109 if (ssa->ops[use].op1_use == result_var) { in zend_dfa_try_to_replace_result()
1110 ssa->ops[use].op1_use = cv_var; in zend_dfa_try_to_replace_result()
1111 ssa->ops[use].op1_use_chain = ssa->vars[cv_var].use_chain; in zend_dfa_try_to_replace_result()
1112 ssa->vars[cv_var].use_chain = use; in zend_dfa_try_to_replace_result()
1116 } else if (ssa->ops[use].op2_use == result_var) { in zend_dfa_try_to_replace_result()
1117 ssa->ops[use].op2_use = cv_var; in zend_dfa_try_to_replace_result()
1118 ssa->ops[use].op2_use_chain = ssa->vars[cv_var].use_chain; in zend_dfa_try_to_replace_result()
1119 ssa->vars[cv_var].use_chain = use; in zend_dfa_try_to_replace_result()
1123 } else if (ssa->ops[use].result_use == result_var) { in zend_dfa_try_to_replace_result()
1124 ssa->ops[use].result_use = cv_var; in zend_dfa_try_to_replace_result()
1125 ssa->ops[use].res_use_chain = ssa->vars[cv_var].use_chain; in zend_dfa_try_to_replace_result()
1126 ssa->vars[cv_var].use_chain = use; in zend_dfa_try_to_replace_result()
1140 void zend_dfa_optimize_op_array(zend_op_array *op_array, zend_optimizer_ctx *ctx, zend_ssa *ssa, ze… in zend_dfa_optimize_op_array() argument
1143 zend_dump_op_array(op_array, ZEND_DUMP_SSA, "before dfa pass", ssa); in zend_dfa_optimize_op_array()
1146 if (ssa->var_info) { in zend_dfa_optimize_op_array()
1155 ssa_verify_integrity(op_array, ssa, "before dfa"); in zend_dfa_optimize_op_array()
1159 if (sccp_optimize_op_array(ctx, op_array, ssa, call_map)) { in zend_dfa_optimize_op_array()
1163 if (zend_dfa_optimize_jmps(op_array, ssa)) { in zend_dfa_optimize_op_array()
1168 ssa_verify_integrity(op_array, ssa, "after sccp"); in zend_dfa_optimize_op_array()
1171 if (zend_dfa_optimize_calls(op_array, ssa)) { in zend_dfa_optimize_op_array()
1176 zend_dump_op_array(op_array, ZEND_DUMP_SSA, "after sccp pass", ssa); in zend_dfa_optimize_op_array()
1179 ssa_verify_integrity(op_array, ssa, "after calls"); in zend_dfa_optimize_op_array()
1184 if (dce_optimize_op_array(op_array, ssa, 0)) { in zend_dfa_optimize_op_array()
1187 if (zend_dfa_optimize_jmps(op_array, ssa)) { in zend_dfa_optimize_op_array()
1191 zend_dump_op_array(op_array, ZEND_DUMP_SSA, "after dce pass", ssa); in zend_dfa_optimize_op_array()
1194 ssa_verify_integrity(op_array, ssa, "after dce"); in zend_dfa_optimize_op_array()
1198 for (v = op_array->last_var; v < ssa->vars_count; v++) { in zend_dfa_optimize_op_array()
1200 op_1 = ssa->vars[v].definition; in zend_dfa_optimize_op_array()
1207 ssa_op = &ssa->ops[op_1]; in zend_dfa_optimize_op_array()
1210 if (ssa->var_info[v].use_as_double) { in zend_dfa_optimize_op_array()
1213 && ssa->ops[op_1].op1_def == v in zend_dfa_optimize_op_array()
1275 ssa->ops[op_1].op1_use = ssa->ops[op_1].op2_use; in zend_dfa_optimize_op_array()
1276 ssa->ops[op_1].op1_use_chain = ssa->ops[op_1].op2_use_chain; in zend_dfa_optimize_op_array()
1277 ssa->ops[op_1].op2_use = -1; in zend_dfa_optimize_op_array()
1278 ssa->ops[op_1].op2_use_chain = -1; in zend_dfa_optimize_op_array()
1295 ssa->ops[op_1].op1_use = ssa->ops[op_1].op2_use; in zend_dfa_optimize_op_array()
1296 ssa->ops[op_1].op1_use_chain = ssa->ops[op_1].op2_use_chain; in zend_dfa_optimize_op_array()
1340 ssa->ops[op_1].op2_use = ssa->ops[op_1].op1_use; in zend_dfa_optimize_op_array()
1341 ssa->ops[op_1].op2_use_chain = ssa->ops[op_1].op1_use_chain; in zend_dfa_optimize_op_array()
1352 && ssa->ops[op_1].op1_def == v in zend_dfa_optimize_op_array()
1353 && ssa->ops[op_1].op1_use >= 0 in zend_dfa_optimize_op_array()
1354 && ssa->ops[op_1].op1_use_chain == -1 in zend_dfa_optimize_op_array()
1355 && can_elide_return_type_check(ctx->script, op_array, ssa, &ssa->ops[op_1])) { in zend_dfa_optimize_op_array()
1359 int orig_var = ssa->ops[op_1].op1_use; in zend_dfa_optimize_op_array()
1360 if (zend_ssa_unlink_use_chain(ssa, op_1, orig_var)) { in zend_dfa_optimize_op_array()
1362 int ret = ssa->vars[v].use_chain; in zend_dfa_optimize_op_array()
1364 ssa->ops[ret].op1_use = orig_var; in zend_dfa_optimize_op_array()
1365 ssa->ops[ret].op1_use_chain = ssa->vars[orig_var].use_chain; in zend_dfa_optimize_op_array()
1366 ssa->vars[orig_var].use_chain = ret; in zend_dfa_optimize_op_array()
1369 ssa->vars[v].definition = -1; in zend_dfa_optimize_op_array()
1370 ssa->vars[v].use_chain = -1; in zend_dfa_optimize_op_array()
1372 ssa->ops[op_1].op1_def = -1; in zend_dfa_optimize_op_array()
1373 ssa->ops[op_1].op1_use = -1; in zend_dfa_optimize_op_array()
1382 && ssa->ops[op_1].result_def == v in zend_dfa_optimize_op_array()
1384 …&& !(ssa->var_info[v].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) in zend_dfa_optimize_op_array()
1387 int src_var = ssa->ops[op_1].op1_use; in zend_dfa_optimize_op_array()
1390 && !(ssa->var_info[src_var].type & MAY_BE_REF) in zend_dfa_optimize_op_array()
1391 && (ssa->var_info[src_var].type & (MAY_BE_UNDEF|MAY_BE_ANY)) in zend_dfa_optimize_op_array()
1392 && ssa->vars[src_var].definition >= 0 in zend_dfa_optimize_op_array()
1393 && ssa->ops[ssa->vars[src_var].definition].result_def == src_var in zend_dfa_optimize_op_array()
1394 && ssa->ops[ssa->vars[src_var].definition].result_use < 0 in zend_dfa_optimize_op_array()
1395 && ssa->vars[src_var].use_chain == op_1 in zend_dfa_optimize_op_array()
1396 && ssa->ops[op_1].op1_use_chain < 0 in zend_dfa_optimize_op_array()
1397 && !ssa->vars[src_var].phi_use_chain in zend_dfa_optimize_op_array()
1398 && !ssa->vars[src_var].sym_use_chain in zend_dfa_optimize_op_array()
1400 op_array, ssa, &op_array->opcodes[ssa->vars[src_var].definition], in zend_dfa_optimize_op_array()
1402 && !variable_defined_or_used_in_range(ssa, EX_VAR_TO_NUM(opline->result.var), in zend_dfa_optimize_op_array()
1403 ssa->vars[src_var].definition+1, op_1) in zend_dfa_optimize_op_array()
1406 int orig_var = ssa->ops[op_1].result_use; in zend_dfa_optimize_op_array()
1407 int op_2 = ssa->vars[src_var].definition; in zend_dfa_optimize_op_array()
1412 if (orig_var < 0 || zend_ssa_unlink_use_chain(ssa, op_1, orig_var)) { in zend_dfa_optimize_op_array()
1414 ssa->vars[v].definition = op_2; in zend_dfa_optimize_op_array()
1415 ssa->ops[op_2].result_def = v; in zend_dfa_optimize_op_array()
1417 ssa->vars[src_var].definition = -1; in zend_dfa_optimize_op_array()
1418 ssa->vars[src_var].use_chain = -1; in zend_dfa_optimize_op_array()
1420 ssa->ops[op_1].op1_use = -1; in zend_dfa_optimize_op_array()
1421 ssa->ops[op_1].op1_def = -1; in zend_dfa_optimize_op_array()
1422 ssa->ops[op_1].op1_use_chain = -1; in zend_dfa_optimize_op_array()
1423 ssa->ops[op_1].result_use = -1; in zend_dfa_optimize_op_array()
1424 ssa->ops[op_1].result_def = -1; in zend_dfa_optimize_op_array()
1425 ssa->ops[op_1].res_use_chain = -1; in zend_dfa_optimize_op_array()
1440 && ssa->ops[op_2].op1_use >= 0 in zend_dfa_optimize_op_array()
1441 …&& !(ssa->var_info[ssa->ops[op_2].op1_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1447 ssa->ops[op_2].result_def = -1; in zend_dfa_optimize_op_array()
1448 ssa->ops[op_2].op1_def = v; in zend_dfa_optimize_op_array()
1456 && ssa->ops[op_2].op1_use >= 0 in zend_dfa_optimize_op_array()
1457 …&& !(ssa->var_info[ssa->ops[op_2].op1_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1463 ssa->ops[op_2].result_def = -1; in zend_dfa_optimize_op_array()
1464 ssa->ops[op_2].op1_def = v; in zend_dfa_optimize_op_array()
1472 && ssa->ops[op_2].op2_use >= 0 in zend_dfa_optimize_op_array()
1473 …&& !(ssa->var_info[ssa->ops[op_2].op2_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1481 ssa->ops[op_2].result_def = -1; in zend_dfa_optimize_op_array()
1482 ssa->ops[op_2].op1_def = v; in zend_dfa_optimize_op_array()
1483 ssa->ops[op_2].op1_use = ssa->ops[op_2].op2_use; in zend_dfa_optimize_op_array()
1484 ssa->ops[op_2].op1_use_chain = ssa->ops[op_2].op2_use_chain; in zend_dfa_optimize_op_array()
1485 ssa->ops[op_2].op2_use = -1; in zend_dfa_optimize_op_array()
1486 ssa->ops[op_2].op2_use_chain = -1; in zend_dfa_optimize_op_array()
1492 if (ssa->vars[v].var >= op_array->last_var) { in zend_dfa_optimize_op_array()
1497 if (ssa->ops[op_1].op1_def == v in zend_dfa_optimize_op_array()
1503 zend_dfa_try_to_replace_result(op_array, ssa, op_1, v); in zend_dfa_optimize_op_array()
1505 int result_var = ssa->ops[op_1].result_def; in zend_dfa_optimize_op_array()
1508 …&& (ssa->var_info[result_var].type & ((MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_D… in zend_dfa_optimize_op_array()
1509 int use = ssa->vars[result_var].use_chain; in zend_dfa_optimize_op_array()
1512 && ssa->ops[use].op1_use == result_var in zend_dfa_optimize_op_array()
1513 && zend_dfa_try_to_replace_result(op_array, ssa, op_1, v)) { in zend_dfa_optimize_op_array()
1519 int result_var = ssa->ops[op_1].result_def; in zend_dfa_optimize_op_array()
1522 …&& (ssa->var_info[result_var].type & ((MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_D… in zend_dfa_optimize_op_array()
1523 int use = ssa->vars[result_var].use_chain; in zend_dfa_optimize_op_array()
1526 && ssa->ops[use].op2_use == result_var in zend_dfa_optimize_op_array()
1527 && zend_dfa_try_to_replace_result(op_array, ssa, op_1, v)) { in zend_dfa_optimize_op_array()
1536 && ssa->ops[op_1].op1_def == v in zend_dfa_optimize_op_array()
1539 int orig_var = ssa->ops[op_1].op1_use; in zend_dfa_optimize_op_array()
1542 …&& !(ssa->var_info[orig_var].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_… in zend_dfa_optimize_op_array()
1544 int src_var = ssa->ops[op_1].op2_use; in zend_dfa_optimize_op_array()
1548 && !(ssa->var_info[src_var].type & MAY_BE_REF) in zend_dfa_optimize_op_array()
1549 && (ssa->var_info[src_var].type & (MAY_BE_UNDEF|MAY_BE_ANY)) in zend_dfa_optimize_op_array()
1550 && ssa->vars[src_var].definition >= 0 in zend_dfa_optimize_op_array()
1551 && ssa->ops[ssa->vars[src_var].definition].result_def == src_var in zend_dfa_optimize_op_array()
1552 && ssa->ops[ssa->vars[src_var].definition].result_use < 0 in zend_dfa_optimize_op_array()
1553 && ssa->vars[src_var].use_chain == op_1 in zend_dfa_optimize_op_array()
1554 && ssa->ops[op_1].op2_use_chain < 0 in zend_dfa_optimize_op_array()
1555 && !ssa->vars[src_var].phi_use_chain in zend_dfa_optimize_op_array()
1556 && !ssa->vars[src_var].sym_use_chain in zend_dfa_optimize_op_array()
1558 op_array, ssa, &op_array->opcodes[ssa->vars[src_var].definition], in zend_dfa_optimize_op_array()
1560 && !variable_defined_or_used_in_range(ssa, EX_VAR_TO_NUM(opline->op1.var), in zend_dfa_optimize_op_array()
1561 ssa->vars[src_var].definition+1, op_1) in zend_dfa_optimize_op_array()
1564 int op_2 = ssa->vars[src_var].definition; in zend_dfa_optimize_op_array()
1569 if (zend_ssa_unlink_use_chain(ssa, op_1, orig_var)) { in zend_dfa_optimize_op_array()
1571 ssa->vars[v].definition = op_2; in zend_dfa_optimize_op_array()
1572 ssa->ops[op_2].result_def = v; in zend_dfa_optimize_op_array()
1574 ssa->vars[src_var].definition = -1; in zend_dfa_optimize_op_array()
1575 ssa->vars[src_var].use_chain = -1; in zend_dfa_optimize_op_array()
1577 ssa->ops[op_1].op1_use = -1; in zend_dfa_optimize_op_array()
1578 ssa->ops[op_1].op2_use = -1; in zend_dfa_optimize_op_array()
1579 ssa->ops[op_1].op1_def = -1; in zend_dfa_optimize_op_array()
1580 ssa->ops[op_1].op1_use_chain = -1; in zend_dfa_optimize_op_array()
1595 && ssa->ops[op_2].op1_use >= 0 in zend_dfa_optimize_op_array()
1596 …&& !(ssa->var_info[ssa->ops[op_2].op1_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1602 ssa->ops[op_2].result_def = -1; in zend_dfa_optimize_op_array()
1603 ssa->ops[op_2].op1_def = v; in zend_dfa_optimize_op_array()
1611 && ssa->ops[op_2].op1_use >= 0 in zend_dfa_optimize_op_array()
1612 …&& !(ssa->var_info[ssa->ops[op_2].op1_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1618 ssa->ops[op_2].result_def = -1; in zend_dfa_optimize_op_array()
1619 ssa->ops[op_2].op1_def = v; in zend_dfa_optimize_op_array()
1627 && ssa->ops[op_2].op2_use >= 0 in zend_dfa_optimize_op_array()
1628 …&& !(ssa->var_info[ssa->ops[op_2].op2_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1636 ssa->ops[op_2].result_def = -1; in zend_dfa_optimize_op_array()
1637 ssa->ops[op_2].op1_def = v; in zend_dfa_optimize_op_array()
1638 ssa->ops[op_2].op1_use = ssa->ops[op_2].op2_use; in zend_dfa_optimize_op_array()
1639 ssa->ops[op_2].op1_use_chain = ssa->ops[op_2].op2_use_chain; in zend_dfa_optimize_op_array()
1640 ssa->ops[op_2].op2_use = -1; in zend_dfa_optimize_op_array()
1641 ssa->ops[op_2].op2_use_chain = -1; in zend_dfa_optimize_op_array()
1646 && ssa->ops[op_1].op2_use >= 0 in zend_dfa_optimize_op_array()
1647 && ssa->ops[op_1].op2_def < 0) in zend_dfa_optimize_op_array()
1652 if (ssa->ops[op_1].op1_use != ssa->ops[op_1].op2_use) { in zend_dfa_optimize_op_array()
1653 zend_ssa_unlink_use_chain(ssa, op_1, orig_var); in zend_dfa_optimize_op_array()
1655 ssa->ops[op_1].op2_use_chain = ssa->ops[op_1].op1_use_chain; in zend_dfa_optimize_op_array()
1659 ssa->ops[op_1].result_def = v; in zend_dfa_optimize_op_array()
1660 ssa->ops[op_1].op1_def = -1; in zend_dfa_optimize_op_array()
1661 ssa->ops[op_1].op1_use = ssa->ops[op_1].op2_use; in zend_dfa_optimize_op_array()
1662 ssa->ops[op_1].op1_use_chain = ssa->ops[op_1].op2_use_chain; in zend_dfa_optimize_op_array()
1663 ssa->ops[op_1].op2_use = -1; in zend_dfa_optimize_op_array()
1664 ssa->ops[op_1].op2_use_chain = -1; in zend_dfa_optimize_op_array()
1679 && ssa->ops[op_1].op1_def == v in zend_dfa_optimize_op_array()
1683 && ssa->ops[op_1].op1_use >= 0 in zend_dfa_optimize_op_array()
1684 …&& !(ssa->var_info[ssa->ops[op_1].op1_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1694 && ssa->ops[op_1].op1_def == v in zend_dfa_optimize_op_array()
1698 && ssa->ops[op_1].op1_use >= 0 in zend_dfa_optimize_op_array()
1699 …&& !(ssa->var_info[ssa->ops[op_1].op1_use].type & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TR… in zend_dfa_optimize_op_array()
1707 } else if (ssa->ops[op_1].op1_def == v in zend_dfa_optimize_op_array()
1709 && ssa->ops[op_1].op1_use >= 0 in zend_dfa_optimize_op_array()
1710 …&& !(ssa->var_info[ssa->ops[op_1].op1_use].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE… in zend_dfa_optimize_op_array()
1717 ssa->ops[op_1].result_def = ssa->ops[op_1].op1_def; in zend_dfa_optimize_op_array()
1718 ssa->ops[op_1].op1_def = -1; in zend_dfa_optimize_op_array()
1730 ssa_verify_integrity(op_array, ssa, "after dfa"); in zend_dfa_optimize_op_array()
1734 zend_ssa_remove_nops(op_array, ssa, ctx); in zend_dfa_optimize_op_array()
1736 ssa_verify_integrity(op_array, ssa, "after nop"); in zend_dfa_optimize_op_array()
1742 zend_dump_op_array(op_array, ZEND_DUMP_SSA, "after dfa pass", ssa); in zend_dfa_optimize_op_array()
1749 zend_ssa ssa; in zend_optimize_dfa() local
1751 if (zend_dfa_analyze_op_array(op_array, ctx, &ssa) != SUCCESS) { in zend_optimize_dfa()
1756 zend_dfa_optimize_op_array(op_array, ctx, &ssa, NULL); in zend_optimize_dfa()