| ... | @@ -1464,9 +1464,8 @@ pub const DeclGen = struct { | ... | @@ -1464,9 +1464,8 @@ pub const DeclGen = struct { |
| 1464 | | 1464 | |
| 1465 | if (struct_obj.layout == .Packed) { | 1465 | if (struct_obj.layout == .Packed) { |
| 1466 | const target = dg.module.getTarget(); | 1466 | const target = dg.module.getTarget(); |
| 1467 | var int_ty_buf: Type.Payload.Bits = undefined; | 1467 | const big_bits = struct_obj.packedIntegerBits(target); |
| 1468 | const int_ty = struct_obj.packedIntegerType(target, &int_ty_buf); | 1468 | const int_llvm_ty = dg.context.intType(big_bits); |
| 1469 | const int_llvm_ty = try dg.llvmType(int_ty); | | |
| 1470 | const fields = struct_obj.fields.values(); | 1469 | const fields = struct_obj.fields.values(); |
| 1471 | comptime assert(Type.packed_struct_layout_version == 2); | 1470 | comptime assert(Type.packed_struct_layout_version == 2); |
| 1472 | var running_int: *const llvm.Value = int_llvm_ty.constNull(); | 1471 | var running_int: *const llvm.Value = int_llvm_ty.constNull(); |
| ... | @@ -1483,7 +1482,10 @@ pub const DeclGen = struct { | ... | @@ -1483,7 +1482,10 @@ pub const DeclGen = struct { |
| 1483 | const small_int_ty = dg.context.intType(ty_bit_size); | 1482 | const small_int_ty = dg.context.intType(ty_bit_size); |
| 1484 | const small_int_val = non_int_val.constBitCast(small_int_ty); | 1483 | const small_int_val = non_int_val.constBitCast(small_int_ty); |
| 1485 | const shift_rhs = int_llvm_ty.constInt(running_bits, .False); | 1484 | const shift_rhs = int_llvm_ty.constInt(running_bits, .False); |
| 1486 | const extended_int_val = small_int_val.constZExt(int_llvm_ty); | 1485 | // If the field is as large as the entire packed struct, this |
| | 1486 | // zext would go from, e.g. i16 to i16. This is legal with |
| | 1487 | // constZExtOrBitCast but not legal with constZExt. |
| | 1488 | const extended_int_val = small_int_val.constZExtOrBitCast(int_llvm_ty); |
| 1487 | const shifted = extended_int_val.constShl(shift_rhs); | 1489 | const shifted = extended_int_val.constShl(shift_rhs); |
| 1488 | running_int = running_int.constOr(shifted); | 1490 | running_int = running_int.constOr(shifted); |
| 1489 | running_bits += ty_bit_size; | 1491 | running_bits += ty_bit_size; |
| ... | @@ -4830,7 +4832,7 @@ pub const FuncGen = struct { | ... | @@ -4830,7 +4832,7 @@ pub const FuncGen = struct { |
| 4830 | index_type.constInt(@boolToInt(layout.tag_align < layout.payload_align), .False), | 4832 | index_type.constInt(@boolToInt(layout.tag_align < layout.payload_align), .False), |
| 4831 | }; | 4833 | }; |
| 4832 | const field_ptr = self.builder.buildInBoundsGEP(casted_ptr, &indices, indices.len, ""); | 4834 | const field_ptr = self.builder.buildInBoundsGEP(casted_ptr, &indices, indices.len, ""); |
| 4833 | const llvm_tag = union_llvm_ty.constInt(extra.field_index, .False); | 4835 | const llvm_tag = tag_llvm_ty.constInt(extra.field_index, .False); |
| 4834 | const store_inst = self.builder.buildStore(llvm_tag, field_ptr); | 4836 | const store_inst = self.builder.buildStore(llvm_tag, field_ptr); |
| 4835 | store_inst.setAlignment(union_obj.tag_ty.abiAlignment(target)); | 4837 | store_inst.setAlignment(union_obj.tag_ty.abiAlignment(target)); |
| 4836 | } | 4838 | } |