| ... | ... | @@ -5865,19 +5865,34 @@ pub const FuncGen = struct { |
| 5865 | 5865 | const array_ty = self.air.typeOf(bin_op.lhs); |
| 5866 | 5866 | const array_llvm_val = try self.resolveInst(bin_op.lhs); |
| 5867 | 5867 | const rhs = try self.resolveInst(bin_op.rhs); |
| 5868 | const array_llvm_ty = try self.dg.lowerType(array_ty); |
| 5869 | const elem_ty = array_ty.childType(); |
| 5868 | 5870 | if (isByRef(array_ty)) { |
| 5869 | | const array_llvm_ty = try self.dg.lowerType(array_ty); |
| 5870 | 5871 | const indices: [2]*llvm.Value = .{ self.context.intType(32).constNull(), rhs }; |
| 5871 | | const elem_ptr = self.builder.buildInBoundsGEP(array_llvm_ty, array_llvm_val, &indices, indices.len, ""); |
| 5872 | | const elem_ty = array_ty.childType(); |
| 5873 | 5872 | if (isByRef(elem_ty)) { |
| 5873 | const elem_ptr = self.builder.buildInBoundsGEP(array_llvm_ty, array_llvm_val, &indices, indices.len, ""); |
| 5874 | 5874 | if (canElideLoad(self, body_tail)) |
| 5875 | 5875 | return elem_ptr; |
| 5876 | 5876 | |
| 5877 | 5877 | const target = self.dg.module.getTarget(); |
| 5878 | 5878 | return self.loadByRef(elem_ptr, elem_ty, elem_ty.abiAlignment(target), false); |
| 5879 | 5879 | } else { |
| 5880 | const lhs_index = Air.refToIndex(bin_op.lhs).?; |
| 5880 | 5881 | const elem_llvm_ty = try self.dg.lowerType(elem_ty); |
| 5882 | if (self.air.instructions.items(.tag)[lhs_index] == .load) { |
| 5883 | const load_data = self.air.instructions.items(.data)[lhs_index]; |
| 5884 | const load_ptr = load_data.ty_op.operand; |
| 5885 | const load_ptr_tag = self.air.instructions.items(.tag)[Air.refToIndex(load_ptr).?]; |
| 5886 | switch (load_ptr_tag) { |
| 5887 | .struct_field_ptr, .struct_field_ptr_index_0, .struct_field_ptr_index_1, .struct_field_ptr_index_2, .struct_field_ptr_index_3 => { |
| 5888 | const load_ptr_inst = try self.resolveInst(load_ptr); |
| 5889 | const gep = self.builder.buildInBoundsGEP(array_llvm_ty, load_ptr_inst, &indices, indices.len, ""); |
| 5890 | return self.builder.buildLoad(elem_llvm_ty, gep, ""); |
| 5891 | }, |
| 5892 | else => {}, |
| 5893 | } |
| 5894 | } |
| 5895 | const elem_ptr = self.builder.buildInBoundsGEP(array_llvm_ty, array_llvm_val, &indices, indices.len, ""); |
| 5881 | 5896 | return self.builder.buildLoad(elem_llvm_ty, elem_ptr, ""); |
| 5882 | 5897 | } |
| 5883 | 5898 | } |