diff --git a/compiler/gen_llvm/src/llvm/build.rs b/compiler/gen_llvm/src/llvm/build.rs index dbaea34d79..07b14c45a9 100644 --- a/compiler/gen_llvm/src/llvm/build.rs +++ b/compiler/gen_llvm/src/llvm/build.rs @@ -1496,97 +1496,6 @@ pub fn build_exp_expr<'a, 'ctx, 'env>( } } - AccessAtIndex { - index, - structure, - field_layouts, - .. - } => { - use BasicValueEnum::*; - - let builder = env.builder; - - // Determine types, assumes the discriminant is in the field layouts - let num_fields = field_layouts.len(); - let mut field_types = Vec::with_capacity_in(num_fields, env.arena); - - for field_layout in field_layouts.iter() { - let field_type = basic_type_from_layout(env, &field_layout); - field_types.push(field_type); - } - - // cast the argument bytes into the desired shape for this tag - let (argument, structure_layout) = load_symbol_and_layout(scope, structure); - - match argument { - StructValue(value) => { - let struct_layout = Layout::Struct(field_layouts); - let struct_type = env - .context - .struct_type(field_types.into_bump_slice(), false); - - let struct_value = access_index_struct_value(builder, value, struct_type); - - let result = builder - .build_extract_value(struct_value, *index as u32, "") - .expect("desired field did not decode"); - - if let Some(Layout::RecursivePointer) = field_layouts.get(*index as usize) { - let desired_type = - block_of_memory(env.context, &struct_layout, env.ptr_bytes); - - // the value is a pointer to the actual value; load that value! - let ptr = env.builder.build_bitcast( - result, - desired_type.ptr_type(AddressSpace::Generic), - "cast_struct_value_pointer", - ); - - builder.build_load(ptr.into_pointer_value(), "load_recursive_field") - } else { - result - } - } - PointerValue(value) => match structure_layout { - Layout::Union(UnionLayout::NullableWrapped { .. }) if *index == 0 => { - panic!("this should not happen any more") - } - Layout::Union(UnionLayout::NullableUnwrapped { .. }) => { - if *index == 0 { - panic!("this should not happen any more") - } else { - let struct_type = env - .context - .struct_type(&field_types.into_bump_slice()[1..], false); - - lookup_at_index_ptr( - env, - &field_layouts[1..], - *index as usize - 1, - value, - struct_type, - structure_layout, - ) - } - } - _ => { - let struct_type = env - .context - .struct_type(field_types.into_bump_slice(), false); - - lookup_at_index_ptr( - env, - field_layouts, - *index as usize, - value, - struct_type, - structure_layout, - ) - } - }, - _ => panic!("cannot look up index in {:?}", argument), - } - } EmptyArray => empty_polymorphic_list(env), Array { elem_layout, elems } => list_literal(env, scope, elem_layout, elems), RuntimeErrorFunction(_) => todo!(), diff --git a/compiler/mono/src/decision_tree.rs b/compiler/mono/src/decision_tree.rs index 4883abd7fb..d8eccb0f87 100644 --- a/compiler/mono/src/decision_tree.rs +++ b/compiler/mono/src/decision_tree.rs @@ -1044,23 +1044,6 @@ fn path_to_expr_help<'a>( debug_assert_eq!(*tag_id, 0); debug_assert!(it.peek().is_none()); - let field_layouts = vec![layout]; - - debug_assert!(*index < field_layouts.len() as u64); - - debug_assert_eq!(field_layouts.len(), 1); - - let inner_expr = Expr::AccessAtIndex { - index: *index, - field_layouts: env.arena.alloc(field_layouts), - structure: symbol, - wrapped: Wrapped::SingleElementRecord, - }; - - // symbol = env.unique_symbol(); - // let inner_layout = layout; - // stores.push((symbol, inner_layout, inner_expr)); - break; } true => {