summaryrefslogtreecommitdiffhomepage
path: root/ir/be/bestate.c
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2011-03-08 12:53:12 +0100
committerMatthias Braun <matze@braunis.de>2011-03-08 12:53:12 +0100
commita572aa3cb3a08690a3d2d6567bd26ab7c52a81c5 (patch)
tree097fc7f0bbb6427742f5a977feb9f16c6f1897e1 /ir/be/bestate.c
parent8737c443a02baf4aab54adb8cace71c59bdb7345 (diff)
fix bestate code not respecting prolog/epilog
Diffstat (limited to 'ir/be/bestate.c')
-rw-r--r--ir/be/bestate.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/ir/be/bestate.c b/ir/be/bestate.c
index 5a57bdd..b7035da 100644
--- a/ir/be/bestate.c
+++ b/ir/be/bestate.c
@@ -135,7 +135,8 @@ static spill_info_t *create_spill(minibelady_env_t *env, ir_node *state, int for
do {
after = next;
next = sched_next(after);
- } while (is_Proj(next) || is_Phi(next) || be_is_Keep(next));
+ } while (is_Proj(next) || is_Phi(next) || be_is_Keep(next)
+ || (arch_irn_get_flags(next) & arch_irn_flags_prolog));
} else {
after = state;
}
@@ -351,6 +352,17 @@ static block_info_t *compute_block_start_state(minibelady_env_t *env, ir_node *b
return block_info;
}
+static ir_node *get_reload_point(ir_node *before)
+{
+ while (true) {
+ ir_node *prev = sched_prev(before);
+ if (! (arch_irn_get_flags(prev) & arch_irn_flags_epilog))
+ break;
+ before = prev;
+ }
+ return before;
+}
+
/**
* For the given block @p block, decide for each values
* whether it is used from a register or is reloaded
@@ -408,7 +420,8 @@ static void belady(minibelady_env_t *env, ir_node *block)
/* create a reload to match state if necessary */
if (need_val != NULL && need_val != current_state) {
DBG((dbg, LEVEL_3, "\t... reloading %+F\n", need_val));
- create_reload(env, need_val, node, current_state);
+ ir_node *before = get_reload_point(node);
+ create_reload(env, need_val, before, current_state);
current_state = need_val;
}