diff --git a/compiler/gen_llvm/src/llvm/convert.rs b/compiler/gen_llvm/src/llvm/convert.rs index 3b37bfa000..5f97a18f24 100644 --- a/compiler/gen_llvm/src/llvm/convert.rs +++ b/compiler/gen_llvm/src/llvm/convert.rs @@ -132,6 +132,15 @@ pub fn argument_type_from_layout<'a, 'ctx, 'env>( argument_type_from_layout(env, &lambda_set.runtime_representation()) } Union(union_layout) => argument_type_from_union_layout(env, union_layout), + Builtin(_) => { + let base = basic_type_from_layout(env, layout); + + if layout.is_passed_by_reference() { + base.ptr_type(AddressSpace::Generic).into() + } else { + base + } + } other => basic_type_from_layout(env, other), } } diff --git a/compiler/gen_llvm/src/llvm/refcounting.rs b/compiler/gen_llvm/src/llvm/refcounting.rs index 1bd968c118..0098432aa5 100644 --- a/compiler/gen_llvm/src/llvm/refcounting.rs +++ b/compiler/gen_llvm/src/llvm/refcounting.rs @@ -20,7 +20,7 @@ use roc_module::symbol::Symbol; use roc_mono::layout::{Builtin, Layout, LayoutIds, UnionLayout}; use roc_target::TargetInfo; -use super::convert::argument_type_from_union_layout; +use super::convert::{argument_type_from_layout, argument_type_from_union_layout}; /// "Infinite" reference count, for static values /// Ref counts are encoded as negative numbers where isize::MIN represents 1 @@ -687,7 +687,7 @@ fn modify_refcount_list<'a, 'ctx, 'env>( let function = match env.module.get_function(fn_name.as_str()) { Some(function_value) => function_value, None => { - let basic_type = basic_type_from_layout(env, layout); + let basic_type = argument_type_from_layout(env, layout); let function_value = build_header(env, basic_type, mode, &fn_name); modify_refcount_list_help( @@ -824,7 +824,7 @@ fn modify_refcount_str<'a, 'ctx, 'env>( let function = match env.module.get_function(fn_name.as_str()) { Some(function_value) => function_value, None => { - let basic_type = basic_type_from_layout(env, layout); + let basic_type = argument_type_from_layout(env, layout); let function_value = build_header(env, basic_type, mode, &fn_name); modify_refcount_str_help(env, mode, layout, function_value);