Commit 6322e331 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Add be_dep_on_frame() to let a node depend on the frame, so it does not get...

Add be_dep_on_frame() to let a node depend on the frame, so it does not get scheduled before it can be spilled.

[r22625]
parent d196cf95
......@@ -89,8 +89,7 @@ static ir_node *create_mov_node(dbg_info *dbg, ir_node *block, long value) {
if (mode_needs_gp_reg(mode))
mode = mode_Iu;
res = new_rd_arm_Mov_i(dbg, irg, block, mode, value);
/* ensure the const is scheduled AFTER the stack frame */
add_irn_dep(res, get_irg_frame(irg));
be_dep_on_frame(res);
return res;
}
......@@ -105,8 +104,7 @@ static ir_node *create_mvn_node(dbg_info *dbg, ir_node *block, long value) {
if (mode_needs_gp_reg(mode))
mode = mode_Iu;
res = new_rd_arm_Mvn_i(dbg, irg, block, mode, value);
/* ensure the const is scheduled AFTER the stack frame */
add_irn_dep(res, get_irg_frame(irg));
be_dep_on_frame(res);
return res;
}
......@@ -1077,8 +1075,7 @@ static ir_node *gen_Const(ir_node *node) {
} else {
node = new_rd_arm_fpaConst(dbg, irg, block, tv);
}
/* ensure the const is scheduled AFTER the stack frame */
add_irn_dep(node, get_irg_frame(irg));
be_dep_on_frame(node);
return node;
}
else if (USE_VFP(env_cg->isa)) {
......@@ -1105,8 +1102,7 @@ static ir_node *gen_SymConst(ir_node *node) {
ir_node *res;
res = new_rd_arm_SymConst(dbg, irg, block, mode, get_sc_ident(node));
/* ensure the const is scheduled AFTER the stack frame */
add_irn_dep(res, get_irg_frame(irg));
be_dep_on_frame(res);
return res;
}
......
......@@ -85,6 +85,14 @@ void be_duplicate_deps(ir_node *old_node, ir_node *new_node) {
}
}
void be_dep_on_frame(ir_node *const node)
{
ir_graph *const irg = current_ir_graph;
if (get_irg_start_block(irg) == get_nodes_block(node))
add_irn_dep(node, get_irg_frame(irg));
}
ir_node *be_duplicate_node(ir_node *node) {
ir_node *block = be_transform_node(get_nodes_block(node));
ir_graph *irg = env.irg;
......
......@@ -53,6 +53,12 @@ ir_node *be_transform_node(ir_node *node);
*/
void be_duplicate_deps(ir_node *old_node, ir_node *new_node);
/**
* Depend on the frame if the node is in the start block. This prevents
* nodes being scheduled before they can be spilled.
*/
void be_dep_on_frame(ir_node *node);
/**
* Duplicate a node during transformation.
*/
......
......@@ -70,6 +70,7 @@
#include "../begnuas.h"
#include "../bestate.h"
#include "../beflags.h"
#include "../betranshlp.h"
#include "bearch_ia32_t.h"
......@@ -1560,8 +1561,7 @@ static ir_node *ia32_get_pic_base(void *self) {
get_eip = new_rd_ia32_GetEIP(NULL, cg->irg, block);
cg->get_eip = get_eip;
add_irn_dep(get_eip, get_irg_frame(cg->irg));
be_dep_on_frame(get_eip);
return get_eip;
}
......
......@@ -654,11 +654,8 @@ ir_node *gen_ASM(ir_node *node)
new_node = new_rd_ia32_Asm(dbgi, irg, new_block, arity, in, out_arity,
get_ASM_text(node), register_map);
/* Prevent the ASM node from being scheduled before the Barrier, if it has
* no inputs */
if (arity == 0 && get_irg_start_block(irg) == new_block) {
add_irn_dep(new_node, get_irg_frame(irg));
}
if (arity == 0)
be_dep_on_frame(new_node);
set_ia32_out_req_all(new_node, out_reg_reqs);
set_ia32_in_req_all(new_node, in_reg_reqs);
......@@ -713,7 +710,7 @@ ir_node *gen_CopyB(ir_node *node) {
size >>= 2;
res = new_rd_ia32_Const(dbgi, irg, block, NULL, 0, size);
add_irn_dep(res, get_irg_frame(irg));
be_dep_on_frame(res);
res = new_rd_ia32_CopyB(dbgi, irg, block, new_dst, new_src, res, new_mem, rem);
} else {
......@@ -769,12 +766,7 @@ ir_node *gen_Unknown(ir_node *node)
ir_node *block = get_irg_start_block(irg);
ir_node *ret = new_rd_ia32_vfldz(dbgi, irg, block);
/* Const Nodes before the initial IncSP are a bad idea, because
* they could be spilled and we have no SP ready at that point yet.
* So add a dependency to the initial frame pointer calculation to
* avoid that situation.
*/
add_irn_dep(ret, get_irg_frame(irg));
be_dep_on_frame(ret);
return ret;
}
} else if (ia32_mode_needs_gp_reg(mode)) {
......
......@@ -291,16 +291,9 @@ static ir_node *gen_Const(ir_node *node) {
}
}
end:
/* Const Nodes before the initial IncSP are a bad idea, because
* they could be spilled and we have no SP ready at that point yet.
* So add a dependency to the initial frame pointer calculation to
* avoid that situation.
*/
if (get_irg_start_block(irg) == block) {
add_irn_dep(load, get_irg_frame(irg));
}
SET_IA32_ORIG_NODE(load, ia32_get_old_node_name(env_cg, node));
be_dep_on_frame(load);
return res;
} else { /* non-float mode */
ir_node *cnst;
......@@ -318,11 +311,7 @@ end:
cnst = new_rd_ia32_Const(dbgi, irg, block, NULL, 0, val);
SET_IA32_ORIG_NODE(cnst, ia32_get_old_node_name(env_cg, node));
/* see above */
if (get_irg_start_block(irg) == block) {
add_irn_dep(cnst, get_irg_frame(irg));
}
be_dep_on_frame(cnst);
return cnst;
}
}
......@@ -358,15 +347,9 @@ static ir_node *gen_SymConst(ir_node *node) {
cnst = new_rd_ia32_Const(dbgi, irg, block, entity, 0, 0);
}
/* Const Nodes before the initial IncSP are a bad idea, because
* they could be spilled and we have no SP ready at that point yet
*/
if (get_irg_start_block(irg) == block) {
add_irn_dep(cnst, get_irg_frame(irg));
}
SET_IA32_ORIG_NODE(cnst, ia32_get_old_node_name(env_cg, node));
be_dep_on_frame(cnst);
return cnst;
}
......@@ -1093,7 +1076,7 @@ static ir_node *gen_Add(ir_node *node) {
ir_graph *irg = current_ir_graph;
new_node = new_rd_ia32_Const(dbgi, irg, new_block, addr.symconst_ent,
addr.symconst_sign, addr.offset);
add_irn_dep(new_node, get_irg_frame(irg));
be_dep_on_frame(new_node);
SET_IA32_ORIG_NODE(new_node, ia32_get_old_node_name(env_cg, node));
return new_node;
}
......@@ -1388,7 +1371,7 @@ static ir_node *create_Div(ir_node *node)
if (mode_is_signed(mode)) {
ir_node *produceval = new_rd_ia32_ProduceVal(dbgi, irg, new_block);
add_irn_dep(produceval, get_irg_frame(irg));
be_dep_on_frame(produceval);
sign_extension = new_rd_ia32_Cltd(dbgi, irg, new_block, am.new_op1,
produceval);
......@@ -1397,7 +1380,7 @@ static ir_node *create_Div(ir_node *node)
am.new_op1, sign_extension);
} else {
sign_extension = new_rd_ia32_Const(dbgi, irg, new_block, NULL, 0, 0);
add_irn_dep(sign_extension, get_irg_frame(irg));
be_dep_on_frame(sign_extension);
new_node = new_rd_ia32_Div(dbgi, irg, new_block, addr->base,
addr->index, new_mem, am.new_op2,
......@@ -1495,8 +1478,8 @@ static ir_node *gen_Shrs(ir_node *node) {
ir_node *op = left;
ir_node *new_op = be_transform_node(op);
ir_node *pval = new_rd_ia32_ProduceVal(dbgi, irg, block);
add_irn_dep(pval, get_irg_frame(irg));
be_dep_on_frame(pval);
return new_rd_ia32_Cltd(dbgi, irg, block, new_op, pval);
}
}
......@@ -1724,7 +1707,7 @@ static ir_node *gen_Abs(ir_node *node)
sign_extension = new_rd_ia32_Cltd(dbgi, irg, new_block,
new_op, pval);
add_irn_dep(pval, get_irg_frame(irg));
be_dep_on_frame(pval);
SET_IA32_ORIG_NODE(sign_extension,ia32_get_old_node_name(env_cg, node));
xor = new_rd_ia32_Xor(dbgi, irg, new_block, noreg_gp, noreg_gp,
......@@ -1897,15 +1880,9 @@ static ir_node *gen_Load(ir_node *node) {
add_ia32_flags(new_node, arch_irn_flags_rematerializable);
}
/* make sure we are scheduled behind the initial IncSP/Barrier
* to avoid spills being placed before it
*/
if (block == get_irg_start_block(irg)) {
add_irn_dep(new_node, get_irg_frame(irg));
}
SET_IA32_ORIG_NODE(new_node, ia32_get_old_node_name(env_cg, node));
be_dep_on_frame(new_node);
return new_node;
}
......
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