- spill.spillslot = set_count(env->spills);
- spill.mode = mode;
- spill.alignment = align;
- DB((dbg, DBG_COALESCING, "Slot %d: %+F\n", spill.spillslot, node));
- res = (spill_t*)set_insert(env->spills, &spill, sizeof(spill), hash);
-
- /* collect attached spills and mem-phis */
- arity = get_irn_arity(node);
- for (i = 0; i < arity; ++i) {
- affinity_edge_t *affinty_edge;
- ir_node *arg = get_irn_n(node, i);
- spill_t *arg_spill;
-
- if (is_Phi(arg)) {
- arg_spill = collect_memphi(env, arg, mode, align);
- } else {
- arg_spill = collect_spill(env, arg, mode, align);
+ spill = OALLOC(&env->obst, spill_t);
+ /* insert into set of spills if not already there */
+ spill->spill = node;
+ spill->mode = mode;
+ spill->alignment = align;
+ spill->spillslot = (int)ARR_LEN(env->spills);
+ ARR_APP1(spill_t*, env->spills, spill);
+ set_irn_link(node, spill);
+ DB((dbg, DBG_COALESCING, "Slot %d: %+F\n", spill->spillslot, node));
+
+ if (is_Phi(node)) {
+ const ir_exec_freq *exec_freq = be_get_irg_exec_freq(env->irg);
+ int arity = get_irn_arity(node);
+ int i;
+ for (i = 0; i < arity; ++i) {
+ affinity_edge_t *affinty_edge;
+ ir_node *arg = get_irn_n(node, i);
+ spill_t *arg_spill = collect_spill(env, arg, mode, align);
+ ir_node *block = get_nodes_block(arg);
+
+ /* add an affinity edge */
+ affinty_edge = OALLOC(&env->obst, affinity_edge_t);
+ affinty_edge->affinity = get_block_execfreq(exec_freq, block);
+ affinty_edge->slot1 = spill->spillslot;
+ affinty_edge->slot2 = arg_spill->spillslot;
+ ARR_APP1(affinity_edge_t*, env->affinity_edges, affinty_edge);