From c5ec8aba4f3cbc312cbc1d35e69c71f7f27ee4ab Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 17 Oct 2023 06:40:16 -0400 Subject: [PATCH] Fix to_cc_type a bit --- crates/compiler/gen_llvm/src/llvm/build.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/compiler/gen_llvm/src/llvm/build.rs b/crates/compiler/gen_llvm/src/llvm/build.rs index 9fffb3b152c..859efd20e70 100644 --- a/crates/compiler/gen_llvm/src/llvm/build.rs +++ b/crates/compiler/gen_llvm/src/llvm/build.rs @@ -5910,8 +5910,18 @@ fn to_cc_type<'a, 'ctx>( layout_interner: &STLayoutInterner<'a>, layout: InLayout<'a>, ) -> BasicTypeEnum<'ctx> { - match layout_interner.runtime_representation(layout) { + let layout_repr = layout_interner.runtime_representation(layout); + match layout_repr { LayoutRepr::Builtin(builtin) => to_cc_type_builtin(env, &builtin), + LayoutRepr::Struct(_) => { + let stack_type = basic_type_from_layout(env, layout_interner, layout_repr); + + if layout_repr.is_passed_by_reference(layout_interner) { + stack_type.ptr_type(AddressSpace::default()).into() + } else { + stack_type + } + } _ => { // TODO this is almost certainly incorrect for bigger structs basic_type_from_layout(env, layout_interner, layout_interner.get_repr(layout))