-static ir_node *spill_phi(belady_env_t *bel, ir_node *phi, ir_node *ctx_irn) {
- int i, n = get_irn_arity(phi);
- ir_node **ins, *bl = get_nodes_block(phi);
- ir_graph *irg = get_irn_irg(bl);
- spill_ctx_t *ctx;
-
- assert(is_Phi(phi));
- DBG((dbg, DBG_SPILL, "spill_phi %+F\n", phi));
-
- /* search an existing spill for this context */
- ctx = get_spill_ctx(bel->spill_ctxs, phi, ctx_irn);
-
- /* if not found spill the phi */
- if(!ctx->spill) {
- /* build a new PhiM with dummy in-array */
- ins = malloc(n * sizeof(ins[0]));
- for(i=0; i<n; ++i)
- ins[i] = new_r_Unknown(irg, mode_M);
- ctx->spill = new_r_Phi(bel->session->irg, bl, n, ins, mode_M);
- free(ins);
-
- /* re-wire the phiM */
- for(i=0; i<n; ++i) {
- ir_node *arg = get_irn_n(phi, i);
- ir_node *sub_res;
-
- if(is_Phi(arg) && pset_find_ptr(bel->mem_phis, arg))
- sub_res = spill_phi(bel, arg, ctx_irn);
- else
- sub_res = spill_irn(bel, arg, ctx_irn);
-
- set_irn_n(ctx->spill, i, sub_res);
- }
- }
- return ctx->spill;
-}
-
-static ir_node *spill_node(belady_env_t *bel, ir_node *to_spill) {
- ir_node *res;
- if (pset_find_ptr(bel->mem_phis, to_spill))
- res = spill_phi(bel, to_spill, to_spill);
- else
- res = spill_irn(bel, to_spill, to_spill);
-
- return res;
+static void rescue_used_reloads(ir_node *irn, void *env) {
+ pset *rlds = (pset *)env;
+ if (pset_find_ptr(rlds, irn))
+ pset_remove_ptr(rlds, irn);