From ce5f3e153b117e1aee1832c6e6e0a698f030e57f Mon Sep 17 00:00:00 2001 From: Peter Huene Date: Thu, 21 May 2020 16:46:30 -0700 Subject: [PATCH] Only update XMM save unwind operation offsets when using a FP. This commit prevents updating the XMM save unwind operation offsets when a frame pointer is not used, even though currently Cranelift always uses a frame pointer. This will prevent incorrect unwind information in the future when we start omitting frame pointers. --- cranelift/codegen/src/isa/x86/unwind/winx64.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cranelift/codegen/src/isa/x86/unwind/winx64.rs b/cranelift/codegen/src/isa/x86/unwind/winx64.rs index af7d7b12f4..de35fc6964 100644 --- a/cranelift/codegen/src/isa/x86/unwind/winx64.rs +++ b/cranelift/codegen/src/isa/x86/unwind/winx64.rs @@ -136,9 +136,12 @@ pub(crate) fn create_unwind_info( assert!(found_end); + // When using a frame register, certain unwind operations, such as XMM saves, are relative to the frame + // register minus some offset, forming a "base address". This attempts to calculate the frame register offset + // while updating the XMM save offsets to be relative from this "base address" rather than RSP. let mut frame_register_offset = 0; - if xmm_save_count > 0 { - // If there are XMM saves, determine the number of 16-byte slots used for all CSRs (including GPRs) + if frame_register.is_some() && xmm_save_count > 0 { + // Determine the number of 16-byte slots used for all CSRs (including GPRs) // The "frame register offset" will point at the last slot used (i.e. the last saved FPR) // Assumption: each FPR is stored at a lower address than the previous one let mut last_stack_offset = None;