Commit 90c9c962 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

be: Add and use be_keep_unused().

parent 509c01cb
......@@ -20,6 +20,7 @@
#include "bespillutil.h"
#include "bestack.h"
#include "be_t.h"
#include "beutil.h"
#include "debug.h"
#include "panic.h"
#include "irarch_t.h"
......@@ -611,11 +612,7 @@ static void introduce_prologue(ir_graph *const irg)
sched_add_after(curr_sp, incsp);
/* make sure the initial IncSP is really used by someone */
if (get_irn_n_edges(incsp) == 0) {
ir_node *in[] = { incsp };
ir_node *keep = be_new_Keep(block, 1, in);
sched_add_after(incsp, keep);
}
be_keep_if_unused(incsp);
layout->initial_bias = -8;
} else {
......
......@@ -167,3 +167,13 @@ void be_remove_dead_nodes_from_schedule(ir_graph *irg)
/* walk schedule and remove non-marked nodes */
irg_block_walk_graph(irg, remove_dead_nodes_walker, NULL, &env);
}
void be_keep_if_unused(ir_node *node)
{
if (get_irn_n_edges(node) == 0) {
ir_node *const in[] = { node };
ir_node *const block = get_nodes_block(node);
ir_node *const keep = be_new_Keep(block, ARRAY_SIZE(in), in);
sched_add_after(node, keep);
}
}
......@@ -45,4 +45,11 @@ ir_node *insert_Perm_before(ir_graph *irg, const arch_register_class_t *cls,
*/
void be_remove_dead_nodes_from_schedule(ir_graph *irg);
/**
* Keep the given node alive, if it has no users, by adding a be_Keep.
*
* @param node The node to kept alive.
*/
void be_keep_if_unused(ir_node *node);
#endif
......@@ -1090,11 +1090,7 @@ static void introduce_prologue(ir_graph *const irg)
sched_add_after(curr_sp, incsp);
/* make sure the initial IncSP is really used by someone */
if (get_irn_n_edges(incsp) == 0) {
ir_node *in[] = { incsp };
ir_node *keep = be_new_Keep(block, 1, in);
sched_add_after(incsp, keep);
}
be_keep_if_unused(incsp);
layout->initial_bias = -4;
} else {
......
......@@ -12,6 +12,7 @@
#include <assert.h>
#include "beirg.h"
#include "beutil.h"
#include "irnode_t.h"
#include "irop_t.h"
#include "irprog.h"
......@@ -1021,18 +1022,6 @@ static void sim_Fucom(x87_state *state, ir_node *n)
)
}
/**
* Keep the given node alive by adding a be_Keep.
*
* @param node the node to kept alive
*/
static void keep_float_node_alive(ir_node *node)
{
ir_node *block = get_nodes_block(node);
ir_node *keep = be_new_Keep(block, 1, &node);
sched_add_after(node, keep);
}
/**
* Simulate a be_Copy.
*
......@@ -1074,8 +1063,7 @@ static void sim_Copy(x87_state *state, ir_node *n)
* the pred blocks. This is unfortunate as removing it would save us 1
* instruction, but we would have to rerun all the simulation to get
* this correct. */
if (get_irn_n_edges(pred) == 0)
keep_float_node_alive(pred);
be_keep_if_unused(pred);
DB((dbg, LEVEL_1, "<<< %+F %+F -> ?\n", copy, pred));
} else {
......
......@@ -199,11 +199,7 @@ static void sparc_introduce_prolog_epilog(ir_graph *irg)
* the function should hold the Save, even if we use a restore
* which just overrides it instead of using the value)
*/
if (get_irn_n_edges(save) == 0) {
ir_node *in[] = { save };
ir_node *keep = be_new_Keep(block, 1, in);
sched_add_after(schedpoint, keep);
}
be_keep_if_unused(save);
} else {
ir_node *const incsp = be_new_IncSP(sp_reg, block, initial_sp, frame_size, 0);
edges_reroute_except(initial_sp, incsp, incsp);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment