From 0a1e297b0f52facea598889bd732ed2c88b9ffaf Mon Sep 17 00:00:00 2001 From: Chad Stearns Date: Sun, 13 Sep 2020 13:31:57 -0400 Subject: [PATCH] Passed result layout down build expr function --- compiler/gen/src/llvm/build.rs | 8 +++++--- compiler/gen/src/llvm/build_list.rs | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/gen/src/llvm/build.rs b/compiler/gen/src/llvm/build.rs index 37a4c57cb6..956e60ef9b 100644 --- a/compiler/gen/src/llvm/build.rs +++ b/compiler/gen/src/llvm/build.rs @@ -298,6 +298,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>( layout_ids: &mut LayoutIds<'a>, scope: &Scope<'a, 'ctx>, parent: FunctionValue<'ctx>, + layout: &Layout<'a>, expr: &roc_mono::ir::Expr<'a>, ) -> BasicValueEnum<'ctx> { use roc_mono::ir::CallType::*; @@ -305,7 +306,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>( match expr { Literal(literal) => build_exp_literal(env, literal), - RunLowLevel(op, symbols) => run_low_level(env, scope, parent, *op, symbols), + RunLowLevel(op, symbols) => run_low_level(env, scope, parent, layout, *op, symbols), FunctionCall { call_type: ByName(name), @@ -832,7 +833,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>( Let(symbol, expr, layout, cont) => { let context = &env.context; - let val = build_exp_expr(env, layout_ids, &scope, parent, &expr); + let val = build_exp_expr(env, layout_ids, &scope, parent, layout, &expr); let expr_bt = if let Layout::RecursivePointer = layout { match expr { Expr::AccessAtIndex { field_layouts, .. } => { @@ -1496,6 +1497,7 @@ fn run_low_level<'a, 'ctx, 'env>( env: &Env<'a, 'ctx, 'env>, scope: &Scope<'a, 'ctx>, parent: FunctionValue<'ctx>, + layout: &Layout<'a>, op: LowLevel, args: &[Symbol], ) -> BasicValueEnum<'ctx> { @@ -1526,7 +1528,7 @@ fn run_low_level<'a, 'ctx, 'env>( let (arg, arg_layout) = load_symbol_and_layout(env, scope, &args[0]); - list_single(env, arg, arg_layout) + list_single(env, layout, arg, arg_layout) } ListRepeat => { // List.repeat : Int, elem -> List elem diff --git a/compiler/gen/src/llvm/build_list.rs b/compiler/gen/src/llvm/build_list.rs index 47cc194679..97ead29f59 100644 --- a/compiler/gen/src/llvm/build_list.rs +++ b/compiler/gen/src/llvm/build_list.rs @@ -17,6 +17,7 @@ fn get_list_element_type<'a, 'b>(layout: &'b Layout<'a>) -> Option<&'b Layout<'a /// List.single : a -> List a pub fn list_single<'a, 'ctx, 'env>( env: &Env<'a, 'ctx, 'env>, + layout: &Layout<'a>, elem: BasicValueEnum<'ctx>, elem_layout: &Layout<'a>, ) -> BasicValueEnum<'ctx> { @@ -1631,6 +1632,7 @@ pub fn clone_list<'a, 'ctx, 'env>( pub fn allocate_list<'a, 'ctx, 'env>( env: &Env<'a, 'ctx, 'env>, + // in_place: InPlace, elem_layout: &Layout<'a>, length: IntValue<'ctx>, ) -> PointerValue<'ctx> {