rematerialized values are like reloads
authorMatthias Braun <matze@braunis.de>
Mon, 15 Oct 2007 11:21:01 +0000 (11:21 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 15 Oct 2007 11:21:01 +0000 (11:21 +0000)
[r16202]

ir/be/bespill.c
ir/be/bespillbelady.c

index c0b5f36..04e801a 100644 (file)
@@ -107,6 +107,8 @@ struct spill_env_t {
                                               placed */
        ir_nodeset_t      mem_phis;       /**< set of all spilled phis. */
        ir_exec_freq     *exec_freq;
+       unsigned          new_nodes_idx;  /**< all old nodes idx is smaller than
+                                              this */
 
 #ifdef FIRM_STATISTICS
        unsigned          spill_count;
@@ -428,7 +430,7 @@ static void spill_irn(spill_env_t *env, spill_info_t *spillinfo)
 
                /* place all spills before the reloads (as we can't guarantee the
                 * same order as the be_add_spill and be_add_reload calls */
-               while(be_is_Reload(sched_prev(before))) {
+               while(get_irn_idx(sched_prev(before)) > env->new_nodes_idx) {
                        before = sched_prev(before);
                }
 
@@ -477,7 +479,7 @@ static void spill_phi(spill_env_t *env, spill_info_t *spillinfo)
                ins[i] = unknown;
        }
 
-       /* override replace spills... */
+       /* override or replace spills list... */
        spill         = obstack_alloc(&env->obst, sizeof(spill[0]));
        spill->before = skip_keeps_phis(phi);
        spill->spill  = new_r_Phi(irg, block, arity, ins, mode_M);
@@ -851,12 +853,15 @@ static void determine_spill_costs(spill_env_t *env, spill_info_t *spillinfo)
 
 void be_insert_spills_reloads(spill_env_t *env)
 {
+       ir_graph              *irg       = env->irg;
        const arch_env_t      *arch_env  = env->arch_env;
        const ir_exec_freq    *exec_freq = env->exec_freq;
        spill_info_t          *si;
        ir_nodeset_iterator_t  iter;
        ir_node               *node;
 
+       env->new_nodes_idx = get_irg_last_idx(irg);
+
        /* create all phi-ms first, this is needed so, that phis, hanging on
           spilled phis work correctly */
        foreach_ir_nodeset(&env->mem_phis, node, iter) {
index 511ea89..59de03b 100644 (file)
@@ -766,15 +766,17 @@ void be_spill_belady_spill_env(be_irg_t *birg, const arch_register_class_t *cls,
        irg_block_walk_graph(irg, NULL, belady, &env);
        /* belady was block-local, fix the global flow by adding reloads on the edges */
        irg_block_walk_graph(irg, fix_block_borders, NULL, &env);
+
+       be_end_uses(env.uses);
+       be_free_loop_pressure(env.loop_ana);
+       obstack_free(&env.ob, NULL);
+
        /* Insert spill/reload nodes into the graph and fix usages */
        be_insert_spills_reloads(env.senv);
 
        /* clean up */
        if(spill_env == NULL)
                be_delete_spill_env(env.senv);
-       be_end_uses(env.uses);
-       be_free_loop_pressure(env.loop_ana);
-       obstack_free(&env.ob, NULL);
 }
 
 void be_init_spillbelady(void)