changed ir_printf call into DBG output
[libfirm] / ir / be / bespillbelady.c
index 1a31dfd..4b5b16a 100644 (file)
@@ -105,7 +105,7 @@ static INLINE workset_t *workset_clone(belady_env_t *env, struct obstack *ob, wo
 
 /**
  * Do NOT alloc anything. Make @param tgt equal to @param src.
- * returns @param tgt for convinience
+ * returns @param tgt for convenience
  */
 static INLINE workset_t *workset_copy(belady_env_t *env, workset_t *tgt, workset_t *src) {
        size_t size = sizeof(*src) + (env->n_regs)*sizeof(src->vals[0]);
@@ -285,8 +285,8 @@ static void displace(belady_env_t *env, workset_t *new_vals, int is_usage) {
                for (i=max_allowed; i<ws->len; ++i) {
                        ir_node *irn = ws->vals[i].irn;
 
-                        if(is_Phi(irn))
-                            continue;
+            if(is_Phi(irn))
+                continue;
 
                        if (!pset_find_ptr(env->used, irn)) {
                                ir_node *curr_bb = get_nodes_block(env->instr);
@@ -558,6 +558,7 @@ void be_spill_belady_spill_env(const be_chordal_env_t *chordal_env, spill_env_t
        belady_env_t env;
 
        FIRM_DBG_REGISTER(dbg, "firm.be.spill.belady");
+       //firm_dbg_set_mask(dbg, DBG_WSETS);
 
        /* init belady env */
        obstack_init(&env.ob);
@@ -575,11 +576,15 @@ void be_spill_belady_spill_env(const be_chordal_env_t *chordal_env, spill_env_t
 
        DBG((dbg, LEVEL_1, "running on register class: %s\n", env.cls->name));
 
-       /* do the work */
        be_clear_links(chordal_env->irg);
+       /* Decide which phi nodes will be spilled and place copies for them into the graph */
        irg_block_walk_graph(chordal_env->irg, place_copy_walker, NULL, &env);
+       be_place_copies(env.senv);
+       /* Fix high register pressure with belady algorithm */
        irg_block_walk_graph(chordal_env->irg, NULL, belady, &env);
+       /* belady was block-local, fix the global flow by adding reloads on the edges */
        irg_block_walk_graph(chordal_env->irg, fix_block_borders, NULL, &env);
+       /* Insert spill/reload nodes into the graph and fix usages */
        be_insert_spills_reloads(env.senv);
 
        be_remove_dead_nodes_from_schedule(chordal_env->irg);