From 51e085a7bad41dc6e279d986f1d0da22e1655944 Mon Sep 17 00:00:00 2001 From: losfair Date: Tue, 12 May 2020 02:11:43 +0800 Subject: [PATCH] Garbage in upper 32 bits shouldn't propagate to I64ExtendI32U's result. --- lib/singlepass-backend/src/codegen_x64.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/singlepass-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs index 9dfc648cc..de7248db3 100644 --- a/lib/singlepass-backend/src/codegen_x64.rs +++ b/lib/singlepass-backend/src/codegen_x64.rs @@ -4043,6 +4043,7 @@ impl FunctionCodeGenerator for X64FunctionCode { false, )[0]; self.value_stack.push(ret); + Self::emit_relaxed_binop( a, &mut self.machine, @@ -4051,6 +4052,16 @@ impl FunctionCodeGenerator for X64FunctionCode { loc, ret, ); + if let Location::Memory(base, off) = ret { + Self::emit_relaxed_binop( + a, + &mut self.machine, + Assembler::emit_mov, + Size::S32, + Location::Imm32(0), + Location::Memory(base, off + 4), + ); + } } Operator::I64ExtendI32S => { let loc =