From 048ef0790052904e04c42c8d8eaf3e2865005bbf Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Mon, 15 Oct 2007 11:21:01 +0000 Subject: [PATCH] rematerialized values are like reloads [r16202] --- ir/be/bespill.c | 9 +++++++-- ir/be/bespillbelady.c | 8 +++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ir/be/bespill.c b/ir/be/bespill.c index c0b5f36fc..04e801af4 100644 --- a/ir/be/bespill.c +++ b/ir/be/bespill.c @@ -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) { diff --git a/ir/be/bespillbelady.c b/ir/be/bespillbelady.c index 511ea898f..59de03b4e 100644 --- a/ir/be/bespillbelady.c +++ b/ir/be/bespillbelady.c @@ -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) -- 2.20.1