fix wrong assert, expor copy_node_attr function to public API
[libfirm] / ir / be / bespill.c
index 04c8860..9e0db49 100644 (file)
@@ -445,7 +445,7 @@ static void spill_irn(spill_env_t *env, spill_info_t *spillinfo)
                after = skip_keeps_phis(after);
 
                spill->spill = be_spill(block, to_spill);
-               sched_add_after(after, spill->spill);
+               sched_add_after(skip_Proj(after), spill->spill);
                DB((dbg, LEVEL_1, "\t%+F after %+F\n", spill->spill, after));
 #ifdef FIRM_STATISTICS
                env->spill_count++;
@@ -483,7 +483,7 @@ static void spill_phi(spill_env_t *env, spill_info_t *spillinfo)
 
        /* build a new PhiM */
        arity   = get_irn_arity(phi);
-       ins     = alloca(sizeof(ir_node*) * arity);
+       ins     = ALLOCAN(ir_node*, arity);
        unknown = new_r_Unknown(irg, mode_M);
        for(i = 0; i < arity; ++i) {
                ins[i] = unknown;
@@ -562,39 +562,19 @@ static int is_value_available(spill_env_t *env, const ir_node *arg,
        if(arg == get_irg_frame(env->irg))
                return 1;
 
+#if 0
        /* hack for now (happens when command should be inserted at end of block) */
-       if(is_Block(reloader)) {
+       if(is_Block(reloader))
                return 0;
-       }
+#else
+       (void)reloader;
+#endif
 
        /*
         * Ignore registers are always available
         */
-       if (arch_irn_is(arg, ignore)) {
+       if (arch_irn_is_ignore(arg))
                return 1;
-       }
-
-       /* the following test does not work while spilling,
-        * because the liveness info is not adapted yet to the effects of the
-        * additional spills/reloads.
-        */
-#if 0
-       /* we want to remat before the insn reloader
-        * thus an arguments is alive if
-        *   - it interferes with the reloaders result
-        *   - or it is (last-) used by reloader itself
-        */
-       if (values_interfere(env->birg->lv, reloader, arg)) {
-               return 1;
-       }
-
-       arity = get_irn_arity(reloader);
-       for (i = 0; i < arity; ++i) {
-               ir_node *rel_arg = get_irn_n(reloader, i);
-               if (rel_arg == arg)
-                       return 1;
-       }
-#endif
 
        return 0;
 }
@@ -640,6 +620,10 @@ static int check_remat_conditions_costs(spill_env_t *env,
        if(parentcosts + costs >= env->reload_cost + env->spill_cost) {
                return REMAT_COST_INFINITE;
        }
+       /* never rematerialize a node which modifies the flags.
+        * (would be better to test wether the flags are actually live at point
+        * reloader...)
+        */
        if (arch_irn_is(spilled, modify_flags)) {
                return REMAT_COST_INFINITE;
        }
@@ -689,7 +673,7 @@ static ir_node *do_remat(spill_env_t *env, ir_node *spilled, ir_node *reloader)
                bl = get_nodes_block(reloader);
        }
 
-       ins = alloca(get_irn_arity(spilled) * sizeof(ins[0]));
+       ins = ALLOCAN(ir_node*, get_irn_arity(spilled));
        for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
                ir_node *arg = get_irn_n(spilled, i);