From d18477f8dbd1ae0983d8ab5d7b8c2846173677f5 Mon Sep 17 00:00:00 2001 From: Trevor Elliott Date: Thu, 16 May 2024 10:17:02 -0700 Subject: [PATCH] Including the outgoing arguments area when computing the caller's sp (#8636) --- cranelift/codegen/src/machinst/abi.rs | 5 +++-- cranelift/codegen/src/machinst/vcode.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cranelift/codegen/src/machinst/abi.rs b/cranelift/codegen/src/machinst/abi.rs index 38c4952e1f..ccdbc29109 100644 --- a/cranelift/codegen/src/machinst/abi.rs +++ b/cranelift/codegen/src/machinst/abi.rs @@ -1942,12 +1942,13 @@ impl Callee { frame_layout.clobber_size + frame_layout.fixed_frame_storage_size } - /// Returns offset from the nominal SP to caller's SP. - pub fn nominal_sp_to_caller_sp_offset(&self) -> u32 { + /// Returns offset from the SP to caller's SP. + pub fn sp_to_caller_sp_offset(&self) -> u32 { let frame_layout = self.frame_layout(); frame_layout.clobber_size + frame_layout.fixed_frame_storage_size + frame_layout.setup_area_size + + frame_layout.outgoing_args_size } /// Returns the size of arguments expected on the stack. diff --git a/cranelift/codegen/src/machinst/vcode.rs b/cranelift/codegen/src/machinst/vcode.rs index 6e9318912a..112f643c7a 100644 --- a/cranelift/codegen/src/machinst/vcode.rs +++ b/cranelift/codegen/src/machinst/vcode.rs @@ -1138,7 +1138,7 @@ impl VCode { } else { let slot = alloc.as_stack().unwrap(); let sp_offset = self.abi.get_spillslot_offset(slot); - let sp_to_caller_sp_offset = self.abi.nominal_sp_to_caller_sp_offset(); + let sp_to_caller_sp_offset = self.abi.sp_to_caller_sp_offset(); let caller_sp_to_cfa_offset = crate::isa::unwind::systemv::caller_sp_to_cfa_offset(); let cfa_to_sp_offset = -((sp_to_caller_sp_offset + caller_sp_to_cfa_offset) as i64);