From a286dec4cc0c2190ad09a73b08a2f934ed1d2a43 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 20 Mar 2020 22:38:28 -0400 Subject: [PATCH] Reorganize some things --- compiler/gen/src/llvm/build.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/gen/src/llvm/build.rs b/compiler/gen/src/llvm/build.rs index f20914ac20..89b65d06c7 100644 --- a/compiler/gen/src/llvm/build.rs +++ b/compiler/gen/src/llvm/build.rs @@ -1101,7 +1101,6 @@ fn call_with_args<'a, 'ctx, 'env>( debug_assert!(args.len() == 3); - let elem_index = args[1].0.into_int_value(); let (elem, elem_layout) = args[2]; let (wrapper_struct, array_data_ptr) = { // This original wrapper_struct should only stay in scope long enough to clone it. @@ -1126,6 +1125,7 @@ fn call_with_args<'a, 'ctx, 'env>( let elem_size = env.ptr_int().const_int(elem_bytes, false); // Calculate the offset at runtime by multiplying the index by the size of an element. + let elem_index = args[1].0.into_int_value(); let offset_bytes = builder.build_int_mul(elem_index, elem_size, "mul_offset"); // We already checked the bounds earlier. @@ -1135,8 +1135,8 @@ fn call_with_args<'a, 'ctx, 'env>( // Mutate the array in-place. builder.build_store(elem_ptr, elem); - // Return the wrapper unchanged, since pointer, length and capacity are all unchanged - wrapper_struct.into() + // Return the cloned wrapper + BasicValueEnum::StructValue(wrapper_struct) } Symbol::LIST_SET_IN_PLACE => { let builder = env.builder; @@ -1169,8 +1169,8 @@ fn call_with_args<'a, 'ctx, 'env>( // Mutate the array in-place. builder.build_store(elem_ptr, elem); - // Return the wrapper unchanged, since pointer, length and capacity are all unchanged - wrapper_struct.into() + // Return the wrapper unchanged, since pointer and length are unchanged + BasicValueEnum::StructValue(wrapper_struct) } _ => { let fn_val = env