Pop the callee-saved registers in the function epilogue(s).

This commit is contained in:
Tyler McMullen
2017-11-29 17:43:06 -08:00
committed by Jakob Stoklund Olesen
parent f31a764fc8
commit cf9d287bea

View File

@@ -216,9 +216,7 @@ impl TargetIsa for Isa {
// Insert an epilogue directly before every 'return'
for inst in return_insts {
let fp_ret = self.insert_epilogue(inst, local_stack_size as i32, func);
func.locations[fp_ret] = ir::ValueLoc::Reg(RU::rbp as RegUnit);
func.dfg.append_inst_arg(inst, fp_ret);
self.insert_epilogue(inst, local_stack_size as i32, func);
}
@@ -227,16 +225,24 @@ impl TargetIsa for Isa {
}
impl Isa {
fn insert_epilogue(
&self,
inst: ir::Inst,
stack_size: i32,
func: &mut ir::Function,
) -> ir::Value {
fn insert_epilogue(&self, inst: ir::Inst, stack_size: i32, func: &mut ir::Function) {
let mut return_values = Vec::new();
let mut pos = EncCursor::new(func, self).at_inst(inst);
if stack_size > 0 {
pos.ins().adjust_sp_imm(stack_size);
}
pos.ins().x86_pop(ir::types::I64)
for reg in abi::CSR_GPRS.iter().rev() {
let csr_ret = pos.ins().x86_pop(ir::types::I64);
return_values.push((csr_ret, *reg));
}
let fp_ret = pos.ins().x86_pop(ir::types::I64);
return_values.push((fp_ret, RU::rbp));
let func = pos.func;
for (val, reg) in return_values {
func.locations[val] = ir::ValueLoc::Reg(reg as RegUnit);
func.dfg.append_inst_arg(inst, val);
}
}
}