X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbespill.c;h=85c051d17c23f3d84f8fdb6f8f863d49189016d4;hb=8dd1d4b07d2638ab224c6b044655facd6026dbd7;hp=6b2b8ae98d4e8b5f621cf79c614045e17215bc0b;hpb=3a3b54087566a26b9e9987bb073c8314e0a8876c;p=libfirm diff --git a/ir/be/bespill.c b/ir/be/bespill.c index 6b2b8ae98..85c051d17 100644 --- a/ir/be/bespill.c +++ b/ir/be/bespill.c @@ -116,6 +116,8 @@ int cmp_spillinfo(const void *x, const void *y, size_t size) { const spill_info_t *xx = x; const spill_info_t *yy = y; + (void) size; + return xx->to_spill != yy->to_spill; } @@ -239,6 +241,8 @@ void be_add_reload(spill_env_t *env, ir_node *to_spill, ir_node *before, #endif } + assert(!is_Proj(before) && !be_is_Keep(before)); + /* put reload into list */ rel = obstack_alloc(&env->obst, sizeof(rel[0])); rel->next = info->reloaders; @@ -258,6 +262,26 @@ void be_add_reload(spill_env_t *env, ir_node *to_spill, ir_node *before, to_spill, before, allow_remat ? "" : " not")); } +ir_node *be_get_end_of_block_insertion_point(const ir_node *block) +{ + ir_node *last = sched_last(block); + + /* we might have projs and keepanys behind the jump... */ + while(is_Proj(last) || be_is_Keep(last)) { + last = sched_prev(last); + assert(!sched_is_end(last)); + } + + if(!is_cfop(last)) { + last = sched_next(last); + /* last node must be a cfop, only exception is the start block */ + assert(last == get_irg_start_block(get_irn_irg(block))); + } + + /* add the reload before the (cond-)jump */ + return last; +} + /** * Returns the point at which you can insert a node that should be executed * before block @p block when coming from pred @p pos. @@ -265,7 +289,7 @@ void be_add_reload(spill_env_t *env, ir_node *to_spill, ir_node *before, static ir_node *get_block_insertion_point(ir_node *block, int pos) { - ir_node *predblock, *last; + ir_node *predblock; /* 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 @@ -277,22 +301,15 @@ ir_node *get_block_insertion_point(ir_node *block, int pos) /* We have to reload the value in pred-block */ predblock = get_Block_cfgpred_block(block, pos); - last = sched_last(predblock); - - /* we might have projs and keepanys behind the jump... */ - while(is_Proj(last) || be_is_Keep(last)) { - last = sched_prev(last); - assert(!sched_is_end(last)); - } - - if(!is_cfop(last)) { - last = sched_next(last); - /* last node must be a cfop, only exception is the start block */ - assert(last == get_irg_start_block(get_irn_irg(block))); - } + return be_get_end_of_block_insertion_point(predblock); +} - /* add the reload before the (cond-)jump */ - return last; +void be_add_reload_at_end(spill_env_t *env, ir_node *to_spill, const ir_node *block, + const arch_register_class_t *reload_cls, + int allow_remat) +{ + ir_node *before = be_get_end_of_block_insertion_point(block); + be_add_reload(env, to_spill, before, reload_cls, allow_remat); } void be_add_reload_on_edge(spill_env_t *env, ir_node *to_spill, ir_node *block, @@ -347,7 +364,7 @@ static void sched_add_after_insn(ir_node *sched_after, ir_node *node) { ir_node *next = sched_next(sched_after); - while(is_Proj(next) || is_Phi(next)) { + while(is_Proj(next) || is_Phi(next) || be_is_Keep(next)) { next = sched_next(next); } assert(next != NULL); @@ -685,15 +702,17 @@ ir_node *do_remat(spill_env_t *env, ir_node *spilled, ir_node *reloader) get_irn_arity(spilled), ins); copy_node_attr(spilled, res); new_backedge_info(res); - sched_reset(res); DBG((dbg, LEVEL_1, "Insert remat %+F of %+F before reloader %+F\n", res, spilled, reloader)); - /* insert in schedule */ - sched_add_before(reloader, res); + if (! is_Proj(res)) { + /* insert in schedule */ + sched_reset(res); + sched_add_before(reloader, res); #ifdef FIRM_STATISTICS - env->remat_count++; + env->remat_count++; #endif + } return res; } @@ -702,6 +721,7 @@ double be_get_spill_costs(spill_env_t *env, ir_node *to_spill, ir_node *after) { ir_node *block = get_nodes_block(after); double freq = get_block_execfreq(env->exec_freq, block); + (void) to_spill; return env->spill_cost * freq; } @@ -796,7 +816,7 @@ void be_insert_spills_reloads(spill_env_t *env) remat_cost_delta = remat_cost - env->reload_cost; rld->remat_cost_delta = remat_cost_delta; - block = get_nodes_block(reloader); + block = is_Block(reloader) ? reloader : get_nodes_block(reloader); freq = get_block_execfreq(exec_freq, block); all_remat_costs += remat_cost_delta * freq; DBG((dbg, LEVEL_2, "\tremat costs delta before %+F: " @@ -878,19 +898,16 @@ void be_insert_spills_reloads(spill_env_t *env) si->reloaders = NULL; } -#ifdef FIRM_STATISTICS - if (be_stat_ev_is_active()) { - be_stat_ev("spill_spills", env->spill_count); - be_stat_ev("spill_reloads", env->reload_count); - be_stat_ev("spill_remats", env->remat_count); - be_stat_ev("spill_spilled_phis", env->spilled_phi_count); - } -#endif + stat_ev_dbl("spill_spills", env->spill_count); + stat_ev_dbl("spill_reloads", env->reload_count); + stat_ev_dbl("spill_remats", env->remat_count); + stat_ev_dbl("spill_spilled_phis", env->spilled_phi_count); - be_remove_dead_nodes_from_schedule(env->irg); /* Matze: In theory be_ssa_construction should take care of the liveness... * try to disable this again in the future */ - be_invalidate_liveness(env->birg); + be_liveness_invalidate(env->birg->lv); + + be_remove_dead_nodes_from_schedule(env->birg); } void be_init_spill(void)