+ /* We have to place copy nodes in the predecessor blocks to temporarily
+ * produce new values that get separate spill slots
+ */
+ for(i = 0, arity = get_irn_arity(node); i < arity; ++i) {
+ ir_node *pred_block, *arg, *copy, *insert_point;
+
+ /* Don't do anything for looping edges (there's no need
+ * and placing copies here breaks stuff as it suddenly
+ * generates new living values through the whole loop)
+ */
+ arg = get_irn_n(node, i);
+ if(arg == node)
+ continue;
+
+ pred_block = get_Block_cfgpred_block(get_nodes_block(node), i);
+ copy = be_new_Copy(env->cls, get_irn_irg(arg), pred_block, arg);
+
+ ARR_APP1(ir_node*, env->copies, copy);
+ insert_point = find_last_use_def(env, pred_block, arg);
+ sched_add_before(insert_point, copy);
+
+ set_irn_n(node, i, copy);
+ }
+}
+
+void be_place_copies(spill_env_t *env) {
+ ir_node *node;
+
+ foreach_pset(env->mem_phis, node) {
+ place_copies_for_phi(env, node);
+ }
+}
+
+void be_spill_phi(spill_env_t *env, ir_node *node) {
+ spill_ctx_t *spill_ctx;
+
+ assert(is_Phi(node));
+
+ pset_insert_ptr(env->mem_phis, node);
+
+ // remove spill context for this phi (if there was one)
+ spill_ctx = be_get_spill_ctx(env->spill_ctxs, node, node);
+ if(spill_ctx != NULL) {
+ spill_ctx->spill = NULL;
+ }
+}
+
+void be_insert_spills_reloads(spill_env_t *env) {
+ const arch_env_t *arch_env = env->chordal_env->birg->main_env->arch_env;
+ //ir_node *node;
+ spill_info_t *si;
+
+#if 0
+ // Matze: This should be pointless as beladies fix_block_borders
+ // should result in the same
+ DBG((env->dbg, LEVEL_1, "Reloads for mem-phis:\n"));
+ foreach_pset(env->mem_phis, node) {