| ... | @@ -9051,7 +9051,7 @@ pub const FuncGen = struct { | ... | @@ -9051,7 +9051,7 @@ pub const FuncGen = struct { |
| 9051 | } | 9051 | } |
| 9052 | }, | 9052 | }, |
| 9053 | }, | 9053 | }, |
| 9054 | .Union => return self.unionFieldPtr(inst, struct_ptr, struct_ty, field_index), | 9054 | .Union => return self.unionFieldPtr(inst, struct_ptr, struct_ty), |
| 9055 | else => unreachable, | 9055 | else => unreachable, |
| 9056 | } | 9056 | } |
| 9057 | } | 9057 | } |
| ... | @@ -9061,16 +9061,13 @@ pub const FuncGen = struct { | ... | @@ -9061,16 +9061,13 @@ pub const FuncGen = struct { |
| 9061 | inst: Air.Inst.Index, | 9061 | inst: Air.Inst.Index, |
| 9062 | union_ptr: *const llvm.Value, | 9062 | union_ptr: *const llvm.Value, |
| 9063 | union_ty: Type, | 9063 | union_ty: Type, |
| 9064 | field_index: c_uint, | | |
| 9065 | ) !?*const llvm.Value { | 9064 | ) !?*const llvm.Value { |
| 9066 | const union_obj = union_ty.cast(Type.Payload.Union).?.data; | | |
| 9067 | const field = &union_obj.fields.values()[field_index]; | | |
| 9068 | const result_llvm_ty = try self.dg.lowerType(self.air.typeOfIndex(inst)); | 9065 | const result_llvm_ty = try self.dg.lowerType(self.air.typeOfIndex(inst)); |
| 9069 | if (!field.ty.hasRuntimeBitsIgnoreComptime()) { | | |
| 9070 | return null; | | |
| 9071 | } | | |
| 9072 | const target = self.dg.module.getTarget(); | 9066 | const target = self.dg.module.getTarget(); |
| 9073 | const layout = union_ty.unionGetLayout(target); | 9067 | const layout = union_ty.unionGetLayout(target); |
| | 9068 | if (layout.payload_size == 0) { |
| | 9069 | return self.builder.buildBitCast(union_ptr, result_llvm_ty, ""); |
| | 9070 | } |
| 9074 | const payload_index = @boolToInt(layout.tag_align >= layout.payload_align); | 9071 | const payload_index = @boolToInt(layout.tag_align >= layout.payload_align); |
| 9075 | const union_field_ptr = self.builder.buildStructGEP(union_ptr, payload_index, ""); | 9072 | const union_field_ptr = self.builder.buildStructGEP(union_ptr, payload_index, ""); |
| 9076 | return self.builder.buildBitCast(union_field_ptr, result_llvm_ty, ""); | 9073 | return self.builder.buildBitCast(union_field_ptr, result_llvm_ty, ""); |