Commit cd2fd327 authored by qinsoon's avatar qinsoon

make sure when we adjust frame size, stack pointer is 16-bytes aligned

(for calling convention)
parent bf5b86a9
......@@ -633,7 +633,15 @@ impl MachineCode for ASMCode {
regs_to_remove
}
fn patch_frame_size(&mut self, size: usize) {
fn patch_frame_size(&mut self, size: usize, size_used: usize) {
// calling convention requires stack pointer to be 16 bytes aligned before a call
// we make frame size a multipl of 16 bytes
let size = if (size + size_used) % 16 == 0 {
size
} else {
( (size + size_used) / 16 + 1) * 16 - size_used
};
let size = size.to_string();
debug_assert!(size.len() <= FRAME_SIZE_PLACEHOLDER_LEN);
......
......@@ -95,7 +95,7 @@ impl RegisterAllocation {
let size_to_patch = total_frame_size - size_for_callee_saved_regs;
trace!("patching the code to grow/shrink size of {} bytes", size_to_patch);
coloring.cf.mc_mut().patch_frame_size(size_to_patch);
coloring.cf.mc_mut().patch_frame_size(size_to_patch, size_for_callee_saved_regs);
}
coloring.cf.mc().trace_mc();
......
......@@ -192,7 +192,7 @@ pub trait MachineCode {
/// returns what registers push/pop have been deleted
fn remove_unnecessary_callee_saved(&mut self, used_callee_saved: Vec<MuID>) -> Vec<MuID>;
/// patch frame size
fn patch_frame_size(&mut self, size: usize);
fn patch_frame_size(&mut self, size: usize, size_used: usize);
fn as_any(&self) -> &Any;
}
......
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