| ... | ... | @@ -2893,8 +2893,8 @@ pub const Object = struct { |
| 2893 | 2893 | o.gpa, |
| 2894 | 2894 | try o.builder.arrayType(padding_len, .i8), |
| 2895 | 2895 | ); |
| 2896 | | if (@ctz(offset) < max_field_ty_align.toLog2Units()) { |
| 2897 | | struct_kind = .@"packed"; // prevent unexpected trailing padding |
| 2896 | if (struct_type.alignment.compareStrict(.lt, max_field_ty_align)) { |
| 2897 | struct_kind = .@"packed"; // prevent wrong alignment |
| 2898 | 2898 | } |
| 2899 | 2899 | } |
| 2900 | 2900 | |
| ... | ... | @@ -2973,6 +2973,14 @@ pub const Object = struct { |
| 2973 | 2973 | const aligned_field_ty = Type.fromInterned(union_obj.field_types.get(ip)[layout.most_aligned_field]); |
| 2974 | 2974 | const aligned_field_llvm_ty = try o.lowerType(aligned_field_ty, repr); |
| 2975 | 2975 | |
| 2976 | const struct_kind: Builder.Type.Structure.Kind = for (union_obj.field_types.get(ip)) |field_ty_ip| { |
| 2977 | const field_ty = Type.fromInterned(field_ty_ip); |
| 2978 | if (!field_ty.hasRuntimeBits(zcu)) continue; |
| 2979 | if (layout.payload_align.compareStrict(.lt, field_ty.abiAlignment(zcu))) { |
| 2980 | break .@"packed"; // prevent wrong alignment |
| 2981 | } |
| 2982 | } else .normal; |
| 2983 | |
| 2976 | 2984 | const payload_ty = ty: { |
| 2977 | 2985 | if (layout.most_aligned_field_size == layout.payload_size) { |
| 2978 | 2986 | break :ty aligned_field_llvm_ty; |
| ... | ... | @@ -2993,7 +3001,7 @@ pub const Object = struct { |
| 2993 | 3001 | |
| 2994 | 3002 | o.builder.namedTypeSetBody( |
| 2995 | 3003 | ty, |
| 2996 | | try o.builder.structType(.normal, &.{payload_ty}), |
| 3004 | try o.builder.structType(struct_kind, &.{payload_ty}), |
| 2997 | 3005 | ); |
| 2998 | 3006 | return ty; |
| 2999 | 3007 | } |
| ... | ... | @@ -3021,7 +3029,7 @@ pub const Object = struct { |
| 3021 | 3029 | |
| 3022 | 3030 | o.builder.namedTypeSetBody( |
| 3023 | 3031 | ty, |
| 3024 | | try o.builder.structType(.normal, llvm_fields[0..llvm_fields_len]), |
| 3032 | try o.builder.structType(struct_kind, llvm_fields[0..llvm_fields_len]), |
| 3025 | 3033 | ); |
| 3026 | 3034 | return ty; |
| 3027 | 3035 | }, |