authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-01-22 16:30:15+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-03-10 10:26:07+00:00
log6e49697ef576e86799c8365492082fdee9d216a9
tree4d8a85516aff5399acf46ced92a7c055989e19b3
parent792830d69cd335a49de97b617d3f668aa544b181
signaturelock-open Commit is signed but in an unrecognized format.

backend progress

The x86_64 backend now compiles and, with `-fstrip`, kinda works!

6 files changed, 144 insertions(+), 145 deletions(-)

src/InternPool.zig+14
......@@ -4150,6 +4150,13 @@ pub const Index = enum(u32) {
41504150 const extra = ip.getLocalShared(slice.tid).extra.acquire();
41514151 return @ptrCast(extra.view().items(.@"0")[slice.start..][0..slice.len]);
41524152 }
4153
4154 /// If `slice` is empty (`slice.len == 0`), returns `.none`.
4155 /// Otherwise, asserts that `index < slice.len`, and returns the value at `index`.
4156 pub fn getOrNone(slice: Slice, ip: *const InternPool, index: usize) Index {
4157 if (slice.len == 0) return .none;
4158 return slice.get(ip)[index];
4159 }
41534160 };
41544161
41554162 /// Used for a map of `Index` values to the index within a list of `Index` values.
......@@ -5981,6 +5988,13 @@ pub const Alignment = enum(u6) {
59815988 const bytes: []u8 = @ptrCast(extra.view().items(.@"0")[slice.start..]);
59825989 return @ptrCast(bytes[0..slice.len]);
59835990 }
5991
5992 /// If `slice` is empty (`slice.len == 0`), returns `.none`.
5993 /// Otherwise, asserts that `index < slice.len`, and returns the value at `index`.
5994 pub fn getOrNone(slice: Slice, ip: *const InternPool, index: usize) Alignment {
5995 if (slice.len == 0) return .none;
5996 return slice.get(ip)[index];
5997 }
59845998 };
59855999
59866000 pub fn toRelaxedCompareUnits(a: Alignment) u8 {
src/Zcu/PerThread.zig+1
......@@ -4097,6 +4097,7 @@ pub fn getExtern(pt: Zcu.PerThread, key: InternPool.Key.Extern) Allocator.Error!
40974097}
40984098
40994099// TODO: this shouldn't need a `PerThread`! Fix the signature of `Type.abiAlignment`.
4100// MLUGG TODO: that's done, move it!
41004101pub fn navAlignment(pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) InternPool.Alignment {
41014102 const zcu = pt.zcu;
41024103 const ty: Type, const alignment = switch (zcu.intern_pool.getNav(nav_index).status) {
src/codegen.zig+37-55
......@@ -377,7 +377,7 @@ pub fn generateSymbol(
377377 .payload => 0,
378378 };
379379
380 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
380 if (!payload_ty.hasRuntimeBits(zcu)) {
381381 try w.writeInt(u16, err_val, endian);
382382 return;
383383 }
......@@ -610,7 +610,7 @@ pub fn generateSymbol(
610610 .auto, .@"extern" => {
611611 const struct_begin = w.end;
612612 const field_types = struct_type.field_types.get(ip);
613 const offsets = struct_type.offsets.get(ip);
613 const offsets = struct_type.field_offsets.get(ip);
614614
615615 var it = struct_type.iterateRuntimeOrder(ip);
616616 while (it.next()) |field_index| {
......@@ -635,13 +635,11 @@ pub fn generateSymbol(
635635 try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), w, reloc_parent);
636636 }
637637
638 const size = struct_type.sizeUnordered(ip);
639 const alignment = struct_type.flagsUnordered(ip).alignment.toByteUnits().?;
638 assert(struct_type.alignment.check(struct_type.size));
640639
641 const padding = math.cast(
642 usize,
643 std.mem.alignForward(u64, size, @max(alignment, 1)) - (w.end - struct_begin),
644 ) orelse return error.Overflow;
640 const padding = math.cast(usize, struct_type.size - (w.end - struct_begin)) orelse {
641 return error.Overflow;
642 };
645643 if (padding > 0) try w.splatByteAll(0, padding);
646644 },
647645 }
......@@ -1060,51 +1058,38 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo
10601058
10611059 switch (ty.zigTypeTag(zcu)) {
10621060 .void => return .none,
1061 .bool => return .{ .immediate = @intFromBool(val.toBool()) },
10631062 .pointer => switch (ty.ptrSize(zcu)) {
10641063 .slice => {},
1065 else => switch (val.toIntern()) {
1066 .null_value => {
1067 return .{ .immediate = 0 };
1068 },
1069 else => switch (ip.indexToKey(val.toIntern())) {
1070 .int => {
1071 return .{ .immediate = val.toUnsignedInt(zcu) };
1064 .one, .many, .c => {
1065 const elem_ty = ty.childType(zcu);
1066 const ptr = ip.indexToKey(val.toIntern()).ptr;
1067 if (ptr.base_addr == .int) return .{ .immediate = ptr.byte_offset };
1068 switch (ptr.base_addr) {
1069 .int => unreachable, // handled above
1070
1071 .nav => |nav| if (elem_ty.isFnOrHasRuntimeBits(zcu)) {
1072 return .{ .lea_nav = nav };
1073 } else {
1074 // Create the 0xaa bit pattern...
1075 const undef_ptr_bits: u64 = @intCast((@as(u66, 1) << @intCast(target.ptrBitWidth() + 1)) / 3);
1076 // ...but align the pointer
1077 const alignment = pt.navAlignment(nav);
1078 return .{ .immediate = alignment.forward(undef_ptr_bits) };
10721079 },
1073 .ptr => |ptr| if (ptr.byte_offset == 0) switch (ptr.base_addr) {
1074 .nav => |nav| {
1075 if (!ty.isFnOrHasRuntimeBitsIgnoreComptime(zcu)) {
1076 const imm: u64 = switch (@divExact(target.ptrBitWidth(), 8)) {
1077 1 => 0xaa,
1078 2 => 0xaaaa,
1079 4 => 0xaaaaaaaa,
1080 8 => 0xaaaaaaaaaaaaaaaa,
1081 else => unreachable,
1082 };
1083 return .{ .immediate = imm };
1084 }
1085
1086 if (ty.castPtrToFn(zcu)) |fn_ty| {
1087 if (zcu.typeToFunc(fn_ty).?.is_generic) {
1088 return .{ .immediate = fn_ty.abiAlignment(zcu).toByteUnits().? };
1089 }
1090 } else if (ty.zigTypeTag(zcu) == .pointer) {
1091 const elem_ty = ty.childType(zcu);
1092 if (!elem_ty.hasRuntimeBits(zcu)) {
1093 return .{ .immediate = elem_ty.abiAlignment(zcu).toByteUnits().? };
1094 }
1095 }
10961080
1097 return .{ .lea_nav = nav };
1098 },
1099 .uav => |uav| if (Value.fromInterned(uav.val).typeOf(zcu).hasRuntimeBits(zcu))
1100 return .{ .lea_uav = uav }
1101 else
1102 return .{ .immediate = Type.fromInterned(uav.orig_ty).ptrAlignment(zcu)
1103 .forward(@intCast((@as(u66, 1) << @intCast(target.ptrBitWidth() | 1)) / 3)) },
1104 else => {},
1081 .uav => |uav| if (elem_ty.isFnOrHasRuntimeBits(zcu)) {
1082 return .{ .lea_uav = uav };
1083 } else {
1084 // Create the 0xaa bit pattern...
1085 const undef_ptr_bits: u64 = @intCast((@as(u66, 1) << @intCast(target.ptrBitWidth() + 1)) / 3);
1086 // ...but align the pointer
1087 const alignment = Type.fromInterned(uav.orig_ty).ptrAlignment(zcu);
1088 return .{ .immediate = alignment.forward(undef_ptr_bits) };
11051089 },
1090
11061091 else => {},
1107 },
1092 }
11081093 },
11091094 },
11101095 .int => {
......@@ -1117,9 +1102,6 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo
11171102 return .{ .immediate = unsigned };
11181103 }
11191104 },
1120 .bool => {
1121 return .{ .immediate = @intFromBool(val.toBool()) };
1122 },
11231105 .optional => {
11241106 if (ty.isPtrLikeOptional(zcu)) {
11251107 return lowerValue(
......@@ -1147,7 +1129,7 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo
11471129 .error_union => {
11481130 const err_type = ty.errorUnionSet(zcu);
11491131 const payload_type = ty.errorUnionPayload(zcu);
1150 if (!payload_type.hasRuntimeBitsIgnoreComptime(zcu)) {
1132 if (!payload_type.hasRuntimeBits(zcu)) {
11511133 // We use the error type directly as the type.
11521134 const err_int_ty = try pt.errorIntType();
11531135 switch (ip.indexToKey(val.toIntern()).error_union.val) {
......@@ -1187,10 +1169,10 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo
11871169}
11881170
11891171pub fn errUnionPayloadOffset(payload_ty: Type, zcu: *Zcu) u64 {
1190 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) return 0;
1172 if (!payload_ty.hasRuntimeBits(zcu)) return 0;
11911173 const payload_align = payload_ty.abiAlignment(zcu);
11921174 const error_align = Type.anyerror.abiAlignment(zcu);
1193 if (payload_align.compare(.gte, error_align) or !payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
1175 if (payload_align.compare(.gte, error_align) or !payload_ty.hasRuntimeBits(zcu)) {
11941176 return 0;
11951177 } else {
11961178 return payload_align.forward(Type.anyerror.abiSize(zcu));
......@@ -1198,10 +1180,10 @@ pub fn errUnionPayloadOffset(payload_ty: Type, zcu: *Zcu) u64 {
11981180}
11991181
12001182pub fn errUnionErrorOffset(payload_ty: Type, zcu: *Zcu) u64 {
1201 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) return 0;
1183 if (!payload_ty.hasRuntimeBits(zcu)) return 0;
12021184 const payload_align = payload_ty.abiAlignment(zcu);
12031185 const error_align = Type.anyerror.abiAlignment(zcu);
1204 if (payload_align.compare(.gte, error_align) and payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
1186 if (payload_align.compare(.gte, error_align) and payload_ty.hasRuntimeBits(zcu)) {
12051187 return error_align.forward(payload_ty.abiSize(zcu));
12061188 } else {
12071189 return 0;
src/codegen/x86_64/CodeGen.zig+32-30
......@@ -43261,7 +43261,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
4326143261 var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs });
4326243262 try ops[0].toSlicePtr(cg);
4326343263 var res: [1]Temp = undefined;
43264 if (!hack_around_sema_opv_bugs or ty_pl.ty.toType().childType(zcu).hasRuntimeBitsIgnoreComptime(zcu)) cg.select(&res, &.{ty_pl.ty.toType()}, &ops, comptime &.{ .{
43264 if (!hack_around_sema_opv_bugs or ty_pl.ty.toType().childType(zcu).hasRuntimeBits(zcu)) cg.select(&res, &.{ty_pl.ty.toType()}, &ops, comptime &.{ .{
4326543265 .patterns = &.{
4326643266 .{ .src = .{ .to_gpr, .simm32, .none } },
4326743267 },
......@@ -43375,7 +43375,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
4337543375 var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs });
4337643376 try ops[0].toSlicePtr(cg);
4337743377 var res: [1]Temp = undefined;
43378 if (!hack_around_sema_opv_bugs or ty_pl.ty.toType().childType(zcu).hasRuntimeBitsIgnoreComptime(zcu)) cg.select(&res, &.{ty_pl.ty.toType()}, &ops, comptime &.{ .{
43378 if (!hack_around_sema_opv_bugs or ty_pl.ty.toType().childType(zcu).hasRuntimeBits(zcu)) cg.select(&res, &.{ty_pl.ty.toType()}, &ops, comptime &.{ .{
4337943379 .patterns = &.{
4338043380 .{ .src = .{ .to_gpr, .simm32, .none } },
4338143381 },
......@@ -103699,7 +103699,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
103699103699 .optional_payload => {
103700103700 const ty_op = air_datas[@intFromEnum(inst)].ty_op;
103701103701 var ops = try cg.tempsFromOperands(inst, .{ty_op.operand});
103702 const pl = if (!hack_around_sema_opv_bugs or ty_op.ty.toType().hasRuntimeBitsIgnoreComptime(zcu))
103702 const pl = if (!hack_around_sema_opv_bugs or ty_op.ty.toType().hasRuntimeBits(zcu))
103703103703 try ops[0].read(ty_op.ty.toType(), .{}, cg)
103704103704 else
103705103705 try cg.tempInit(ty_op.ty.toType(), .none);
......@@ -103745,7 +103745,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
103745103745 const eu_pl_ty = ty_op.ty.toType();
103746103746 const eu_pl_off: i32 = @intCast(codegen.errUnionPayloadOffset(eu_pl_ty, zcu));
103747103747 var ops = try cg.tempsFromOperands(inst, .{ty_op.operand});
103748 const pl = if (!hack_around_sema_opv_bugs or eu_pl_ty.hasRuntimeBitsIgnoreComptime(zcu))
103748 const pl = if (!hack_around_sema_opv_bugs or eu_pl_ty.hasRuntimeBits(zcu))
103749103749 try ops[0].read(eu_pl_ty, .{ .disp = eu_pl_off }, cg)
103750103750 else
103751103751 try cg.tempInit(eu_pl_ty, .none);
......@@ -103864,7 +103864,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
103864103864 .@"packed" => unreachable,
103865103865 };
103866103866 var ops = try cg.tempsFromOperands(inst, .{struct_field.struct_operand});
103867 var res = if (!hack_around_sema_opv_bugs or field_ty.hasRuntimeBitsIgnoreComptime(zcu))
103867 var res = if (!hack_around_sema_opv_bugs or field_ty.hasRuntimeBits(zcu))
103868103868 try ops[0].read(field_ty, .{ .disp = field_off }, cg)
103869103869 else
103870103870 try cg.tempInit(field_ty, .none);
......@@ -104125,7 +104125,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
104125104125 var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs });
104126104126 try ops[0].toSlicePtr(cg);
104127104127 var res: [1]Temp = undefined;
104128 if (!hack_around_sema_opv_bugs or res_ty.hasRuntimeBitsIgnoreComptime(zcu)) cg.select(&res, &.{res_ty}, &ops, comptime &.{ .{
104128 if (!hack_around_sema_opv_bugs or res_ty.hasRuntimeBits(zcu)) cg.select(&res, &.{res_ty}, &ops, comptime &.{ .{
104129104129 .dst_constraints = .{ .{ .int = .byte }, .any },
104130104130 .patterns = &.{
104131104131 .{ .src = .{ .to_gpr, .simm32, .none } },
......@@ -171422,10 +171422,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
171422171422 .auto, .@"extern" => {
171423171423 for (elems, 0..) |elem_ref, field_index| {
171424171424 const elem_dies = bt.feed();
171425 if (loaded_struct.fieldIsComptime(ip, field_index)) continue;
171426 if (!hack_around_sema_opv_bugs or Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]).hasRuntimeBitsIgnoreComptime(zcu)) {
171425 if (loaded_struct.field_is_comptime_bits.get(ip, field_index)) continue;
171426 if (!hack_around_sema_opv_bugs or Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]).hasRuntimeBits(zcu)) {
171427171427 var elem = try cg.tempFromOperand(elem_ref, elem_dies);
171428 try res.write(&elem, .{ .disp = @intCast(loaded_struct.offsets.get(ip)[field_index]) }, cg);
171428 try res.write(&elem, .{ .disp = @intCast(loaded_struct.field_offsets.get(ip)[field_index]) }, cg);
171429171429 try elem.die(cg);
171430171430 try cg.resetTemps(reset_index);
171431171431 }
......@@ -171441,7 +171441,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
171441171441 const elem_dies = bt.feed();
171442171442 if (tuple_type.values.get(ip)[field_index] != .none) continue;
171443171443 const field_type = Type.fromInterned(tuple_type.types.get(ip)[field_index]);
171444 if (!hack_around_sema_opv_bugs or field_type.hasRuntimeBitsIgnoreComptime(zcu)) {
171444 if (!hack_around_sema_opv_bugs or field_type.hasRuntimeBits(zcu)) {
171445171445 elem_disp = @intCast(field_type.abiAlignment(zcu).forward(elem_disp));
171446171446 var elem = try cg.tempFromOperand(elem_ref, elem_dies);
171447171447 try res.write(&elem, .{ .disp = elem_disp }, cg);
......@@ -173756,7 +173756,7 @@ fn genLazy(cg: *CodeGen, lazy_sym: link.File.LazySymbol) InnerError!void {
173756173756
173757173757 var data_off: i32 = 0;
173758173758 const reset_index = cg.next_temp_index;
173759 const tag_names = ip.loadEnumType(lazy_sym.ty).names;
173759 const tag_names = ip.loadEnumType(lazy_sym.ty).field_names;
173760173760 for (0..tag_names.len) |tag_index| {
173761173761 var enum_temp = try cg.tempInit(enum_ty, if (enum_ty.abiSize(zcu) <= @as(u4, switch (cg.target.cpu.arch) {
173762173762 else => unreachable,
......@@ -174334,7 +174334,7 @@ fn genUnwrapErrUnionPayloadMir(
174334174334 const payload_ty = err_union_ty.errorUnionPayload(zcu);
174335174335
174336174336 const result: MCValue = result: {
174337 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) break :result .none;
174337 if (!payload_ty.hasRuntimeBits(zcu)) break :result .none;
174338174338
174339174339 const payload_off: u31 = @intCast(codegen.errUnionPayloadOffset(payload_ty, zcu));
174340174340 switch (err_union) {
......@@ -174450,7 +174450,7 @@ fn load(self: *CodeGen, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) InnerE
174450174450 const pt = self.pt;
174451174451 const zcu = pt.zcu;
174452174452 const dst_ty = ptr_ty.childType(zcu);
174453 if (!dst_ty.hasRuntimeBitsIgnoreComptime(zcu)) return;
174453 if (!dst_ty.hasRuntimeBits(zcu)) return;
174454174454 switch (ptr_mcv) {
174455174455 .none,
174456174456 .unreach,
......@@ -174503,7 +174503,7 @@ fn store(
174503174503 const pt = self.pt;
174504174504 const zcu = pt.zcu;
174505174505 const src_ty = ptr_ty.childType(zcu);
174506 if (!src_ty.hasRuntimeBitsIgnoreComptime(zcu)) return;
174506 if (!src_ty.hasRuntimeBits(zcu)) return;
174507174507 switch (ptr_mcv) {
174508174508 .none,
174509174509 .unreach,
......@@ -176615,7 +176615,7 @@ fn lowerSwitchBr(
176615176615 break :condition_index condition_index;
176616176616 };
176617176617 try cg.spillEflagsIfOccupied();
176618 if (min.?.orderAgainstZero(zcu).compare(.neq)) try cg.genBinOpMir(
176618 if (Value.compareHetero(min.?, .neq, .zero_comptime_int, zcu)) try cg.genBinOpMir(
176619176619 .{ ._, .sub },
176620176620 condition_ty,
176621176621 condition_index,
......@@ -176957,7 +176957,7 @@ fn airSwitchDispatch(self: *CodeGen, inst: Air.Inst.Index) !void {
176957176957 const unsigned_condition_ty = try self.pt.intType(.unsigned, self.intInfo(condition_ty).?.bits);
176958176958 const condition_mcv = block_tracking.short;
176959176959 try self.spillEflagsIfOccupied();
176960 if (table.min.orderAgainstZero(self.pt.zcu).compare(.neq)) try self.genBinOpMir(
176960 if (Value.compareHetero(table.min, .neq, .zero_comptime_int, self.pt.zcu)) try self.genBinOpMir(
176961176961 .{ ._, .sub },
176962176962 condition_ty,
176963176963 condition_mcv,
......@@ -177054,8 +177054,7 @@ fn airBr(self: *CodeGen, inst: Air.Inst.Index) !void {
177054177054 const br = self.air.instructions.items(.data)[@intFromEnum(inst)].br;
177055177055
177056177056 const block_ty = self.typeOfIndex(br.block_inst);
177057 const block_unused =
177058 !block_ty.hasRuntimeBitsIgnoreComptime(zcu) or self.liveness.isUnused(br.block_inst);
177057 const block_unused = !block_ty.hasRuntimeBits(zcu) or self.liveness.isUnused(br.block_inst);
177059177058 const block_tracking = self.inst_tracking.getPtr(br.block_inst).?;
177060177059 const block_data = self.blocks.getPtr(br.block_inst).?;
177061177060 const first_br = block_data.relocs.items.len == 0;
......@@ -180986,7 +180985,7 @@ fn resolveInst(self: *CodeGen, ref: Air.Inst.Ref) InnerError!MCValue {
180986180985 const ty = self.typeOf(ref);
180987180986
180988180987 // If the type has no codegen bits, no need to store it.
180989 if (!ty.hasRuntimeBitsIgnoreComptime(zcu)) return .none;
180988 if (!ty.hasRuntimeBits(zcu)) return .none;
180990180989
180991180990 const mcv: MCValue = if (ref.toIndex()) |inst| mcv: {
180992180991 break :mcv self.inst_tracking.getPtr(inst).?.short;
......@@ -181105,7 +181104,7 @@ fn resolveCallingConventionValues(
181105181104 // Return values
181106181105 if (ret_ty.isNoReturn(zcu)) {
181107181106 result.return_value = .init(.unreach);
181108 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
181107 } else if (!ret_ty.hasRuntimeBits(zcu)) {
181109181108 // TODO: is this even possible for C calling convention?
181110181109 result.return_value = .init(.none);
181111181110 } else {
......@@ -181182,7 +181181,7 @@ fn resolveCallingConventionValues(
181182181181
181183181182 // Input params
181184181183 params: for (param_types, result.args) |ty, *arg| {
181185 assert(ty.hasRuntimeBitsIgnoreComptime(zcu));
181184 assert(ty.hasRuntimeBits(zcu));
181186181185 result.air_arg_count += 1;
181187181186 switch (cc) {
181188181187 .x86_64_sysv => {},
......@@ -181327,7 +181326,7 @@ fn resolveCallingConventionValues(
181327181326 // Return values
181328181327 result.return_value = if (ret_ty.isNoReturn(zcu))
181329181328 .init(.unreach)
181330 else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu))
181329 else if (!ret_ty.hasRuntimeBits(zcu))
181331181330 .init(.none)
181332181331 else return_value: {
181333181332 const ret_gpr = abi.getCAbiIntReturnRegs(cc);
......@@ -181357,7 +181356,7 @@ fn resolveCallingConventionValues(
181357181356
181358181357 // Input params
181359181358 for (param_types, result.args) |param_ty, *arg| {
181360 if (!param_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
181359 if (!param_ty.hasRuntimeBits(zcu)) {
181361181360 arg.* = .none;
181362181361 continue;
181363181362 }
......@@ -181721,7 +181720,7 @@ fn intInfo(cg: *CodeGen, ty: Type) ?std.builtin.Type.Int {
181721181720 .one, .many, .c => .{ .signedness = .unsigned, .bits = cg.target.ptrBitWidth() },
181722181721 .slice => null,
181723181722 },
181724 .opt_type => |opt_child| return if (!Type.fromInterned(opt_child).hasRuntimeBitsIgnoreComptime(zcu))
181723 .opt_type => |opt_child| return if (!Type.fromInterned(opt_child).hasRuntimeBits(zcu))
181725181724 .{ .signedness = .unsigned, .bits = 1 }
181726181725 else switch (ip.indexToKey(opt_child)) {
181727181726 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
......@@ -181734,7 +181733,7 @@ fn intInfo(cg: *CodeGen, ty: Type) ?std.builtin.Type.Int {
181734181733 else => null,
181735181734 },
181736181735 .error_union_type => |error_union_type| return if (!Type.fromInterned(error_union_type.payload_type)
181737 .hasRuntimeBitsIgnoreComptime(zcu)) .{ .signedness = .unsigned, .bits = zcu.errorSetBits() } else null,
181736 .hasRuntimeBits(zcu)) .{ .signedness = .unsigned, .bits = zcu.errorSetBits() } else null,
181738181737 .simple_type => |simple_type| return switch (simple_type) {
181739181738 .bool => .{ .signedness = .unsigned, .bits = 1 },
181740181739 .anyerror => .{ .signedness = .unsigned, .bits = zcu.errorSetBits() },
......@@ -181767,14 +181766,17 @@ fn intInfo(cg: *CodeGen, ty: Type) ?std.builtin.Type.Int {
181767181766 const loaded_struct = ip.loadStructType(ty_index);
181768181767 switch (loaded_struct.layout) {
181769181768 .auto, .@"extern" => return null,
181770 .@"packed" => ty_index = loaded_struct.backingIntTypeUnordered(ip),
181769 .@"packed" => ty_index = loaded_struct.packed_backing_int_type,
181771181770 }
181772181771 },
181773 .union_type => return switch (ip.loadUnionType(ty_index).flagsUnordered(ip).layout) {
181774 .auto, .@"extern" => null,
181775 .@"packed" => .{ .signedness = .unsigned, .bits = @intCast(ty.bitSize(zcu)) },
181772 .union_type => {
181773 const loaded_union = ip.loadUnionType(ty_index);
181774 switch (loaded_union.layout) {
181775 .auto, .@"extern" => return null,
181776 .@"packed" => ty_index = loaded_union.packed_backing_int_type,
181777 }
181776181778 },
181777 .enum_type => ty_index = ip.loadEnumType(ty_index).tag_ty,
181779 .enum_type => ty_index = ip.loadEnumType(ty_index).int_tag_type,
181778181780 .error_set_type, .inferred_error_set_type => return .{ .signedness = .unsigned, .bits = zcu.errorSetBits() },
181779181781 else => return null,
181780181782 };
src/codegen/x86_64/abi.zig+6-6
......@@ -339,7 +339,7 @@ fn classifySystemVStruct(
339339 var field_it = loaded_struct.iterateRuntimeOrder(ip);
340340 while (field_it.next()) |field_index| {
341341 const field_ty = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);
342 const field_align = loaded_struct.fieldAlign(ip, field_index);
342 const field_align = loaded_struct.field_aligns.getOrNone(ip, field_index);
343343 byte_offset = std.mem.alignForward(
344344 u64,
345345 byte_offset,
......@@ -355,7 +355,7 @@ fn classifySystemVStruct(
355355 .@"packed" => {},
356356 }
357357 } else if (zcu.typeToUnion(field_ty)) |field_loaded_union| {
358 switch (field_loaded_union.flagsUnordered(ip).layout) {
358 switch (field_loaded_union.layout) {
359359 .auto => unreachable,
360360 .@"extern" => {
361361 byte_offset = classifySystemVUnion(result, byte_offset, field_loaded_union, zcu, target);
......@@ -369,11 +369,11 @@ fn classifySystemVStruct(
369369 result_class.* = result_class.combineSystemV(field_class);
370370 byte_offset += field_ty.abiSize(zcu);
371371 }
372 const final_byte_offset = starting_byte_offset + loaded_struct.sizeUnordered(ip);
372 const final_byte_offset = starting_byte_offset + loaded_struct.size;
373373 std.debug.assert(final_byte_offset == std.mem.alignForward(
374374 u64,
375375 byte_offset,
376 loaded_struct.flagsUnordered(ip).alignment.toByteUnits().?,
376 loaded_struct.alignment.toByteUnits().?,
377377 ));
378378 return final_byte_offset;
379379}
......@@ -398,7 +398,7 @@ fn classifySystemVUnion(
398398 .@"packed" => {},
399399 }
400400 } else if (zcu.typeToUnion(field_ty)) |field_loaded_union| {
401 switch (field_loaded_union.flagsUnordered(ip).layout) {
401 switch (field_loaded_union.layout) {
402402 .auto => unreachable,
403403 .@"extern" => {
404404 _ = classifySystemVUnion(result, starting_byte_offset, field_loaded_union, zcu, target);
......@@ -411,7 +411,7 @@ fn classifySystemVUnion(
411411 for (result[@intCast(starting_byte_offset / 8)..][0..field_classes.len], field_classes) |*result_class, field_class|
412412 result_class.* = result_class.combineSystemV(field_class);
413413 }
414 return starting_byte_offset + loaded_union.sizeUnordered(ip);
414 return starting_byte_offset + loaded_union.size;
415415}
416416
417417pub const zigcc = struct {
src/link/Dwarf.zig+54-54
......@@ -2243,8 +2243,8 @@ pub const WipNav = struct {
22432243 const zcu = wip_nav.pt.zcu;
22442244 const ip = &zcu.intern_pool;
22452245 var big_int_space: Value.BigIntSpace = undefined;
2246 try wip_nav.bigIntConstValue(abbrev_code, .fromInterned(loaded_enum.tag_ty), if (loaded_enum.values.len > 0)
2247 Value.fromInterned(loaded_enum.values.get(ip)[field_index]).toBigInt(&big_int_space, zcu)
2246 try wip_nav.bigIntConstValue(abbrev_code, .fromInterned(loaded_enum.int_tag_type), if (loaded_enum.field_values.len > 0)
2247 Value.fromInterned(loaded_enum.field_values.get(ip)[field_index]).toBigInt(&big_int_space, zcu)
22482248 else
22492249 std.math.big.int.Mutable.init(&big_int_space.limbs, field_index).toConst());
22502250 }
......@@ -3164,8 +3164,8 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
31643164 try diw.writeUleb128(nav_val.toType().abiSize(zcu));
31653165 try diw.writeUleb128(nav_val.toType().abiAlignment(zcu).toByteUnits().?);
31663166 for (0..loaded_struct.field_types.len) |field_index| {
3167 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);
3168 const field_init = loaded_struct.fieldInit(ip, field_index);
3167 const is_comptime = loaded_struct.field_is_comptime_bits.get(ip, field_index);
3168 const field_init = loaded_struct.field_defaults.getOrNone(ip, field_index);
31693169 assert(!(is_comptime and field_init == .none));
31703170 const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]);
31713171 const has_runtime_bits, const has_comptime_state = switch (field_init) {
......@@ -3191,11 +3191,11 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
31913191 .struct_field
31923192 else
31933193 .struct_field);
3194 try wip_nav.strp(loaded_struct.fieldName(ip, field_index).toSlice(ip));
3194 try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip));
31953195 try wip_nav.refType(field_type);
31963196 if (!is_comptime) {
3197 try diw.writeUleb128(loaded_struct.offsets.get(ip)[field_index]);
3198 try diw.writeUleb128(loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
3197 try diw.writeUleb128(loaded_struct.field_offsets.get(ip)[field_index]);
3198 try diw.writeUleb128(loaded_struct.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse
31993199 field_type.abiAlignment(zcu).toByteUnits().?);
32003200 }
32013201 if (has_comptime_state)
......@@ -3212,11 +3212,11 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
32123212 .generic_decl = .generic_decl_const,
32133213 .decl_instance = .decl_instance_packed_struct,
32143214 }, &nav, inst_info.file, &decl);
3215 try wip_nav.refType(.fromInterned(loaded_struct.backingIntTypeUnordered(ip)));
3215 try wip_nav.refType(.fromInterned(loaded_struct.packed_backing_int_type));
32163216 var field_bit_offset: u16 = 0;
32173217 for (0..loaded_struct.field_types.len) |field_index| {
32183218 try wip_nav.abbrevCode(.packed_struct_field);
3219 try wip_nav.strp(loaded_struct.fieldName(ip, field_index).toSlice(ip));
3219 try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip));
32203220 const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]);
32213221 try wip_nav.refType(field_type);
32223222 try diw.writeUleb128(field_bit_offset);
......@@ -3246,7 +3246,7 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
32463246 }
32473247 wip_nav.entry = nav_gop.value_ptr.*;
32483248 const diw = &wip_nav.debug_info.writer;
3249 try wip_nav.declCommon(if (loaded_enum.names.len > 0) .{
3249 try wip_nav.declCommon(if (loaded_enum.field_names.len > 0) .{
32503250 .decl = .decl_enum,
32513251 .generic_decl = .generic_decl_const,
32523252 .decl_instance = .decl_instance_enum,
......@@ -3255,16 +3255,16 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
32553255 .generic_decl = .generic_decl_const,
32563256 .decl_instance = .decl_instance_empty_enum,
32573257 }, &nav, inst_info.file, &decl);
3258 try wip_nav.refType(.fromInterned(loaded_enum.tag_ty));
3259 for (0..loaded_enum.names.len) |field_index| {
3258 try wip_nav.refType(.fromInterned(loaded_enum.int_tag_type));
3259 for (0..loaded_enum.field_names.len) |field_index| {
32603260 try wip_nav.enumConstValue(loaded_enum, .{
32613261 .sdata = .signed_enum_field,
32623262 .udata = .unsigned_enum_field,
32633263 .block = .big_enum_field,
32643264 }, field_index);
3265 try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip));
3265 try wip_nav.strp(loaded_enum.field_names.get(ip)[field_index].toSlice(ip));
32663266 }
3267 if (loaded_enum.names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
3267 if (loaded_enum.field_names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
32683268 break :tag .done;
32693269 },
32703270 .union_type => tag: {
......@@ -3293,8 +3293,8 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
32933293 const union_layout = Type.getUnionLayout(loaded_union, zcu);
32943294 try diw.writeUleb128(union_layout.abi_size);
32953295 try diw.writeUleb128(union_layout.abi_align.toByteUnits().?);
3296 const loaded_tag = loaded_union.loadTagType(ip);
3297 if (loaded_union.hasTag(ip)) {
3296 const loaded_tag = ip.loadEnumType(loaded_union.enum_tag_type);
3297 if (loaded_union.runtime_tag != .none) {
32983298 try wip_nav.abbrevCode(.tagged_union);
32993299 try wip_nav.infoSectionOffset(
33003300 .debug_info,
......@@ -3305,7 +3305,7 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
33053305 {
33063306 try wip_nav.abbrevCode(.generated_field);
33073307 try wip_nav.strp("tag");
3308 try wip_nav.refType(.fromInterned(loaded_union.enum_tag_ty));
3308 try wip_nav.refType(.fromInterned(loaded_union.enum_tag_type));
33093309 try diw.writeUleb128(union_layout.tagOffset());
33103310
33113311 for (0..loaded_union.field_types.len) |field_index| {
......@@ -3316,11 +3316,11 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
33163316 }, field_index);
33173317 {
33183318 try wip_nav.abbrevCode(.struct_field);
3319 try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip));
3319 try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip));
33203320 const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]);
33213321 try wip_nav.refType(field_type);
33223322 try diw.writeUleb128(union_layout.payloadOffset());
3323 try diw.writeUleb128(loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
3323 try diw.writeUleb128(loaded_union.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse
33243324 if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?);
33253325 }
33263326 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
......@@ -3329,10 +3329,10 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
33293329 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
33303330 } else for (0..loaded_union.field_types.len) |field_index| {
33313331 try wip_nav.abbrevCode(.untagged_union_field);
3332 try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip));
3332 try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip));
33333333 const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]);
33343334 try wip_nav.refType(field_type);
3335 try diw.writeUleb128(loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
3335 try diw.writeUleb128(loaded_union.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse
33363336 if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?);
33373337 }
33383338 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
......@@ -3877,18 +3877,18 @@ fn updateLazyType(
38773877 },
38783878 .enum_type => {
38793879 const loaded_enum = ip.loadEnumType(type_index);
3880 try wip_nav.abbrevCode(if (loaded_enum.names.len == 0) .generated_empty_enum_type else .generated_enum_type);
3880 try wip_nav.abbrevCode(if (loaded_enum.field_names.len == 0) .generated_empty_enum_type else .generated_enum_type);
38813881 try wip_nav.strp(name);
3882 try wip_nav.refType(.fromInterned(loaded_enum.tag_ty));
3883 for (0..loaded_enum.names.len) |field_index| {
3882 try wip_nav.refType(.fromInterned(loaded_enum.int_tag_type));
3883 for (0..loaded_enum.field_names.len) |field_index| {
38843884 try wip_nav.enumConstValue(loaded_enum, .{
38853885 .sdata = .signed_enum_field,
38863886 .udata = .unsigned_enum_field,
38873887 .block = .big_enum_field,
38883888 }, field_index);
3889 try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip));
3889 try wip_nav.strp(loaded_enum.field_names.get(ip)[field_index].toSlice(ip));
38903890 }
3891 if (loaded_enum.names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
3891 if (loaded_enum.field_names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
38923892 },
38933893 .func_type => |func_type| {
38943894 const is_nullary = func_type.param_types.len == 0 and !func_type.is_var_args;
......@@ -4349,7 +4349,7 @@ fn updateLazyValue(
43494349 const loaded_struct_type = ip.loadStructType(aggregate.ty);
43504350 assert(loaded_struct_type.layout == .auto);
43514351 for (0..loaded_struct_type.field_types.len) |field_index| {
4352 if (loaded_struct_type.fieldIsComptime(ip, field_index)) continue;
4352 if (loaded_struct_type.field_is_comptime_bits.get(ip, field_index)) continue;
43534353 const field_type: Type = .fromInterned(loaded_struct_type.field_types.get(ip)[field_index]);
43544354 const has_runtime_bits = field_type.hasRuntimeBits(zcu);
43554355 const has_comptime_state = field_type.comptimeOnly(zcu) and try field_type.onePossibleValue(pt) == null;
......@@ -4359,7 +4359,7 @@ fn updateLazyValue(
43594359 .comptime_value_field_runtime_bits
43604360 else
43614361 continue);
4362 try wip_nav.strp(loaded_struct_type.fieldName(ip, field_index).toSlice(ip));
4362 try wip_nav.strp(loaded_struct_type.field_names.get(ip)[field_index].toSlice(ip));
43634363 const field_value: Value = .fromInterned(switch (aggregate.storage) {
43644364 .bytes => unreachable,
43654365 .elems => |elems| elems[field_index],
......@@ -4427,10 +4427,10 @@ fn updateLazyValue(
44274427 try wip_nav.refType(.fromInterned(un.ty));
44284428 field: {
44294429 const loaded_union_type = ip.loadUnionType(un.ty);
4430 assert(loaded_union_type.flagsUnordered(ip).layout == .auto);
4430 assert(loaded_union_type.layout == .auto);
44314431 const field_index = zcu.unionTagFieldIndex(loaded_union_type, Value.fromInterned(un.tag)).?;
44324432 const field_ty: Type = .fromInterned(loaded_union_type.field_types.get(ip)[field_index]);
4433 const field_name = loaded_union_type.loadTagType(ip).names.get(ip)[field_index];
4433 const field_name = ip.loadEnumType(loaded_union_type.enum_tag_type).field_names.get(ip)[field_index];
44344434 const has_runtime_bits = field_ty.hasRuntimeBits(zcu);
44354435 const has_comptime_state = field_ty.comptimeOnly(zcu) and try field_ty.onePossibleValue(pt) == null;
44364436 try wip_nav.abbrevCode(if (has_comptime_state)
......@@ -4521,8 +4521,8 @@ fn updateContainerTypeWriterError(
45214521 try diw.writeUleb128(ty.abiSize(zcu));
45224522 try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?);
45234523 for (0..loaded_struct.field_types.len) |field_index| {
4524 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);
4525 const field_init = loaded_struct.fieldInit(ip, field_index);
4524 const is_comptime = loaded_struct.field_is_comptime_bits.get(ip, field_index);
4525 const field_init = loaded_struct.field_defaults.getOrNone(ip, field_index);
45264526 assert(!(is_comptime and field_init == .none));
45274527 const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]);
45284528 const has_runtime_bits, const has_comptime_state = switch (field_init) {
......@@ -4548,11 +4548,11 @@ fn updateContainerTypeWriterError(
45484548 .struct_field
45494549 else
45504550 .struct_field);
4551 try wip_nav.strp(loaded_struct.fieldName(ip, field_index).toSlice(ip));
4551 try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip));
45524552 try wip_nav.refType(field_type);
45534553 if (!is_comptime) {
4554 try diw.writeUleb128(loaded_struct.offsets.get(ip)[field_index]);
4555 try diw.writeUleb128(loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
4554 try diw.writeUleb128(loaded_struct.field_offsets.get(ip)[field_index]);
4555 try diw.writeUleb128(loaded_struct.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse
45564556 field_type.abiAlignment(zcu).toByteUnits().?);
45574557 }
45584558 if (has_comptime_state)
......@@ -4628,8 +4628,8 @@ fn updateContainerTypeWriterError(
46284628 try diw.writeUleb128(ty.abiSize(zcu));
46294629 try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?);
46304630 for (0..loaded_struct.field_types.len) |field_index| {
4631 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);
4632 const field_init = loaded_struct.fieldInit(ip, field_index);
4631 const is_comptime = loaded_struct.field_is_comptime_bits.get(ip, field_index);
4632 const field_init = loaded_struct.field_defaults.getOrNone(ip, field_index);
46334633 assert(!(is_comptime and field_init == .none));
46344634 const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]);
46354635 const has_runtime_bits, const has_comptime_state = switch (field_init) {
......@@ -4655,11 +4655,11 @@ fn updateContainerTypeWriterError(
46554655 .struct_field
46564656 else
46574657 .struct_field);
4658 try wip_nav.strp(loaded_struct.fieldName(ip, field_index).toSlice(ip));
4658 try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip));
46594659 try wip_nav.refType(field_type);
46604660 if (!is_comptime) {
4661 try diw.writeUleb128(loaded_struct.offsets.get(ip)[field_index]);
4662 try diw.writeUleb128(loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
4661 try diw.writeUleb128(loaded_struct.field_offsets.get(ip)[field_index]);
4662 try diw.writeUleb128(loaded_struct.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse
46634663 field_type.abiAlignment(zcu).toByteUnits().?);
46644664 }
46654665 if (has_comptime_state)
......@@ -4674,11 +4674,11 @@ fn updateContainerTypeWriterError(
46744674 try wip_nav.abbrevCode(if (loaded_struct.field_types.len > 0) .packed_struct_type else .empty_packed_struct_type);
46754675 try diw.writeUleb128(file_gop.index);
46764676 try wip_nav.strp(name);
4677 try wip_nav.refType(.fromInterned(loaded_struct.backingIntTypeUnordered(ip)));
4677 try wip_nav.refType(.fromInterned(loaded_struct.packed_backing_int_type));
46784678 var field_bit_offset: u16 = 0;
46794679 for (0..loaded_struct.field_types.len) |field_index| {
46804680 try wip_nav.abbrevCode(.packed_struct_field);
4681 try wip_nav.strp(loaded_struct.fieldName(ip, field_index).toSlice(ip));
4681 try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip));
46824682 const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]);
46834683 try wip_nav.refType(field_type);
46844684 try diw.writeUleb128(field_bit_offset);
......@@ -4690,19 +4690,19 @@ fn updateContainerTypeWriterError(
46904690 },
46914691 .enum_type => {
46924692 const loaded_enum = ip.loadEnumType(type_index);
4693 try wip_nav.abbrevCode(if (loaded_enum.names.len > 0) .enum_type else .empty_enum_type);
4693 try wip_nav.abbrevCode(if (loaded_enum.field_names.len > 0) .enum_type else .empty_enum_type);
46944694 try diw.writeUleb128(file_gop.index);
46954695 try wip_nav.strp(name);
4696 try wip_nav.refType(.fromInterned(loaded_enum.tag_ty));
4697 for (0..loaded_enum.names.len) |field_index| {
4696 try wip_nav.refType(.fromInterned(loaded_enum.int_tag_type));
4697 for (0..loaded_enum.field_names.len) |field_index| {
46984698 try wip_nav.enumConstValue(loaded_enum, .{
46994699 .sdata = .signed_enum_field,
47004700 .udata = .unsigned_enum_field,
47014701 .block = .big_enum_field,
47024702 }, field_index);
4703 try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip));
4703 try wip_nav.strp(loaded_enum.field_names.get(ip)[field_index].toSlice(ip));
47044704 }
4705 if (loaded_enum.names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
4705 if (loaded_enum.field_names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
47064706 },
47074707 .union_type => {
47084708 const loaded_union = ip.loadUnionType(type_index);
......@@ -4712,8 +4712,8 @@ fn updateContainerTypeWriterError(
47124712 const union_layout = Type.getUnionLayout(loaded_union, zcu);
47134713 try diw.writeUleb128(union_layout.abi_size);
47144714 try diw.writeUleb128(union_layout.abi_align.toByteUnits().?);
4715 const loaded_tag = loaded_union.loadTagType(ip);
4716 if (loaded_union.hasTag(ip)) {
4715 const loaded_tag = ip.loadEnumType(loaded_union.enum_tag_type);
4716 if (loaded_union.runtime_tag != .none) {
47174717 try wip_nav.abbrevCode(.tagged_union);
47184718 try wip_nav.infoSectionOffset(
47194719 .debug_info,
......@@ -4724,7 +4724,7 @@ fn updateContainerTypeWriterError(
47244724 {
47254725 try wip_nav.abbrevCode(.generated_field);
47264726 try wip_nav.strp("tag");
4727 try wip_nav.refType(.fromInterned(loaded_union.enum_tag_ty));
4727 try wip_nav.refType(.fromInterned(loaded_union.enum_tag_type));
47284728 try diw.writeUleb128(union_layout.tagOffset());
47294729
47304730 for (0..loaded_union.field_types.len) |field_index| {
......@@ -4735,11 +4735,11 @@ fn updateContainerTypeWriterError(
47354735 }, field_index);
47364736 {
47374737 try wip_nav.abbrevCode(.struct_field);
4738 try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip));
4738 try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip));
47394739 const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]);
47404740 try wip_nav.refType(field_type);
47414741 try diw.writeUleb128(union_layout.payloadOffset());
4742 try diw.writeUleb128(loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
4742 try diw.writeUleb128(loaded_union.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse
47434743 if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?);
47444744 }
47454745 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
......@@ -4748,10 +4748,10 @@ fn updateContainerTypeWriterError(
47484748 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
47494749 } else for (0..loaded_union.field_types.len) |field_index| {
47504750 try wip_nav.abbrevCode(.untagged_union_field);
4751 try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip));
4751 try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip));
47524752 const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]);
47534753 try wip_nav.refType(field_type);
4754 try diw.writeUleb128(loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
4754 try diw.writeUleb128(loaded_union.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse
47554755 if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?);
47564756 }
47574757 if (loaded_union.field_types.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));