Commit 6d7f9e79 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

amd64: Correct three bugs for functions with frame pointers.

* Use rbp and rsp as output of leave, not rbp twice.
* Attach the rbp input/output of leave to rbp, not rsp.
* Use the function's own frame pointer instead of the caller's frame pointer.
parent eee77c81
......@@ -258,7 +258,7 @@ leave => {
op_flags => [ "uses_memory" ],
state => "exc_pinned",
in_reqs => [ "rbp" ],
out_reqs => [ "rbp:I", "rbp:I|S" ],
out_reqs => [ "rbp:I", "rsp:I|S" ],
outs => [ "frame", "stack" ],
fixed => "amd64_op_mode_t op_mode = AMD64_OP_NONE;\n",
emit => "leave",
......
......@@ -504,7 +504,7 @@ static void amd64_collect_frame_entity_nodes(ir_node *node, void *data)
static int determine_rbp_input(ir_node *ret)
{
const arch_register_t *bp = &amd64_registers[REG_RSP];
arch_register_t const *const bp = &amd64_registers[REG_RBP];
foreach_irn_in(ret, i, input) {
if (arch_get_irn_register(input) == bp)
return i;
......@@ -568,6 +568,7 @@ static void introduce_prologue(ir_graph *const irg)
if (!layout->sp_relative) {
/* push rbp */
ir_node *const initial_bp = be_get_initial_reg_value(irg, bp);
ir_node *push = new_bd_amd64_push_rbp(NULL, block, initial_sp);
ir_node *curr_sp = new_r_Proj(push, mode_gp, pn_amd64_push_rbp_stack);
......@@ -579,6 +580,7 @@ static void introduce_prologue(ir_graph *const irg)
sched_add_after(push, curr_bp);
be_set_constr_single_reg_out(curr_bp, 0,
bp, arch_register_req_type_ignore);
edges_reroute_except(initial_bp, curr_bp, push);
ir_node *incsp = amd64_new_IncSP(block, curr_sp, frame_size, 0);
sched_add_after(curr_bp, 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