Lines Matching refs:ssa

61 static zend_bool needs_pi(const zend_op_array *op_array, zend_dfg *dfg, zend_ssa *ssa, int from, in…  in needs_pi()  argument
73 from_block = &ssa->cfg.blocks[from]; in needs_pi()
79 to_block = &ssa->cfg.blocks[to]; in needs_pi()
89 return !will_rejoin(&ssa->cfg, dfg, to_block, other_successor, from, var); in needs_pi()
94 zend_arena **arena, const zend_op_array *op_array, zend_dfg *dfg, zend_ssa *ssa, in add_pi() argument
98 if (!needs_pi(op_array, dfg, ssa, from, to, var)) { in add_pi()
104 ZEND_MM_ALIGNED_SIZE(sizeof(int) * ssa->cfg.blocks[to].predecessors_count) + in add_pi()
105 sizeof(void*) * ssa->cfg.blocks[to].predecessors_count); in add_pi()
107 memset(phi->sources, 0xff, sizeof(int) * ssa->cfg.blocks[to].predecessors_count); in add_pi()
108 …phi->use_chains = (zend_ssa_phi**)(((char*)phi->sources) + ZEND_MM_ALIGNED_SIZE(sizeof(int) * ssa-… in add_pi()
113 phi->next = ssa->blocks[to].phis; in add_pi()
114 ssa->blocks[to].phis = phi; in add_pi()
124 if (ssa->cfg.blocks[to].predecessors_count > 1) { in add_pi()
244 uint32_t build_flags, zend_ssa *ssa, zend_dfg *dfg) /* {{{ */ { in place_essa_pis() argument
245 zend_basic_block *blocks = ssa->cfg.blocks; in place_essa_pis()
246 int j, blocks_count = ssa->cfg.blocks_count; in place_essa_pis()
272 if ((pi = add_pi(arena, op_array, dfg, ssa, j, blocks[j].successors[0], var))) { in place_essa_pis()
280 if ((pi = add_pi(arena, op_array, dfg, ssa, j, blocks[j].successors[1], var))) { in place_essa_pis()
370 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var1))) { in place_essa_pis()
373 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var1))) { in place_essa_pis()
377 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var1))) { in place_essa_pis()
380 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var1))) { in place_essa_pis()
385 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var1))) { in place_essa_pis()
389 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var1))) { in place_essa_pis()
393 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var1))) { in place_essa_pis()
397 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var1))) { in place_essa_pis()
405 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var2))) { in place_essa_pis()
408 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var2))) { in place_essa_pis()
412 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var2))) { in place_essa_pis()
415 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var2))) { in place_essa_pis()
420 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var2))) { in place_essa_pis()
424 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var2))) { in place_essa_pis()
428 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var2))) { in place_essa_pis()
432 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var2))) { in place_essa_pis()
446 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var))) { in place_essa_pis()
449 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var))) { in place_essa_pis()
453 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var))) { in place_essa_pis()
456 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var))) { in place_essa_pis()
467 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var))) { in place_essa_pis()
471 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var))) { in place_essa_pis()
478 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var))) { in place_essa_pis()
483 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var))) { in place_essa_pis()
512 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var))) { in place_essa_pis()
515 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var))) { in place_essa_pis()
519 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bf, var))) { in place_essa_pis()
522 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var))) { in place_essa_pis()
539 if ((pi = add_pi(arena, op_array, dfg, ssa, j, bt, var))) { in place_essa_pis()
794 static int zend_ssa_rename(const zend_op_array *op_array, uint32_t build_flags, zend_ssa *ssa, int … in zend_ssa_rename() argument
796 zend_basic_block *blocks = ssa->cfg.blocks; in zend_ssa_rename()
797 zend_ssa_block *ssa_blocks = ssa->blocks; in zend_ssa_rename()
798 zend_ssa_op *ssa_ops = ssa->ops; in zend_ssa_rename()
799 int ssa_vars_count = ssa->vars_count; in zend_ssa_rename()
863 if (ssa->cfg.predecessors[blocks[succ].predecessor_offset + j] == n) { in zend_ssa_rename()
880 if (ssa->cfg.predecessors[blocks[succ].predecessor_offset + j] == n) { in zend_ssa_rename()
893 ssa->vars_count = ssa_vars_count; in zend_ssa_rename()
898 if (zend_ssa_rename(op_array, build_flags, ssa, var, j) != SUCCESS) in zend_ssa_rename()
911 … zend_script *script, const zend_op_array *op_array, uint32_t build_flags, zend_ssa *ssa) /* {{{ */ in zend_build_ssa() argument
913 zend_basic_block *blocks = ssa->cfg.blocks; in zend_build_ssa()
915 int blocks_count = ssa->cfg.blocks_count; in zend_build_ssa()
930 ssa->blocks = ssa_blocks; in zend_build_ssa()
942 if (zend_build_dfg(op_array, &ssa->cfg, &dfg, build_flags) != SUCCESS) { in zend_build_ssa()
948 zend_dump_dfg(op_array, &ssa->cfg, &dfg); in zend_build_ssa()
960 place_essa_pis(arena, script, op_array, build_flags, ssa, &dfg); in zend_build_ssa()
978 i = ssa->cfg.predecessors[blocks[j].predecessor_offset + k]; in zend_build_ssa()
1014 …zend_ssa_phi**)(((char*)phi->sources) + ZEND_MM_ALIGNED_SIZE(sizeof(int) * ssa->cfg.blocks[j].pred… in zend_build_ssa()
1037 zend_dump_phi_placement(op_array, ssa); in zend_build_ssa()
1041 ssa->ops = zend_arena_calloc(arena, op_array->last, sizeof(zend_ssa_op)); in zend_build_ssa()
1042 memset(ssa->ops, 0xff, op_array->last * sizeof(zend_ssa_op)); in zend_build_ssa()
1048 ssa->vars_count = op_array->last_var; in zend_build_ssa()
1049 if (zend_ssa_rename(op_array, build_flags, ssa, var, 0) != SUCCESS) { in zend_build_ssa()
1062 …_compute_use_def_chains(zend_arena **arena, const zend_op_array *op_array, zend_ssa *ssa) /* {{{ */ in zend_ssa_compute_use_def_chains() argument
1067 if (!ssa->vars) { in zend_ssa_compute_use_def_chains()
1068 ssa->vars = zend_arena_calloc(arena, ssa->vars_count, sizeof(zend_ssa_var)); in zend_ssa_compute_use_def_chains()
1070 ssa_vars = ssa->vars; in zend_ssa_compute_use_def_chains()
1078 for (i = op_array->last_var; i < ssa->vars_count; i++) { in zend_ssa_compute_use_def_chains()
1086 zend_ssa_op *op = ssa->ops + i; in zend_ssa_compute_use_def_chains()
1114 for (i = 0; i < ssa->cfg.blocks_count; i++) { in zend_ssa_compute_use_def_chains()
1115 zend_ssa_phi *phi = ssa->blocks[i].phis; in zend_ssa_compute_use_def_chains()
1126 p = zend_ssa_next_use_phi(ssa, phi->sources[0], p); in zend_ssa_compute_use_def_chains()
1146 for (j = 0; j < ssa->cfg.blocks[i].predecessors_count; j++) { in zend_ssa_compute_use_def_chains()
1152 p = zend_ssa_next_use_phi(ssa, phi->sources[j], p); in zend_ssa_compute_use_def_chains()
1166 if ((ssa->cfg.flags & ZEND_FUNC_INDIRECT_VAR_ACCESS)) { in zend_ssa_compute_use_def_chains()
1172 for (i = op_array->last_var; i < ssa->vars_count; i++) { in zend_ssa_compute_use_def_chains()
1182 int zend_ssa_unlink_use_chain(zend_ssa *ssa, int op, int var) /* {{{ */ in zend_ssa_unlink_use_chain() argument
1184 if (ssa->vars[var].use_chain == op) { in zend_ssa_unlink_use_chain()
1185 ssa->vars[var].use_chain = zend_ssa_next_use(ssa->ops, var, op); in zend_ssa_unlink_use_chain()
1188 int use = ssa->vars[var].use_chain; in zend_ssa_unlink_use_chain()
1191 if (ssa->ops[use].result_use == var) { in zend_ssa_unlink_use_chain()
1192 if (ssa->ops[use].res_use_chain == op) { in zend_ssa_unlink_use_chain()
1193 ssa->ops[use].res_use_chain = zend_ssa_next_use(ssa->ops, var, op); in zend_ssa_unlink_use_chain()
1196 use = ssa->ops[use].res_use_chain; in zend_ssa_unlink_use_chain()
1198 } else if (ssa->ops[use].op1_use == var) { in zend_ssa_unlink_use_chain()
1199 if (ssa->ops[use].op1_use_chain == op) { in zend_ssa_unlink_use_chain()
1200 ssa->ops[use].op1_use_chain = zend_ssa_next_use(ssa->ops, var, op); in zend_ssa_unlink_use_chain()
1203 use = ssa->ops[use].op1_use_chain; in zend_ssa_unlink_use_chain()
1205 } else if (ssa->ops[use].op2_use == var) { in zend_ssa_unlink_use_chain()
1206 if (ssa->ops[use].op2_use_chain == op) { in zend_ssa_unlink_use_chain()
1207 ssa->ops[use].op2_use_chain = zend_ssa_next_use(ssa->ops, var, op); in zend_ssa_unlink_use_chain()
1210 use = ssa->ops[use].op2_use_chain; in zend_ssa_unlink_use_chain()
1223 void zend_ssa_remove_instr(zend_ssa *ssa, zend_op *opline, zend_ssa_op *ssa_op) /* {{{ */ in zend_ssa_remove_instr() argument
1226 zend_ssa_unlink_use_chain(ssa, ssa_op - ssa->ops, ssa_op->result_use); in zend_ssa_remove_instr()
1232 zend_ssa_unlink_use_chain(ssa, ssa_op - ssa->ops, ssa_op->op1_use); in zend_ssa_remove_instr()
1240 zend_ssa_unlink_use_chain(ssa, ssa_op - ssa->ops, ssa_op->op2_use); in zend_ssa_remove_instr()
1254 static inline zend_ssa_phi **zend_ssa_next_use_phi_ptr(zend_ssa *ssa, int var, zend_ssa_phi *p) /* … in zend_ssa_next_use_phi_ptr() argument
1260 for (j = 0; j < ssa->cfg.blocks[p->block].predecessors_count; j++) { in zend_ssa_next_use_phi_ptr()
1273 static inline void zend_ssa_remove_use_of_phi_source(zend_ssa *ssa, zend_ssa_phi *phi, int source, … in zend_ssa_remove_use_of_phi_source() argument
1275 zend_ssa_phi **cur = &ssa->vars[source].phi_use_chain; in zend_ssa_remove_use_of_phi_source()
1277 cur = zend_ssa_next_use_phi_ptr(ssa, source, *cur); in zend_ssa_remove_use_of_phi_source()
1285 static void zend_ssa_remove_uses_of_phi_sources(zend_ssa *ssa, zend_ssa_phi *phi) /* {{{ */ in zend_ssa_remove_uses_of_phi_sources() argument
1289 zend_ssa_remove_use_of_phi_source(ssa, phi, source, zend_ssa_next_use_phi(ssa, source, phi)); in zend_ssa_remove_uses_of_phi_sources()
1294 static void zend_ssa_remove_phi_from_block(zend_ssa *ssa, zend_ssa_phi *phi) /* {{{ */ in zend_ssa_remove_phi_from_block() argument
1296 zend_ssa_block *block = &ssa->blocks[phi->block]; in zend_ssa_remove_phi_from_block()
1306 static inline void zend_ssa_remove_defs_of_instr(zend_ssa *ssa, zend_ssa_op *ssa_op) /* {{{ */ in zend_ssa_remove_defs_of_instr() argument
1309 zend_ssa_remove_uses_of_var(ssa, ssa_op->op1_def); in zend_ssa_remove_defs_of_instr()
1310 zend_ssa_remove_op1_def(ssa, ssa_op); in zend_ssa_remove_defs_of_instr()
1313 zend_ssa_remove_uses_of_var(ssa, ssa_op->op2_def); in zend_ssa_remove_defs_of_instr()
1314 zend_ssa_remove_op2_def(ssa, ssa_op); in zend_ssa_remove_defs_of_instr()
1317 zend_ssa_remove_uses_of_var(ssa, ssa_op->result_def); in zend_ssa_remove_defs_of_instr()
1318 zend_ssa_remove_result_def(ssa, ssa_op); in zend_ssa_remove_defs_of_instr()
1323 static inline void zend_ssa_remove_phi_source(zend_ssa *ssa, zend_ssa_phi *phi, int pred_offset, in… in zend_ssa_remove_phi_source() argument
1348 zend_ssa_remove_use_of_phi_source(ssa, phi, var_num, next_phi); in zend_ssa_remove_phi_source()
1352 void zend_ssa_remove_phi(zend_ssa *ssa, zend_ssa_phi *phi) /* {{{ */ in zend_ssa_remove_phi() argument
1355 ZEND_ASSERT(ssa->vars[phi->ssa_var].use_chain < 0 in zend_ssa_remove_phi()
1356 && ssa->vars[phi->ssa_var].phi_use_chain == NULL); in zend_ssa_remove_phi()
1357 zend_ssa_remove_uses_of_phi_sources(ssa, phi); in zend_ssa_remove_phi()
1358 zend_ssa_remove_phi_from_block(ssa, phi); in zend_ssa_remove_phi()
1359 ssa->vars[phi->ssa_var].definition_phi = NULL; in zend_ssa_remove_phi()
1364 void zend_ssa_remove_uses_of_var(zend_ssa *ssa, int var_num) /* {{{ */ in zend_ssa_remove_uses_of_var() argument
1366 zend_ssa_var *var = &ssa->vars[var_num]; in zend_ssa_remove_uses_of_var()
1379 zend_ssa_op *ssa_op = &ssa->ops[use]; in zend_ssa_remove_uses_of_var()
1397 void zend_ssa_remove_predecessor(zend_ssa *ssa, int from, int to) /* {{{ */ in zend_ssa_remove_predecessor() argument
1399 zend_basic_block *next_block = &ssa->cfg.blocks[to]; in zend_ssa_remove_predecessor()
1400 zend_ssa_block *next_ssa_block = &ssa->blocks[to]; in zend_ssa_remove_predecessor()
1406 int *predecessors = &ssa->cfg.predecessors[next_block->predecessor_offset]; in zend_ssa_remove_predecessor()
1425 zend_ssa_rename_var_uses(ssa, phi->ssa_var, phi->sources[0], /* update_types */ 0); in zend_ssa_remove_predecessor()
1426 zend_ssa_remove_phi(ssa, phi); in zend_ssa_remove_predecessor()
1430 zend_ssa_remove_phi_source(ssa, phi, pred_offset, next_block->predecessors_count); in zend_ssa_remove_predecessor()
1437 predecessors = &ssa->cfg.predecessors[next_block->predecessor_offset + pred_offset]; in zend_ssa_remove_predecessor()
1443 void zend_ssa_remove_block(zend_op_array *op_array, zend_ssa *ssa, int i) /* {{{ */ in zend_ssa_remove_block() argument
1445 zend_basic_block *block = &ssa->cfg.blocks[i]; in zend_ssa_remove_block()
1446 zend_ssa_block *ssa_block = &ssa->blocks[i]; in zend_ssa_remove_block()
1455 zend_ssa_remove_uses_of_var(ssa, phi->ssa_var); in zend_ssa_remove_block()
1456 zend_ssa_remove_phi(ssa, phi); in zend_ssa_remove_block()
1465 zend_ssa_remove_defs_of_instr(ssa, &ssa->ops[j]); in zend_ssa_remove_block()
1466 zend_ssa_remove_instr(ssa, &op_array->opcodes[j], &ssa->ops[j]); in zend_ssa_remove_block()
1470 zend_ssa_remove_predecessor(ssa, i, block->successors[s]); in zend_ssa_remove_block()
1474 predecessors = &ssa->cfg.predecessors[block->predecessor_offset]; in zend_ssa_remove_block()
1477 zend_basic_block *prev_block = &ssa->cfg.blocks[predecessors[j]]; in zend_ssa_remove_block()
1496 j = ssa->cfg.blocks[block->idom].children; in zend_ssa_remove_block()
1498 ssa->cfg.blocks[block->idom].children = block->next_child; in zend_ssa_remove_block()
1500 while (ssa->cfg.blocks[j].next_child >= 0) { in zend_ssa_remove_block()
1501 if (ssa->cfg.blocks[j].next_child == i) { in zend_ssa_remove_block()
1502 ssa->cfg.blocks[j].next_child = block->next_child; in zend_ssa_remove_block()
1505 j = ssa->cfg.blocks[j].next_child; in zend_ssa_remove_block()
1516 static void propagate_phi_type_widening(zend_ssa *ssa, int var) /* {{{ */ in propagate_phi_type_widening() argument
1519 FOREACH_PHI_USE(&ssa->vars[var], phi) { in propagate_phi_type_widening()
1520 if (ssa->var_info[var].type & ~ssa->var_info[phi->ssa_var].type) { in propagate_phi_type_widening()
1521 ssa->var_info[phi->ssa_var].type |= ssa->var_info[var].type; in propagate_phi_type_widening()
1522 propagate_phi_type_widening(ssa, phi->ssa_var); in propagate_phi_type_widening()
1528 void zend_ssa_rename_var_uses(zend_ssa *ssa, int old, int new, zend_bool update_types) /* {{{ */ in zend_ssa_rename_var_uses() argument
1530 zend_ssa_var *old_var = &ssa->vars[old]; in zend_ssa_rename_var_uses()
1531 zend_ssa_var *new_var = &ssa->vars[new]; in zend_ssa_rename_var_uses()
1543 zend_ssa_op *ssa_op = &ssa->ops[use]; in zend_ssa_rename_var_uses()
1604 for (j = 0; j < ssa->cfg.blocks[phi->block].predecessors_count; j++) { in zend_ssa_rename_var_uses()
1611 for (j = 0; j < ssa->cfg.blocks[phi->block].predecessors_count; j++) { in zend_ssa_rename_var_uses()
1638 if (update_types && (ssa->var_info[new].type & ~ssa->var_info[phi->ssa_var].type)) { in zend_ssa_rename_var_uses()
1639 ssa->var_info[phi->ssa_var].type |= ssa->var_info[new].type; in zend_ssa_rename_var_uses()
1640 propagate_phi_type_widening(ssa, phi->ssa_var); in zend_ssa_rename_var_uses()