diff --git a/compiler/gen_llvm/src/llvm/build.rs b/compiler/gen_llvm/src/llvm/build.rs index 0ce8640365..54852a42a9 100644 --- a/compiler/gen_llvm/src/llvm/build.rs +++ b/compiler/gen_llvm/src/llvm/build.rs @@ -672,7 +672,7 @@ fn promote_to_main_function<'a, 'ctx, 'env>( top_level: ProcLayout<'a>, ) -> (&'static str, FunctionValue<'ctx>) { let it = top_level.arguments.iter().copied(); - let bytes = roc_mono::alias_analysis::func_name_bytes_help(symbol, it, top_level.result); + let bytes = roc_mono::alias_analysis::func_name_bytes_help(symbol, it, &top_level.result); let func_name = FuncName(&bytes); let func_solutions = mod_solutions.func_solutions(func_name).unwrap(); @@ -4150,7 +4150,7 @@ pub fn build_proc<'a, 'ctx, 'env>( let bytes = roc_mono::alias_analysis::func_name_bytes_help( symbol, it, - top_level.result, + &top_level.result, ); let func_name = FuncName(&bytes); let func_solutions = mod_solutions.func_solutions(func_name).unwrap(); diff --git a/compiler/mono/src/alias_analysis.rs b/compiler/mono/src/alias_analysis.rs index 048b860565..0d6620b0be 100644 --- a/compiler/mono/src/alias_analysis.rs +++ b/compiler/mono/src/alias_analysis.rs @@ -24,7 +24,7 @@ pub const STATIC_LIST_NAME: ConstName = ConstName(b"THIS IS A STATIC LIST"); const ENTRY_POINT_NAME: &[u8] = b"mainForHost"; pub fn func_name_bytes(proc: &Proc) -> [u8; SIZE] { - func_name_bytes_help(proc.name, proc.args.iter().map(|x| x.0), proc.ret_layout) + func_name_bytes_help(proc.name, proc.args.iter().map(|x| x.0), &proc.ret_layout) } const DEBUG: bool = false; @@ -53,7 +53,7 @@ impl TagUnionId { pub fn func_name_bytes_help<'a, I>( symbol: Symbol, argument_layouts: I, - return_layout: Layout<'a>, + return_layout: &Layout<'a>, ) -> [u8; SIZE] where I: Iterator>, @@ -162,13 +162,13 @@ where match layout { RawFunctionLayout::Function(_, _, _) => { let it = top_level.arguments.iter().copied(); - let bytes = func_name_bytes_help(*symbol, it, top_level.result); + let bytes = func_name_bytes_help(*symbol, it, &top_level.result); host_exposed_functions.push((bytes, top_level.arguments)); } RawFunctionLayout::ZeroArgumentThunk(_) => { let it = std::iter::once(Layout::Struct(&[])); - let bytes = func_name_bytes_help(*symbol, it, top_level.result); + let bytes = func_name_bytes_help(*symbol, it, &top_level.result); host_exposed_functions.push((bytes, top_level.arguments)); } @@ -196,7 +196,7 @@ where let roc_main_bytes = func_name_bytes_help( entry_point.symbol, entry_point.layout.arguments.iter().copied(), - entry_point.layout.result, + &entry_point.layout.result, ); let roc_main = FuncName(&roc_main_bytes); @@ -660,7 +660,7 @@ fn call_spec( let arg_value_id = build_tuple_value(builder, env, block, call.arguments)?; let it = arg_layouts.iter().copied(); - let bytes = func_name_bytes_help(*symbol, it, *ret_layout); + let bytes = func_name_bytes_help(*symbol, it, ret_layout); let name = FuncName(&bytes); let module = MOD_APP; builder.add_call(block, spec_var, module, name, arg_value_id) @@ -708,7 +708,7 @@ fn call_spec( let update_mode_var = UpdateModeVar(&mode); let it = arg_layouts.iter().copied(); - let bytes = func_name_bytes_help(*function_name, it, *ret_layout); + let bytes = func_name_bytes_help(*function_name, it, ret_layout); let name = FuncName(&bytes); let module = MOD_APP; diff --git a/compiler/mono/src/borrow.rs b/compiler/mono/src/borrow.rs index f7bcd2a59f..0b6d6531c1 100644 --- a/compiler/mono/src/borrow.rs +++ b/compiler/mono/src/borrow.rs @@ -560,7 +560,7 @@ impl<'a> BorrowInfState<'a> { arg_layouts, .. } => { - let top_level = ProcLayout::new(self.arena, arg_layouts, *ret_layout); + let top_level = ProcLayout::new(self.arena, arg_layouts, **ret_layout); // get the borrow signature of the applied function let ps = param_map @@ -795,7 +795,7 @@ impl<'a> BorrowInfState<'a> { Stmt::Ret(z), ) = (v, b) { - let top_level = ProcLayout::new(self.arena, arg_layouts, *ret_layout); + let top_level = ProcLayout::new(self.arena, arg_layouts, **ret_layout); if self.current_proc == *g && x == *z { // anonymous functions (for which the ps may not be known) diff --git a/compiler/mono/src/inc_dec.rs b/compiler/mono/src/inc_dec.rs index c180432907..63604bf205 100644 --- a/compiler/mono/src/inc_dec.rs +++ b/compiler/mono/src/inc_dec.rs @@ -667,7 +667,7 @@ impl<'a> Context<'a> { arg_layouts, .. } => { - let top_level = ProcLayout::new(self.arena, arg_layouts, *ret_layout); + let top_level = ProcLayout::new(self.arena, arg_layouts, **ret_layout); // get the borrow signature let ps = self diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index b759e83006..7e225772f5 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -28,11 +28,11 @@ pub const PRETTY_PRINT_IR_SYMBOLS: bool = false; // please change it to the lower number. // if it went up, maybe check that the change is really required static_assertions::assert_eq_size!([u8; 3 * 8], Literal); -static_assertions::assert_eq_size!([u8; 13 * 8], Expr); +static_assertions::assert_eq_size!([u8; 11 * 8], Expr); static_assertions::assert_eq_size!([u8; 22 * 8], Stmt); static_assertions::assert_eq_size!([u8; 7 * 8], ProcLayout); -static_assertions::assert_eq_size!([u8; 12 * 8], Call); -static_assertions::assert_eq_size!([u8; 10 * 8], CallType); +static_assertions::assert_eq_size!([u8; 8 * 8], Call); +static_assertions::assert_eq_size!([u8; 6 * 8], CallType); macro_rules! return_on_layout_error { ($env:expr, $layout_result:expr) => { @@ -1128,7 +1128,7 @@ impl UpdateModeId { pub enum CallType<'a> { ByName { name: Symbol, - ret_layout: Layout<'a>, + ret_layout: &'a Layout<'a>, arg_layouts: &'a [Layout<'a>], specialization_id: CallSpecId, }, @@ -2027,7 +2027,7 @@ fn specialize_external<'a>( Symbol::ARG_CLOSURE, argument_symbols.into_bump_slice(), argument_layouts, - *return_layout, + return_layout, assigned, hole, ); @@ -3871,7 +3871,7 @@ pub fn with_hole<'a>( closure_data_symbol, arg_symbols, arg_layouts, - *ret_layout, + ret_layout, assigned, hole, ); @@ -3898,7 +3898,7 @@ pub fn with_hole<'a>( closure_data_symbol, arg_symbols, arg_layouts, - *ret_layout, + ret_layout, assigned, hole, ); @@ -6107,7 +6107,7 @@ fn force_thunk<'a>( let call = self::Call { call_type: CallType::ByName { name: thunk_name, - ret_layout: layout, + ret_layout: env.arena.alloc(layout), arg_layouts: &[], specialization_id: env.next_call_specialization_id(), }, @@ -6472,7 +6472,7 @@ fn call_by_name<'a>( closure_data_symbol, arg_symbols, arg_layouts, - *ret_layout, + ret_layout, assigned, hole, ); @@ -6596,7 +6596,7 @@ fn call_by_name_help<'a>( let call = self::Call { call_type: CallType::ByName { name: proc_name, - ret_layout: *ret_layout, + ret_layout: ret_layout, arg_layouts: argument_layouts, specialization_id: env.next_call_specialization_id(), }, @@ -6637,7 +6637,7 @@ fn call_by_name_help<'a>( let call = self::Call { call_type: CallType::ByName { name: proc_name, - ret_layout: *ret_layout, + ret_layout: ret_layout, arg_layouts: argument_layouts, specialization_id: env.next_call_specialization_id(), }, @@ -6691,7 +6691,7 @@ fn call_by_name_help<'a>( let call = self::Call { call_type: CallType::ByName { name: proc_name, - ret_layout: *ret_layout, + ret_layout: ret_layout, arg_layouts: argument_layouts, specialization_id: env.next_call_specialization_id(), }, @@ -6939,7 +6939,7 @@ fn call_specialized_proc<'a>( let call = self::Call { call_type: CallType::ByName { name: proc_name, - ret_layout: function_layout.result, + ret_layout: env.arena.alloc(function_layout.result), arg_layouts: function_layout.arguments, specialization_id: env.next_call_specialization_id(), }, @@ -6982,7 +6982,7 @@ fn call_specialized_proc<'a>( closure_data_symbol, field_symbols, argument_layouts.into_bump_slice(), - function_layout.result, + env.arena.alloc(function_layout.result), assigned, hole, ); @@ -7012,7 +7012,7 @@ fn call_specialized_proc<'a>( let call = self::Call { call_type: CallType::ByName { name: proc_name, - ret_layout: function_layout.result, + ret_layout: env.arena.alloc(function_layout.result), arg_layouts: function_layout.arguments, specialization_id: env.next_call_specialization_id(), }, @@ -8096,7 +8096,7 @@ fn match_on_lambda_set<'a>( closure_data_symbol: Symbol, argument_symbols: &'a [Symbol], argument_layouts: &'a [Layout<'a>], - return_layout: Layout<'a>, + return_layout: &'a Layout<'a>, assigned: Symbol, hole: &'a Stmt<'a>, ) -> Stmt<'a> { @@ -8193,7 +8193,7 @@ fn union_lambda_set_to_switch<'a>( closure_data_symbol: Symbol, argument_symbols: &'a [Symbol], argument_layouts: &'a [Layout<'a>], - return_layout: Layout<'a>, + return_layout: &'a Layout<'a>, assigned: Symbol, hole: &'a Stmt<'a>, ) -> Stmt<'a> { @@ -8237,12 +8237,12 @@ fn union_lambda_set_to_switch<'a>( cond_layout: closure_tag_id_layout, branches: branches.into_bump_slice(), default_branch, - ret_layout: return_layout, + ret_layout: *return_layout, }; let param = Param { symbol: assigned, - layout: return_layout, + layout: *return_layout, borrow: false, }; @@ -8264,7 +8264,7 @@ fn union_lambda_set_branch<'a>( closure_data_layout: Layout<'a>, argument_symbols_slice: &'a [Symbol], argument_layouts_slice: &'a [Layout<'a>], - return_layout: Layout<'a>, + return_layout: &'a Layout<'a>, ) -> Stmt<'a> { let result_symbol = env.unique_symbol(); @@ -8293,7 +8293,7 @@ fn union_lambda_set_branch_help<'a>( closure_data_layout: Layout<'a>, argument_symbols_slice: &'a [Symbol], argument_layouts_slice: &'a [Layout<'a>], - return_layout: Layout<'a>, + return_layout: &'a Layout<'a>, assigned: Symbol, hole: &'a Stmt<'a>, ) -> Stmt<'a> { @@ -8339,7 +8339,7 @@ fn union_lambda_set_branch_help<'a>( arguments: argument_symbols, }; - build_call(env, call, assigned, return_layout, hole) + build_call(env, call, assigned, *return_layout, hole) } #[allow(clippy::too_many_arguments)] @@ -8351,7 +8351,7 @@ fn enum_lambda_set_to_switch<'a>( closure_data_symbol: Symbol, argument_symbols: &'a [Symbol], argument_layouts: &'a [Layout<'a>], - return_layout: Layout<'a>, + return_layout: &'a Layout<'a>, assigned: Symbol, hole: &'a Stmt<'a>, ) -> Stmt<'a> { @@ -8388,12 +8388,12 @@ fn enum_lambda_set_to_switch<'a>( cond_layout: closure_tag_id_layout, branches: branches.into_bump_slice(), default_branch, - ret_layout: return_layout, + ret_layout: *return_layout, }; let param = Param { symbol: assigned, - layout: return_layout, + layout: *return_layout, borrow: false, }; @@ -8414,7 +8414,7 @@ fn enum_lambda_set_branch<'a>( closure_data_layout: Layout<'a>, argument_symbols_slice: &'a [Symbol], argument_layouts_slice: &'a [Layout<'a>], - return_layout: Layout<'a>, + return_layout: &'a Layout<'a>, ) -> Stmt<'a> { let result_symbol = env.unique_symbol(); @@ -8455,7 +8455,7 @@ fn enum_lambda_set_branch<'a>( }, arguments: argument_symbols, }; - build_call(env, call, assigned, return_layout, env.arena.alloc(hole)) + build_call(env, call, assigned, *return_layout, env.arena.alloc(hole)) } #[allow(clippy::too_many_arguments)]