diff --git a/compiler/gen/src/llvm/build.rs b/compiler/gen/src/llvm/build.rs index 4908b1684f..a7526a1b26 100644 --- a/compiler/gen/src/llvm/build.rs +++ b/compiler/gen/src/llvm/build.rs @@ -1877,6 +1877,8 @@ fn run_low_level<'a, 'ctx, 'env>( ListSetInPlace => { let (list_symbol, list_layout) = load_symbol_and_layout(env, scope, &args[0]); + let output_inplace = get_inplace_from_layout(layout); + list_set( parent, &[ @@ -1886,6 +1888,7 @@ fn run_low_level<'a, 'ctx, 'env>( ], env, InPlace::InPlace, + output_inplace, ) } ListSet => { @@ -1897,8 +1900,10 @@ fn run_low_level<'a, 'ctx, 'env>( (load_symbol_and_layout(env, scope, &args[2])), ]; - let in_place = || list_set(parent, arguments, env, InPlace::InPlace); - let clone = || list_set(parent, arguments, env, InPlace::Clone); + let output_inplace = get_inplace_from_layout(layout); + + let in_place = || list_set(parent, arguments, env, InPlace::InPlace, output_inplace); + let clone = || list_set(parent, arguments, env, InPlace::Clone, output_inplace); let empty = || list_symbol; maybe_inplace_list( diff --git a/compiler/gen/src/llvm/build_list.rs b/compiler/gen/src/llvm/build_list.rs index a6cc41ddf3..d463824271 100644 --- a/compiler/gen/src/llvm/build_list.rs +++ b/compiler/gen/src/llvm/build_list.rs @@ -642,7 +642,8 @@ pub fn list_set<'a, 'ctx, 'env>( parent: FunctionValue<'ctx>, args: &[(BasicValueEnum<'ctx>, &'a Layout<'a>)], env: &Env<'a, 'ctx, 'env>, - inplace: InPlace, + input_inplace: InPlace, + output_inplace: InPlace, ) -> BasicValueEnum<'ctx> { let builder = env.builder; @@ -664,14 +665,15 @@ pub fn list_set<'a, 'ctx, 'env>( let ctx = env.context; let elem_type = basic_type_from_layout(env.arena, ctx, elem_layout, env.ptr_bytes); let ptr_type = get_ptr_type(&elem_type, AddressSpace::Generic); - let (new_wrapper, array_data_ptr) = match inplace { + + let (new_wrapper, array_data_ptr) = match input_inplace { InPlace::InPlace => ( original_wrapper, load_list_ptr(builder, original_wrapper, ptr_type), ), InPlace::Clone => clone_nonempty_list( env, - inplace, + output_inplace, list_len, load_list_ptr(builder, original_wrapper, ptr_type), elem_layout,