From f0f720a86aeb60ff6e15db0dfd1d8b8a0059d2b6 Mon Sep 17 00:00:00 2001 From: Folkert Date: Thu, 1 Sep 2022 20:12:55 +0200 Subject: [PATCH 1/2] pass by pointer more on windows --- crates/compiler/gen_llvm/src/llvm/build.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/compiler/gen_llvm/src/llvm/build.rs b/crates/compiler/gen_llvm/src/llvm/build.rs index b825be718d..2cb4647185 100644 --- a/crates/compiler/gen_llvm/src/llvm/build.rs +++ b/crates/compiler/gen_llvm/src/llvm/build.rs @@ -6686,7 +6686,11 @@ impl<'ctx> FunctionSpec<'ctx> { /// According to the C ABI, how should we return a value with the given layout? pub fn to_cc_return<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>, layout: &Layout<'a>) -> CCReturn { let return_size = layout.stack_size(env.target_info); - let pass_result_by_pointer = return_size > 2 * env.target_info.ptr_width() as u32; + let pass_result_by_pointer = match env.target_info.operating_system { + roc_target::OperatingSystem::Windows => return_size >= env.target_info.ptr_width() as u32, + roc_target::OperatingSystem::Unix => return_size > 2 * env.target_info.ptr_width() as u32, + roc_target::OperatingSystem::Wasi => unreachable!(), + }; if return_size == 0 { CCReturn::Void From d99fdb3831579fd70056c742c72bd59e3d0ed594 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 3 Sep 2022 12:42:13 +0200 Subject: [PATCH 2/2] change the cutoff for when a pointer is used on windows --- crates/compiler/gen_llvm/src/llvm/build.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/compiler/gen_llvm/src/llvm/build.rs b/crates/compiler/gen_llvm/src/llvm/build.rs index cdf53f5534..232376ee21 100644 --- a/crates/compiler/gen_llvm/src/llvm/build.rs +++ b/crates/compiler/gen_llvm/src/llvm/build.rs @@ -6720,7 +6720,9 @@ impl<'ctx> FunctionSpec<'ctx> { pub fn to_cc_return<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>, layout: &Layout<'a>) -> CCReturn { let return_size = layout.stack_size(env.layout_interner, env.target_info); let pass_result_by_pointer = match env.target_info.operating_system { - roc_target::OperatingSystem::Windows => return_size >= env.target_info.ptr_width() as u32, + roc_target::OperatingSystem::Windows => { + return_size >= 2 * env.target_info.ptr_width() as u32 + } roc_target::OperatingSystem::Unix => return_size > 2 * env.target_info.ptr_width() as u32, roc_target::OperatingSystem::Wasi => unreachable!(), };