Pop the callee-saved registers in the function epilogue(s).
This commit is contained in:
committed by
Jakob Stoklund Olesen
parent
f31a764fc8
commit
cf9d287bea
@@ -216,9 +216,7 @@ impl TargetIsa for Isa {
|
|||||||
|
|
||||||
// Insert an epilogue directly before every 'return'
|
// Insert an epilogue directly before every 'return'
|
||||||
for inst in return_insts {
|
for inst in return_insts {
|
||||||
let fp_ret = self.insert_epilogue(inst, local_stack_size as i32, func);
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -227,16 +225,24 @@ impl TargetIsa for Isa {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Isa {
|
impl Isa {
|
||||||
fn insert_epilogue(
|
fn insert_epilogue(&self, inst: ir::Inst, stack_size: i32, func: &mut ir::Function) {
|
||||||
&self,
|
let mut return_values = Vec::new();
|
||||||
inst: ir::Inst,
|
|
||||||
stack_size: i32,
|
|
||||||
func: &mut ir::Function,
|
|
||||||
) -> ir::Value {
|
|
||||||
let mut pos = EncCursor::new(func, self).at_inst(inst);
|
let mut pos = EncCursor::new(func, self).at_inst(inst);
|
||||||
if stack_size > 0 {
|
if stack_size > 0 {
|
||||||
pos.ins().adjust_sp_imm(stack_size);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user