sparc: fix bitopcc bugs
[libfirm] / ir / be / bespillutil.c
index c63914f..1aeb1a1 100644 (file)
@@ -52,7 +52,7 @@
 #include "bespill.h"
 #include "bespillutil.h"
 #include "belive_t.h"
-#include "benode_t.h"
+#include "benode.h"
 #include "bechordal_t.h"
 #include "bestatevent.h"
 #include "bessaconstr.h"
@@ -98,7 +98,6 @@ struct spill_env_t {
        const arch_env_t *arch_env;
        ir_graph         *irg;
        struct obstack    obst;
-       be_irg_t         *birg;
        int               spill_cost;     /**< the cost of a single spill node */
        int               reload_cost;    /**< the cost of a reload node */
        set              *spills;         /**< all spill_info_t's, which must be
@@ -148,19 +147,18 @@ static spill_info_t *get_spillinfo(const spill_env_t *env, ir_node *value)
        return res;
 }
 
-spill_env_t *be_new_spill_env(be_irg_t *birg)
+spill_env_t *be_new_spill_env(ir_graph *irg)
 {
-       const arch_env_t *arch_env = birg->main_env->arch_env;
+       const arch_env_t *arch_env = be_get_irg_arch_env(irg);
 
        spill_env_t *env = XMALLOC(spill_env_t);
        env->spills                     = new_set(cmp_spillinfo, 1024);
-       env->irg            = be_get_birg_irg(birg);
-       env->birg           = birg;
+       env->irg            = irg;
        env->arch_env       = arch_env;
        ir_nodeset_init(&env->mem_phis);
        env->spill_cost     = arch_env->spill_cost;
        env->reload_cost    = arch_env->reload_cost;
-       env->exec_freq      = be_get_birg_exec_freq(birg);
+       env->exec_freq      = be_get_irg_exec_freq(irg);
        obstack_init(&env->obst);
 
 #ifdef FIRM_STATISTICS
@@ -192,12 +190,12 @@ void be_delete_spill_env(spill_env_t *env)
 
 void be_add_spill(spill_env_t *env, ir_node *to_spill, ir_node *after)
 {
-       spill_info_t *spill_info = get_spillinfo(env, to_spill);
-       spill_t      *spill;
-       spill_t      *s;
-       spill_t      *last;
+       spill_info_t  *spill_info = get_spillinfo(env, to_spill);
+       spill_t       *spill;
+       spill_t       *s;
+       spill_t       *last;
 
-       assert(!arch_irn_is(to_spill, dont_spill));
+       assert(!arch_irn_is(skip_Proj_const(to_spill), dont_spill));
        DB((dbg, LEVEL_1, "Add spill of %+F after %+F\n", to_spill, after));
 
        /* Just for safety make sure that we do not insert the spill in front of a phi */
@@ -206,16 +204,16 @@ void be_add_spill(spill_env_t *env, ir_node *to_spill, ir_node *after)
        /* spills that are dominated by others are not needed */
        last = NULL;
        s    = spill_info->spills;
-       for( ; s != NULL; s = s->next) {
+       for ( ; s != NULL; s = s->next) {
                /* no need to add this spill if it is dominated by another */
-               if(value_dominates(s->after, after)) {
+               if (value_dominates(s->after, after)) {
                        DB((dbg, LEVEL_1, "...dominated by %+F, not added\n", s->after));
                        return;
                }
                /* remove spills that we dominate */
-               if(value_dominates(after, s->after)) {
+               if (value_dominates(after, s->after)) {
                        DB((dbg, LEVEL_1, "...remove old spill at %+F\n", s->after));
-                       if(last != NULL) {
+                       if (last != NULL) {
                                last->next         = s->next;
                        } else {
                                spill_info->spills = s->next;
@@ -225,7 +223,7 @@ void be_add_spill(spill_env_t *env, ir_node *to_spill, ir_node *after)
                }
        }
 
-       spill         = obstack_alloc(&env->obst, sizeof(spill[0]));
+       spill         = OALLOC(&env->obst, spill_t);
        spill->after  = after;
        spill->next   = spill_info->spills;
        spill->spill  = NULL;
@@ -242,7 +240,7 @@ void be_add_remat(spill_env_t *env, ir_node *to_spill, ir_node *before,
        spill_info = get_spillinfo(env, to_spill);
 
        /* add the remat information */
-       reloader                   = obstack_alloc(&env->obst, sizeof(reloader[0]));
+       reloader                   = OALLOC(&env->obst, reloader_t);
        reloader->next             = spill_info->reloaders;
        reloader->reloader         = before;
        reloader->rematted_node    = rematted_node;
@@ -260,10 +258,10 @@ void be_add_reload2(spill_env_t *env, ir_node *to_spill, ir_node *before,
                ir_node *can_spill_after, const arch_register_class_t *reload_cls,
                int allow_remat)
 {
-       spill_info_t *info;
-       reloader_t *rel;
+       spill_info_t  *info;
+       reloader_t    *rel;
 
-       assert(!arch_irn_is(to_spill, dont_spill));
+       assert(!arch_irn_is(skip_Proj_const(to_spill), dont_spill));
 
        info = get_spillinfo(env, to_spill);
 
@@ -280,7 +278,7 @@ void be_add_reload2(spill_env_t *env, ir_node *to_spill, ir_node *before,
        assert(!is_Proj(before) && !be_is_Keep(before));
 
        /* put reload into list */
-       rel                   = obstack_alloc(&env->obst, sizeof(rel[0]));
+       rel                   = OALLOC(&env->obst, reloader_t);
        rel->next             = info->reloaders;
        rel->reloader         = before;
        rel->rematted_node    = NULL;
@@ -320,9 +318,9 @@ ir_node *be_get_end_of_block_insertion_point(const ir_node *block)
 
 static ir_node *skip_keeps_phis(ir_node *node)
 {
-       while(true) {
+       while (true) {
                ir_node *next = sched_next(node);
-               if(!is_Phi(next) && !be_is_Keep(next))
+               if (!is_Phi(next) && !be_is_Keep(next) && !be_is_CopyKeep(next))
                        break;
                node = next;
        }
@@ -340,7 +338,7 @@ static ir_node *get_block_insertion_point(ir_node *block, int pos)
        /* simply add the reload to the beginning of the block if we only have 1
         * predecessor. We don't need to check for phis as there can't be any in a
         * block with only 1 pred. */
-       if(get_Block_n_cfgpreds(block) == 1) {
+       if (get_Block_n_cfgpreds(block) == 1) {
                assert(!is_Phi(sched_first(block)));
                return sched_first(block);
        }
@@ -370,7 +368,6 @@ void be_add_reload_on_edge(spill_env_t *env, ir_node *to_spill, ir_node *block,
 void be_spill_phi(spill_env_t *env, ir_node *node)
 {
        ir_node *block;
-       spill_info_t* spill;
        int i, arity;
 
        assert(is_Phi(node));
@@ -379,15 +376,13 @@ void be_spill_phi(spill_env_t *env, ir_node *node)
 
        /* create spills for the phi arguments */
        block = get_nodes_block(node);
-       spill = get_spillinfo(env, node);
-       for(i = 0, arity = get_irn_arity(node); i < arity; ++i) {
+       for (i = 0, arity = get_irn_arity(node); i < arity; ++i) {
                ir_node *arg = get_irn_n(node, i);
                ir_node *insert;
-               //get_spillinfo(env, arg);
 
                /* some backends have virtual noreg/unknown nodes that are not scheduled
                 * and simply always available. */
-               if(!sched_is_scheduled(arg)) {
+               if (!sched_is_scheduled(arg)) {
                        ir_node *pred_block = get_Block_cfgpred_block(block, i);
                        insert = be_get_end_of_block_insertion_point(pred_block);
                        insert = sched_prev(insert);
@@ -421,7 +416,8 @@ static void determine_spill_costs(spill_env_t *env, spill_info_t *spillinfo);
  */
 static void spill_irn(spill_env_t *env, spill_info_t *spillinfo)
 {
-       ir_node *to_spill = spillinfo->to_spill;
+       ir_node       *to_spill = spillinfo->to_spill;
+       const ir_node *insn     = skip_Proj_const(to_spill);
        spill_t *spill;
 
        /* determine_spill_costs must have been run before */
@@ -429,7 +425,7 @@ static void spill_irn(spill_env_t *env, spill_info_t *spillinfo)
 
        /* some backends have virtual noreg/unknown nodes that are not scheduled
         * and simply always available. */
-       if(!sched_is_scheduled(to_spill)) {
+       if (!sched_is_scheduled(insn)) {
                /* override spillinfos or create a new one */
                spillinfo->spills->spill = new_NoMem();
                DB((dbg, LEVEL_1, "don't spill %+F use NoMem\n", to_spill));
@@ -438,7 +434,7 @@ static void spill_irn(spill_env_t *env, spill_info_t *spillinfo)
 
        DBG((dbg, LEVEL_1, "spilling %+F ... \n", to_spill));
        spill = spillinfo->spills;
-       for( ; spill != NULL; spill = spill->next) {
+       for ( ; spill != NULL; spill = spill->next) {
                ir_node *after = spill->after;
                ir_node *block = get_block(after);
 
@@ -485,12 +481,12 @@ static void spill_phi(spill_env_t *env, spill_info_t *spillinfo)
        arity   = get_irn_arity(phi);
        ins     = ALLOCAN(ir_node*, arity);
        unknown = new_r_Unknown(irg, mode_M);
-       for(i = 0; i < arity; ++i) {
+       for (i = 0; i < arity; ++i) {
                ins[i] = unknown;
        }
 
        /* override or replace spills list... */
-       spill         = obstack_alloc(&env->obst, sizeof(spill[0]));
+       spill         = OALLOC(&env->obst, spill_t);
        spill->after  = skip_keeps_phis(phi);
        spill->spill  = new_r_Phi(block, arity, ins, mode_M);
        spill->next   = NULL;
@@ -500,7 +496,7 @@ static void spill_phi(spill_env_t *env, spill_info_t *spillinfo)
        env->spilled_phi_count++;
 #endif
 
-       for(i = 0; i < arity; ++i) {
+       for (i = 0; i < arity; ++i) {
                ir_node      *arg      = get_irn_n(phi, i);
                spill_info_t *arg_info = get_spillinfo(env, arg);
 
@@ -524,7 +520,7 @@ static void spill_node(spill_env_t *env, spill_info_t *spillinfo)
        ir_node *to_spill;
 
        /* node is already spilled */
-       if(spillinfo->spills != NULL && spillinfo->spills->spill != NULL)
+       if (spillinfo->spills != NULL && spillinfo->spills->spill != NULL)
                return;
 
        to_spill = spillinfo->to_spill;
@@ -553,22 +549,19 @@ static void spill_node(spill_env_t *env, spill_info_t *spillinfo)
 static int is_value_available(spill_env_t *env, const ir_node *arg,
                               const ir_node *reloader)
 {
-       if(is_Unknown(arg) || arg == new_NoMem())
+       if (is_Unknown(arg) || arg == new_NoMem())
                return 1;
 
-       if(be_is_Spill(arg))
+       if (be_is_Spill(skip_Proj_const(arg)))
                return 1;
 
-       if(arg == get_irg_frame(env->irg))
+       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))
-               return 0;
-#else
        (void)reloader;
-#endif
+
+       if (get_irn_mode(arg) == mode_T)
+               return 0;
 
        /*
         * Ignore registers are always available
@@ -579,19 +572,6 @@ static int is_value_available(spill_env_t *env, const ir_node *arg,
        return 0;
 }
 
-/**
- * Checks whether the node can principally be rematerialized
- */
-static int is_remat_node(const ir_node *node)
-{
-       assert(!be_is_Spill(node));
-
-       if (arch_irn_is(node, rematerializable))
-               return 1;
-
-       return 0;
-}
-
 /**
  * Check if a node is rematerializable. This tests for the following conditions:
  *
@@ -608,45 +588,46 @@ static int check_remat_conditions_costs(spill_env_t *env,
        int i, arity;
        int argremats;
        int costs = 0;
+       const ir_node *insn = skip_Proj_const(spilled);
 
-       if (!is_remat_node(spilled))
+       assert(!be_is_Spill(insn));
+       if (!arch_irn_is(insn, rematerializable))
                return REMAT_COST_INFINITE;
 
-       if(be_is_Reload(spilled)) {
+       if (be_is_Reload(insn)) {
                costs += 2;
        } else {
-               costs += arch_get_op_estimated_cost(spilled);
+               costs += arch_get_op_estimated_cost(insn);
        }
-       if(parentcosts + costs >= env->reload_cost + env->spill_cost) {
+       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)) {
+       if (arch_irn_is(insn, modify_flags)) {
                return REMAT_COST_INFINITE;
        }
 
        argremats = 0;
-       for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
-               ir_node *arg = get_irn_n(spilled, i);
+       for (i = 0, arity = get_irn_arity(insn); i < arity; ++i) {
+               ir_node *arg = get_irn_n(insn, i);
 
-               if(is_value_available(env, arg, reloader))
+               if (is_value_available(env, arg, reloader))
                        continue;
 
                /* we have to rematerialize the argument as well */
-               if(argremats >= 1) {
+               ++argremats;
+               if (argremats > 1) {
                        /* we only support rematerializing 1 argument at the moment,
-                        * so that we don't have to care about register pressure
-                        */
+                        * as multiple arguments could increase register pressure */
                        return REMAT_COST_INFINITE;
                }
-               argremats++;
 
                costs += check_remat_conditions_costs(env, arg, reloader,
                                                      parentcosts + costs);
-               if(parentcosts + costs >= env->reload_cost + env->spill_cost)
+               if (parentcosts + costs >= env->reload_cost + env->spill_cost)
                        return REMAT_COST_INFINITE;
        }
 
@@ -667,17 +648,17 @@ static ir_node *do_remat(spill_env_t *env, ir_node *spilled, ir_node *reloader)
        ir_node *bl;
        ir_node **ins;
 
-       if(is_Block(reloader)) {
+       if (is_Block(reloader)) {
                bl = reloader;
        } else {
                bl = get_nodes_block(reloader);
        }
 
        ins = ALLOCAN(ir_node*, get_irn_arity(spilled));
-       for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
+       for (i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
                ir_node *arg = get_irn_n(spilled, i);
 
-               if(is_value_available(env, arg, reloader)) {
+               if (is_value_available(env, arg, reloader)) {
                        ins[i] = arg;
                } else {
                        ins[i] = do_remat(env, arg, reloader);
@@ -692,9 +673,8 @@ static ir_node *do_remat(spill_env_t *env, ir_node *spilled, ir_node *reloader)
        res = new_ir_node(get_irn_dbg_info(spilled), env->irg, bl,
                          get_irn_op(spilled), get_irn_mode(spilled),
                          get_irn_arity(spilled), ins);
-       copy_node_attr(spilled, res);
+       copy_node_attr(env->irg, spilled, res);
        arch_env_mark_remat(env->arch_env, res);
-       new_backedge_info(res);
 
        DBG((dbg, LEVEL_1, "Insert remat %+F of %+F before reloader %+F\n", res, spilled, reloader));
 
@@ -722,10 +702,10 @@ double be_get_spill_costs(spill_env_t *env, ir_node *to_spill, ir_node *before)
 unsigned be_get_reload_costs_no_weight(spill_env_t *env, const ir_node *to_spill,
                                        const ir_node *before)
 {
-       if(be_do_remats) {
+       if (be_do_remats) {
                /* is the node rematerializable? */
                unsigned costs = check_remat_conditions_costs(env, to_spill, before, 0);
-               if(costs < (unsigned) env->reload_cost)
+               if (costs < (unsigned) env->reload_cost)
                        return costs;
        }
 
@@ -737,10 +717,10 @@ double be_get_reload_costs(spill_env_t *env, ir_node *to_spill, ir_node *before)
        ir_node      *block = get_nodes_block(before);
        double        freq  = get_block_execfreq(env->exec_freq, block);
 
-       if(be_do_remats) {
+       if (be_do_remats) {
                /* is the node rematerializable? */
                int costs = check_remat_conditions_costs(env, to_spill, before, 0);
-               if(costs < env->reload_cost)
+               if (costs < env->reload_cost)
                        return costs * freq;
        }
 
@@ -774,26 +754,27 @@ double be_get_reload_costs_on_edge(spill_env_t *env, ir_node *to_spill,
  */
 static void determine_spill_costs(spill_env_t *env, spill_info_t *spillinfo)
 {
-       ir_node *to_spill = spillinfo->to_spill;
-       ir_node *spill_block;
-       spill_t *spill;
-       double   spill_execfreq;
+       ir_node       *to_spill = spillinfo->to_spill;
+       const ir_node *insn     = skip_Proj_const(to_spill);
+       ir_node       *spill_block;
+       spill_t       *spill;
+       double         spill_execfreq;
 
        /* already calculated? */
-       if(spillinfo->spill_costs >= 0)
+       if (spillinfo->spill_costs >= 0)
                return;
 
-       assert(!arch_irn_is(to_spill, dont_spill));
-       assert(!be_is_Reload(to_spill));
+       assert(!arch_irn_is(insn, dont_spill));
+       assert(!be_is_Reload(insn));
 
        /* some backends have virtual noreg/unknown nodes that are not scheduled
         * and simply always available.
         * TODO: this is kinda hairy, the NoMem is correct for an Unknown as Phi
         * predecessor (of a PhiM) but this test might match other things too...
         */
-       if(!sched_is_scheduled(to_spill)) {
+       if (!sched_is_scheduled(insn)) {
                /* override spillinfos or create a new one */
-               spill_t *spill = obstack_alloc(&env->obst, sizeof(spill[0]));
+               spill_t *spill = OALLOC(&env->obst, spill_t);
                spill->after = NULL;
                spill->next  = NULL;
                spill->spill = new_NoMem();
@@ -805,7 +786,7 @@ static void determine_spill_costs(spill_env_t *env, spill_info_t *spillinfo)
                return;
        }
 
-       spill_block    = get_nodes_block(to_spill);
+       spill_block    = get_nodes_block(insn);
        spill_execfreq = get_block_execfreq(env->exec_freq, spill_block);
 
        if (is_Phi(to_spill) && ir_nodeset_contains(&env->mem_phis, to_spill)) {
@@ -815,14 +796,14 @@ static void determine_spill_costs(spill_env_t *env, spill_info_t *spillinfo)
                return;
        }
 
-       if(spillinfo->spills != NULL) {
+       if (spillinfo->spills != NULL) {
                spill_t *s;
                double   spills_execfreq;
 
                /* calculate sum of execution frequencies of individual spills */
                spills_execfreq = 0;
                s               = spillinfo->spills;
-               for( ; s != NULL; s = s->next) {
+               for ( ; s != NULL; s = s->next) {
                        ir_node *spill_block = get_block(s->after);
                        double   freq = get_block_execfreq(env->exec_freq, spill_block);
 
@@ -834,7 +815,7 @@ static void determine_spill_costs(spill_env_t *env, spill_info_t *spillinfo)
                    spill_execfreq * env->spill_cost));
 
                /* multi-/latespill is advantageous -> return*/
-               if(spills_execfreq < spill_execfreq) {
+               if (spills_execfreq < spill_execfreq) {
                        DB((dbg, LEVEL_1, "use latespills for %+F\n", to_spill));
                        spillinfo->spill_costs = spills_execfreq * env->spill_cost;
                        return;
@@ -842,7 +823,7 @@ static void determine_spill_costs(spill_env_t *env, spill_info_t *spillinfo)
        }
 
        /* override spillinfos or create a new one */
-       spill        = obstack_alloc(&env->obst, sizeof(spill[0]));
+       spill        = OALLOC(&env->obst, spill_t);
        spill->after = skip_keeps_phis(to_spill);
        spill->next  = NULL;
        spill->spill = NULL;
@@ -893,7 +874,7 @@ void be_insert_spills_reloads(spill_env_t *env)
        ir_nodeset_iterator_t  iter;
        ir_node               *node;
 
-       BE_TIMER_PUSH(t_ra_spill_apply);
+       be_timer_push(T_RA_SPILL_APPLY);
 
        /* create all phi-ms first, this is needed so, that phis, hanging on
           spilled phis work correctly */
@@ -916,7 +897,7 @@ void be_insert_spills_reloads(spill_env_t *env)
                determine_spill_costs(env, si);
 
                /* determine possibility of rematerialisations */
-               if(be_do_remats) {
+               if (be_do_remats) {
                        /* calculate cost savings for each indivial value when it would
                           be rematted instead of reloaded */
                        for (rld = si->reloaders; rld != NULL; rld = rld->next) {
@@ -926,12 +907,12 @@ void be_insert_spills_reloads(spill_env_t *env)
                                ir_node *block;
                                ir_node *reloader = rld->reloader;
 
-                               if(rld->rematted_node != NULL) {
+                               if (rld->rematted_node != NULL) {
                                        DBG((dbg, LEVEL_2, "\tforced remat %+F before %+F\n",
                                             rld->rematted_node, reloader));
                                        continue;
                                }
-                               if(rld->remat_cost_delta >= REMAT_COST_INFINITE) {
+                               if (rld->remat_cost_delta >= REMAT_COST_INFINITE) {
                                        DBG((dbg, LEVEL_2, "\treload before %+F is forbidden\n",
                                             reloader));
                                        all_remat_costs = REMAT_COST_INFINITE;
@@ -940,7 +921,7 @@ void be_insert_spills_reloads(spill_env_t *env)
 
                                remat_cost  = check_remat_conditions_costs(env, to_spill,
                                                                           reloader, 0);
-                               if(remat_cost >= REMAT_COST_INFINITE) {
+                               if (remat_cost >= REMAT_COST_INFINITE) {
                                        DBG((dbg, LEVEL_2, "\tremat before %+F not possible\n",
                                             reloader));
                                        rld->remat_cost_delta = REMAT_COST_INFINITE;
@@ -957,7 +938,7 @@ void be_insert_spills_reloads(spill_env_t *env)
                                     "%d (rel %f)\n", reloader, remat_cost_delta,
                                     remat_cost_delta * freq));
                        }
-                       if(all_remat_costs < REMAT_COST_INFINITE) {
+                       if (all_remat_costs < REMAT_COST_INFINITE) {
                                /* we don't need the costs for the spill if we can remat
                                   all reloaders */
                                all_remat_costs -= si->spill_costs;
@@ -966,7 +947,7 @@ void be_insert_spills_reloads(spill_env_t *env)
                                     env->spill_cost, si->spill_costs));
                        }
 
-                       if(all_remat_costs < 0) {
+                       if (all_remat_costs < 0) {
                                DBG((dbg, LEVEL_1, "\nforcing remats of all reloaders (%f)\n",
                                     all_remat_costs));
                                force_remat = 1;
@@ -1006,9 +987,9 @@ void be_insert_spills_reloads(spill_env_t *env)
                 * SSA form for the spilled value */
                if (ARR_LEN(copies) > 0) {
                        be_ssa_construction_env_t senv;
-                       /* be_lv_t *lv = be_get_birg_liveness(env->birg); */
+                       /* be_lv_t *lv = be_get_irg_liveness(env->irg); */
 
-                       be_ssa_construction_init(&senv, env->birg);
+                       be_ssa_construction_init(&senv, env->irg);
                        be_ssa_construction_add_copy(&senv, to_spill);
                        be_ssa_construction_add_copies(&senv, copies, ARR_LEN(copies));
                        be_ssa_construction_fix_users(&senv, to_spill);
@@ -1019,7 +1000,7 @@ void be_insert_spills_reloads(spill_env_t *env)
                        be_ssa_construction_update_liveness_phis(&senv);
                        be_liveness_update(to_spill);
                        len = ARR_LEN(copies);
-                       for(i = 0; i < len; ++i) {
+                       for (i = 0; i < len; ++i) {
                                be_liveness_update(lv, copies[i]);
                        }
 #endif
@@ -1032,16 +1013,16 @@ void be_insert_spills_reloads(spill_env_t *env)
 
                        be_ssa_construction_env_t senv;
 
-                       be_ssa_construction_init(&senv, env->birg);
+                       be_ssa_construction_init(&senv, env->irg);
                        spill = si->spills;
-                       for( ; spill != NULL; spill = spill->next) {
+                       for ( ; spill != NULL; spill = spill->next) {
                                /* maybe we rematerialized the value and need no spill */
-                               if(spill->spill == NULL)
+                               if (spill->spill == NULL)
                                        continue;
                                be_ssa_construction_add_copy(&senv, spill->spill);
                                spill_count++;
                        }
-                       if(spill_count > 1) {
+                       if (spill_count > 1) {
                                /* all reloads are attached to the first spill, fix them now */
                                be_ssa_construction_fix_users(&senv, si->spills->spill);
                        }
@@ -1060,16 +1041,15 @@ void be_insert_spills_reloads(spill_env_t *env)
 
        /* Matze: In theory be_ssa_construction should take care of the liveness...
         * try to disable this again in the future */
-       be_liveness_invalidate(env->birg->lv);
+       be_liveness_invalidate(be_get_irg_liveness(env->irg));
 
-       be_remove_dead_nodes_from_schedule(env->birg);
+       be_remove_dead_nodes_from_schedule(env->irg);
 
-       BE_TIMER_POP(t_ra_spill_apply);
+       be_timer_pop(T_RA_SPILL_APPLY);
 }
 
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spill);
 void be_init_spill(void)
 {
        FIRM_DBG_REGISTER(dbg, "firm.be.spill");
 }
-
-BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spill);