From c67405ffe55d397e21ee70b2be467975537856e1 Mon Sep 17 00:00:00 2001 From: losfair Date: Mon, 1 Jul 2019 21:20:35 +0800 Subject: [PATCH] Add workaround for singlepass miscompilation on GetLocal. --- lib/singlepass-backend/src/codegen_x64.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/singlepass-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs index 9baa15c22d8..636f596382b 100644 --- a/lib/singlepass-backend/src/codegen_x64.rs +++ b/lib/singlepass-backend/src/codegen_x64.rs @@ -1692,8 +1692,16 @@ impl FunctionCodeGenerator for X64FunctionCode { } Operator::GetLocal { local_index } => { let local_index = local_index as usize; - self.value_stack - .push((self.locals[local_index], LocalOrTemp::Local)); + let ret = self.machine.acquire_locations(a, &[WpType::I64], false)[0]; + Self::emit_relaxed_binop( + a, + &mut self.machine, + Assembler::emit_mov, + Size::S64, + self.locals[local_index], + ret, + ); + self.value_stack.push((ret, LocalOrTemp::Temp)); } Operator::SetLocal { local_index } => { let local_index = local_index as usize;