Merge pull request #7317 from roc-lang/ayaz/fix-pass-by-reference

Fix pass by reference for compare fn
This commit is contained in:
Luke Boswell 2024-12-08 21:25:52 +11:00 committed by GitHub
commit f0cc363b53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -12,8 +12,8 @@ use crate::llvm::refcounting::{
use inkwell::attributes::{Attribute, AttributeLoc}; use inkwell::attributes::{Attribute, AttributeLoc};
use inkwell::types::{BasicType, BasicTypeEnum, StructType}; use inkwell::types::{BasicType, BasicTypeEnum, StructType};
use inkwell::values::{ use inkwell::values::{
BasicValue, BasicValueEnum, CallSiteValue, FunctionValue, InstructionValue, IntValue, BasicMetadataValueEnum, BasicValue, BasicValueEnum, CallSiteValue, FunctionValue,
PointerValue, StructValue, InstructionValue, IntValue, PointerValue, StructValue,
}; };
use inkwell::AddressSpace; use inkwell::AddressSpace;
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
@ -726,13 +726,18 @@ pub fn build_compare_wrapper<'a, 'ctx>(
"load_opaque", "load_opaque",
); );
let closure_data = let closure_data: BasicMetadataValueEnum =
if layout_interner.is_passed_by_reference(closure_data_repr) {
closure_cast.into()
} else {
env.builder env.builder
.new_build_load(closure_type, closure_cast, "load_opaque"); .new_build_load(closure_type, closure_cast, "load_opaque")
.into()
};
env.arena env.arena
.alloc([value1.into(), value2.into(), closure_data.into()]) .alloc([value1.into(), value2.into(), closure_data])
as &[_] as &[BasicMetadataValueEnum]
} }
}; };