From 46fb72af9d3146dd87d5fb7d2a98c7212b3b3745 Mon Sep 17 00:00:00 2001 From: losfair Date: Sun, 28 Apr 2019 13:31:22 +0800 Subject: [PATCH] Add missing `.rev()` on parameter list and simulate "red zone". --- lib/singlepass-backend/src/codegen_x64.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/singlepass-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs index fb465c2a8..783ca13af 100644 --- a/lib/singlepass-backend/src/codegen_x64.rs +++ b/lib/singlepass-backend/src/codegen_x64.rs @@ -1063,7 +1063,7 @@ impl X64FunctionCode { let mut call_movs: Vec<(Location, GPR)> = vec![]; // Prepare register & stack parameters. - for (i, param) in params.iter().enumerate() { + for (i, param) in params.iter().enumerate().rev() { let loc = Machine::get_param_location(1 + i); match loc { Location::GPR(x) => { @@ -1396,6 +1396,8 @@ impl FunctionCodeGenerator for X64FunctionCode { .machine .init_locals(a, self.num_locals, self.num_params); + a.emit_sub(Size::S64, Location::Imm32(32), Location::GPR(GPR::RSP)); // simulate "red zone" if not supported by the platform + self.control_stack.push(ControlFrame { label: a.get_label(), loop_like: false,