From b1c7c1401ef8948aeb311f23b6bdd8d62fbedc6a Mon Sep 17 00:00:00 2001 From: Peter Huene Date: Mon, 6 Jul 2020 18:52:16 -0700 Subject: [PATCH] Fix incorrect scaling for SaveXmm128Far. The `SaveXmm128Far` unwind op should have a 32-bit unscaled value. The value was accidentally scaled down by 16 while calculating whether or not the `SaveXmm128` or `SaveXmm128Far` unwind op should be used. --- cranelift/codegen/src/isa/unwind/winx64.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cranelift/codegen/src/isa/unwind/winx64.rs b/cranelift/codegen/src/isa/unwind/winx64.rs index 649b0e7ed0..6c06a8e67d 100644 --- a/cranelift/codegen/src/isa/unwind/winx64.rs +++ b/cranelift/codegen/src/isa/unwind/winx64.rs @@ -80,13 +80,13 @@ impl UnwindCode { stack_offset, } => { writer.write_u8(*offset); - let stack_offset = stack_offset / 16; - if stack_offset <= core::u16::MAX as u32 { + let scaled_stack_offset = stack_offset / 16; + if scaled_stack_offset <= core::u16::MAX as u32 { writer.write_u8((*reg << 4) | (UnwindOperation::SaveXmm128 as u8)); - writer.write_u16::(stack_offset as u16); + writer.write_u16::(scaled_stack_offset as u16); } else { writer.write_u8((*reg << 4) | (UnwindOperation::SaveXmm128Far as u8)); - writer.write_u16::(stack_offset as u16); + writer.write_u16::(*stack_offset as u16); writer.write_u16::((stack_offset >> 16) as u16); } }