Account for return address when reserving stack space for CSRs.

This commit is contained in:
Tyler McMullen
2017-12-04 17:19:27 -08:00
committed by Jakob Stoklund Olesen
parent a75248d2cf
commit 5783ea2c9a
2 changed files with 10 additions and 3 deletions

View File

@@ -10,8 +10,8 @@ ebb0:
}
; check: function %foo(i64 fp [%rbp], i64 csr [%rbx], i64 csr [%r12], i64 csr [%r13], i64 csr [%r14], i64 csr [%r15]) -> i64 fp [%rbp], i64 csr [%rbx], i64 csr [%r12], i64 csr [%r13], i64 csr [%r14], i64 csr [%r15] native {
; nextln: ss0 = local 168, offset -216
; nextln: ss1 = incoming_arg 48, offset -48
; nextln: ss0 = local 168, offset -224
; nextln: ss1 = incoming_arg 56, offset -56
; check: ebb0(v0: i64 [%rbp], v1: i64 [%rbx], v2: i64 [%r12], v3: i64 [%r13], v4: i64 [%r14], v5: i64 [%r15]):
; nextln: x86_push v0
; nextln: copy_special %rsp -> %rbp

View File

@@ -177,8 +177,15 @@ pub fn prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> result::Ct
ir::types::I32
};
let csrs = callee_saved_registers(isa.flags());
let csr_stack_size = ((csrs.len() + 1) * word_size as usize) as i32;
// The reserved stack area is composed of:
// return address + frame pointer + all callee-saved registers
//
// Pushing the return address is an implicit function of the `call`
// instruction. Each of the others we will then push explicitly. Then we
// will adjust the stack pointer to make room for the rest of the required
// space for this frame.
let csr_stack_size = ((csrs.len() + 2) * word_size as usize) as i32;
func.create_stack_slot(ir::StackSlotData {
kind: ir::StackSlotKind::IncomingArg,
size: csr_stack_size as u32,