- /* copy the best ones to the ws */
- count = MIN(count, ws->bel->n_regs);
- workset_bulk_fill(ws, count, starters);
+ /* Create the start workset for this block. Copy the best ones from starters */
+ blk_info = obstack_alloc(&bel->ob, sizeof(*blk_info));
+ set_irn_link(blk, blk_info);
+
+ ws_count = MIN(count, bel->n_regs);
+ blk_info->ws_start = new_workset(&bel->ob, bel);
+ workset_bulk_fill(blk_info->ws_start, ws_count, starters);
+
+ /* Spill the phis among the remaining values */
+ for (i=ws_count; i<count; ++i) {
+ int o, max;
+
+ irn = starters[i].irn;
+ if (!is_Phi(irn) || get_nodes_block(irn) != blk)
+ continue;
+
+ DBG((dbg, DBG_START, "For %+F:\n", irn));
+
+ for (max=get_irn_arity(irn), o=0; o<max; ++o) {
+ ir_node *arg = get_irn_n(irn, o);
+ ir_node *pred_block = get_Block_cfgpred_block(get_nodes_block(irn), o);
+ ir_node *cpy = be_new_Copy(bel->cls, irg, pred_block, arg);
+ pset_insert_ptr(bel->copies, cpy);
+ DBG((dbg, DBG_START, " place a %+F of %+F in %+F\n", cpy, arg, pred_block));
+ sched_add_before(pred_block, cpy);
+ set_irn_n(irn, o, cpy);
+ }
+ }