authorgravatar for david@vortan.devDavid Rubin <david@vortan.dev> 2024-08-25 22:43:57-07:00
committergravatar for david@vortan.devDavid Rubin <david@vortan.dev> 2024-08-25 22:43:57-07:00
logf777b298327de95d2a54d814ca562c08fd7c7a87
treeb6d4b3fe7925911cf861f22b0a668d78c3a6d223
parentce92ccccc961992c00a10e714ce9e799956c50f2
signaturelock-open Commit is signed but in an unrecognized format.

fix up merge conflicts with master


16 files changed, 141 insertions(+), 82 deletions(-)

src/Compilation.zig+4-4
......@@ -3091,7 +3091,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
30913091 var all_references: ?std.AutoHashMapUnmanaged(InternPool.AnalUnit, ?Zcu.ResolvedReference) = null;
30923092 defer if (all_references) |*a| a.deinit(gpa);
30933093
3094 if (comp.module) |zcu| {
3094 if (comp.zcu) |zcu| {
30953095 const ip = &zcu.intern_pool;
30963096
30973097 for (zcu.failed_files.keys(), zcu.failed_files.values()) |file, error_msg| {
......@@ -3268,7 +3268,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
32683268 }
32693269 }
32703270
3271 if (comp.module) |zcu| {
3271 if (comp.zcu) |zcu| {
32723272 if (comp.incremental and bundle.root_list.items.len == 0) {
32733273 const should_have_error = for (zcu.transitive_failed_analysis.keys()) |failed_unit| {
32743274 if (all_references == null) {
......@@ -3976,7 +3976,7 @@ fn processOneCodegenJob(tid: usize, comp: *Compilation, codegen_job: CodegenJob)
39763976 const named_frame = tracy.namedFrame("codegen_type");
39773977 defer named_frame.end();
39783978
3979 const pt: Zcu.PerThread = .{ .zcu = comp.module.?, .tid = @enumFromInt(tid) };
3979 const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) };
39803980 try pt.linkerUpdateContainerType(ty);
39813981 },
39823982 }
......@@ -4258,7 +4258,7 @@ fn workerAstGenFile(
42584258 const child_prog_node = prog_node.start(file.sub_file_path, 0);
42594259 defer child_prog_node.end();
42604260
4261 const pt: Zcu.PerThread = .{ .zcu = comp.module.?, .tid = @enumFromInt(tid) };
4261 const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) };
42624262 pt.astGenFile(file, path_digest) catch |err| switch (err) {
42634263 error.AnalysisFail => return,
42644264 else => {
src/Sema.zig+7-7
......@@ -3544,7 +3544,7 @@ fn zirAllocExtended(
35443544 }
35453545 const target = pt.zcu.getTarget();
35463546 try var_ty.resolveLayout(pt);
3547 if (sema.func_is_naked and try sema.typeHasRuntimeBits(var_ty)) {
3547 if (sema.func_is_naked and try var_ty.hasRuntimeBitsSema(pt)) {
35483548 const var_src = block.src(.{ .node_offset_store_ptr = extra.data.src_node });
35493549 return sema.fail(block, var_src, "local variable in naked function", .{});
35503550 }
......@@ -3988,7 +3988,7 @@ fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
39883988 if (block.is_comptime) {
39893989 return sema.analyzeComptimeAlloc(block, var_ty, .none);
39903990 }
3991 if (sema.func_is_naked and try sema.typeHasRuntimeBits(var_ty)) {
3991 if (sema.func_is_naked and try var_ty.hasRuntimeBitsSema(pt)) {
39923992 const mut_src = block.src(.{ .node_offset_store_ptr = inst_data.src_node });
39933993 return sema.fail(block, mut_src, "local variable in naked function", .{});
39943994 }
......@@ -4016,7 +4016,7 @@ fn zirAllocMut(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
40164016 if (block.is_comptime) {
40174017 return sema.analyzeComptimeAlloc(block, var_ty, .none);
40184018 }
4019 if (sema.func_is_naked and try sema.typeHasRuntimeBits(var_ty)) {
4019 if (sema.func_is_naked and try var_ty.hasRuntimeBitsSema(pt)) {
40204020 const var_src = block.src(.{ .node_offset_store_ptr = inst_data.src_node });
40214021 return sema.fail(block, var_src, "local variable in naked function", .{});
40224022 }
......@@ -4153,7 +4153,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
41534153 // TODO: source location of runtime control flow
41544154 return sema.fail(block, src, "value with comptime-only type '{}' depends on runtime control flow", .{final_elem_ty.fmt(pt)});
41554155 }
4156 if (sema.func_is_naked and try sema.typeHasRuntimeBits(final_elem_ty)) {
4156 if (sema.func_is_naked and try final_elem_ty.hasRuntimeBitsSema(pt)) {
41574157 const mut_src = block.src(.{ .node_offset_store_ptr = inst_data.src_node });
41584158 return sema.fail(block, mut_src, "local variable in naked function", .{});
41594159 }
......@@ -17534,7 +17534,7 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1753417534 .AnyFrame,
1753517535 => {},
1753617536 }
17537 const val = try ty.lazyAbiSize(pt);
17537 const val = try ty.abiSizeLazy(pt);
1753817538 return Air.internedToRef(val.toIntern());
1753917539}
1754017540
......@@ -35313,7 +35313,7 @@ pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void {
3531335313 if (struct_type.haveLayout(ip))
3531435314 return;
3531535315
35316 try sema.resolveTypeFieldsStruct(ty.toIntern(), struct_type);
35316 try sema.resolveStructFieldTypes(ty.toIntern(), struct_type);
3531735317
3531835318 if (struct_type.layout == .@"packed") {
3531935319 sema.backingIntType(struct_type) catch |err| switch (err) {
......@@ -38454,7 +38454,7 @@ pub fn resolveDeclaredEnum(
3845438454 wip_ty.setTagTy(ip, int_tag_ty.toIntern());
3845538455
3845638456 if (small.nonexhaustive and int_tag_ty.toIntern() != .comptime_int_type) {
38457 if (fields_len > 1 and std.math.log2_int(u64, fields_len) == int_tag_ty.bitSize(pt)) {
38457 if (fields_len > 1 and std.math.log2_int(u64, fields_len) == int_tag_ty.bitSize(zcu)) {
3845838458 return sema.fail(&block, src, "non-exhaustive enum specifies every value", .{});
3845938459 }
3846038460 }
src/Type.zig+61-2
......@@ -1259,7 +1259,7 @@ pub fn abiSize(ty: Type, zcu: *Zcu) u64 {
12591259}
12601260
12611261/// May capture a reference to `ty`.
1262pub fn lazyAbiSize(ty: Type, pt: Zcu.PerThread) !Value {
1262pub fn abiSizeLazy(ty: Type, pt: Zcu.PerThread) !Value {
12631263 switch (try ty.abiSizeInner(.lazy, pt.zcu, pt.tid)) {
12641264 .val => |val| return val,
12651265 .scalar => |x| return pt.intValue(Type.comptime_int, x),
......@@ -3446,7 +3446,7 @@ pub fn structFieldOffset(
34463446 const union_type = ip.loadUnionType(ty.toIntern());
34473447 if (!union_type.hasTag(ip))
34483448 return 0;
3449 const layout = union_type.getUnionLayout(zcu);
3449 const layout = Type.getUnionLayout(union_type, zcu);
34503450 if (layout.tag_align.compare(.gte, layout.payload_align)) {
34513451 // {Tag, Payload}
34523452 return layout.payload_align.forward(layout.tag_size);
......@@ -4000,6 +4000,65 @@ fn resolveUnionInner(
40004000 };
40014001}
40024002
4003pub fn getUnionLayout(loaded_union: InternPool.LoadedUnionType, zcu: *Zcu) Zcu.UnionLayout {
4004 const ip = &zcu.intern_pool;
4005 assert(loaded_union.haveLayout(ip));
4006 var most_aligned_field: u32 = undefined;
4007 var most_aligned_field_size: u64 = undefined;
4008 var biggest_field: u32 = undefined;
4009 var payload_size: u64 = 0;
4010 var payload_align: InternPool.Alignment = .@"1";
4011 for (loaded_union.field_types.get(ip), 0..) |field_ty, field_index| {
4012 if (!Type.fromInterned(field_ty).hasRuntimeBitsIgnoreComptime(zcu)) continue;
4013
4014 const explicit_align = loaded_union.fieldAlign(ip, field_index);
4015 const field_align = if (explicit_align != .none)
4016 explicit_align
4017 else
4018 Type.fromInterned(field_ty).abiAlignment(zcu);
4019 const field_size = Type.fromInterned(field_ty).abiSize(zcu);
4020 if (field_size > payload_size) {
4021 payload_size = field_size;
4022 biggest_field = @intCast(field_index);
4023 }
4024 if (field_align.compare(.gte, payload_align)) {
4025 payload_align = field_align;
4026 most_aligned_field = @intCast(field_index);
4027 most_aligned_field_size = field_size;
4028 }
4029 }
4030 const have_tag = loaded_union.flagsUnordered(ip).runtime_tag.hasTag();
4031 if (!have_tag or !Type.fromInterned(loaded_union.enum_tag_ty).hasRuntimeBits(zcu)) {
4032 return .{
4033 .abi_size = payload_align.forward(payload_size),
4034 .abi_align = payload_align,
4035 .most_aligned_field = most_aligned_field,
4036 .most_aligned_field_size = most_aligned_field_size,
4037 .biggest_field = biggest_field,
4038 .payload_size = payload_size,
4039 .payload_align = payload_align,
4040 .tag_align = .none,
4041 .tag_size = 0,
4042 .padding = 0,
4043 };
4044 }
4045
4046 const tag_size = Type.fromInterned(loaded_union.enum_tag_ty).abiSize(zcu);
4047 const tag_align = Type.fromInterned(loaded_union.enum_tag_ty).abiAlignment(zcu).max(.@"1");
4048 return .{
4049 .abi_size = loaded_union.sizeUnordered(ip),
4050 .abi_align = tag_align.max(payload_align),
4051 .most_aligned_field = most_aligned_field,
4052 .most_aligned_field_size = most_aligned_field_size,
4053 .biggest_field = biggest_field,
4054 .payload_size = payload_size,
4055 .payload_align = payload_align,
4056 .tag_align = tag_align,
4057 .tag_size = tag_size,
4058 .padding = loaded_union.paddingUnordered(ip),
4059 };
4060}
4061
40034062/// Returns the type of a pointer to an element.
40044063/// Asserts that the type is a pointer, and that the element type is indexable.
40054064/// If the element index is comptime-known, it must be passed in `offset`.
src/Value.zig+4-4
......@@ -4196,14 +4196,14 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
41964196 const base_ptr_ty = base_ptr.typeOf(zcu);
41974197 const agg_ty = base_ptr_ty.childType(zcu);
41984198 const field_ty, const field_align = switch (agg_ty.zigTypeTag(zcu)) {
4199 .Struct => .{ agg_ty.fieldType(field.index, zcu), try agg_ty.fieldAlignmentInner(
4200 field.index,
4199 .Struct => .{ agg_ty.fieldType(@intCast(field.index), zcu), try agg_ty.fieldAlignmentInner(
4200 @intCast(field.index),
42014201 if (have_sema) .sema else .normal,
42024202 pt.zcu,
42034203 if (have_sema) pt.tid else {},
42044204 ) },
4205 .Union => .{ agg_ty.unionFieldTypeByIndex(field.index, zcu), try agg_ty.fieldAlignmentInner(
4206 field.index,
4205 .Union => .{ agg_ty.unionFieldTypeByIndex(@intCast(field.index), zcu), try agg_ty.fieldAlignmentInner(
4206 @intCast(field.index),
42074207 if (have_sema) .sema else .normal,
42084208 pt.zcu,
42094209 if (have_sema) pt.tid else {},
src/Zcu.zig+3-3
......@@ -2840,9 +2840,9 @@ pub fn addTypeReference(zcu: *Zcu, src_unit: AnalUnit, referenced_type: InternPo
28402840 gop.value_ptr.* = @intCast(ref_idx);
28412841}
28422842
2843pub fn errorSetBits(mod: *Zcu) u16 {
2844 if (mod.error_limit == 0) return 0;
2845 return @as(u16, std.math.log2_int(ErrorInt, mod.error_limit)) + 1;
2843pub fn errorSetBits(zcu: *const Zcu) u16 {
2844 if (zcu.error_limit == 0) return 0;
2845 return @as(u16, std.math.log2_int(ErrorInt, zcu.error_limit)) + 1;
28462846}
28472847
28482848pub fn errNote(
src/Zcu/PerThread.zig+1-1
......@@ -1326,7 +1326,7 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {
13261326 try decl_ty.resolveFully(pt);
13271327 }
13281328
1329 if (!resolve_type or !decl_ty.hasRuntimeBits(pt)) {
1329 if (!resolve_type or !decl_ty.hasRuntimeBits(zcu)) {
13301330 if (zcu.comp.config.use_llvm) break :queue_codegen;
13311331 if (file.mod.strip) break :queue_codegen;
13321332 }
src/arch/x86_64/CodeGen.zig+1-1
......@@ -12105,7 +12105,7 @@ fn genLocalDebugInfo(
1210512105 self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op.operand,
1210612106 ),
1210712107 };
12108 const frame_index = try self.allocFrameIndex(FrameAlloc.initSpill(ty, self.pt));
12108 const frame_index = try self.allocFrameIndex(FrameAlloc.initSpill(ty, self.pt.zcu));
1210912109 try self.genSetMem(.{ .frame = frame_index }, 0, ty, mcv, .{});
1211012110 try self.asmAirMemory(.dbg_local, inst, .{
1211112111 .base = .{ .frame = frame_index },
src/arch/x86_64/Emit.zig+1-1
......@@ -357,7 +357,7 @@ pub fn emitMir(emit: *Emit) Error!void {
357357 } } };
358358 },
359359 };
360 const ip = &emit.lower.bin_file.comp.module.?.intern_pool;
360 const ip = &emit.lower.bin_file.comp.zcu.?.intern_pool;
361361 const air_inst = emit.air.instructions.get(@intFromEnum(air_inst_index));
362362 const name: Air.NullTerminatedString = switch (air_inst.tag) {
363363 else => unreachable,
src/codegen.zig+7-7
......@@ -878,12 +878,12 @@ fn genNavRef(
878878 // TODO this feels clunky. Perhaps we should check for it in `genTypedValue`?
879879 if (ty.castPtrToFn(zcu)) |fn_ty| {
880880 if (zcu.typeToFunc(fn_ty).?.is_generic) {
881 return .{ .mcv = .{ .immediate = fn_ty.abiAlignment(pt).toByteUnits().? } };
881 return .{ .mcv = .{ .immediate = fn_ty.abiAlignment(zcu).toByteUnits().? } };
882882 }
883883 } else if (ty.zigTypeTag(zcu) == .Pointer) {
884884 const elem_ty = ty.elemType2(zcu);
885 if (!elem_ty.hasRuntimeBits(pt)) {
886 return .{ .mcv = .{ .immediate = elem_ty.abiAlignment(pt).toByteUnits().? } };
885 if (!elem_ty.hasRuntimeBits(zcu)) {
886 return .{ .mcv = .{ .immediate = elem_ty.abiAlignment(zcu).toByteUnits().? } };
887887 }
888888 }
889889
......@@ -964,15 +964,15 @@ pub fn genTypedValue(
964964 },
965965 else => switch (ip.indexToKey(val.toIntern())) {
966966 .int => {
967 return .{ .mcv = .{ .immediate = val.toUnsignedInt(pt) } };
967 return .{ .mcv = .{ .immediate = val.toUnsignedInt(zcu) } };
968968 },
969969 .ptr => |ptr| if (ptr.byte_offset == 0) switch (ptr.base_addr) {
970970 .nav => |nav| return genNavRef(lf, pt, src_loc, val, nav, target),
971 .uav => |uav| if (Value.fromInterned(uav.val).typeOf(zcu).hasRuntimeBits(pt))
971 .uav => |uav| if (Value.fromInterned(uav.val).typeOf(zcu).hasRuntimeBits(zcu))
972972 return switch (try lf.lowerUav(
973973 pt,
974974 uav.val,
975 Type.fromInterned(uav.orig_ty).ptrAlignment(pt),
975 Type.fromInterned(uav.orig_ty).ptrAlignment(zcu),
976976 src_loc,
977977 )) {
978978 .mcv => |mcv| return .{ .mcv = switch (mcv) {
......@@ -983,7 +983,7 @@ pub fn genTypedValue(
983983 .fail => |em| return .{ .fail = em },
984984 }
985985 else
986 return .{ .mcv = .{ .immediate = Type.fromInterned(uav.orig_ty).ptrAlignment(pt)
986 return .{ .mcv = .{ .immediate = Type.fromInterned(uav.orig_ty).ptrAlignment(zcu)
987987 .forward(@intCast((@as(u66, 1) << @intCast(target.ptrBitWidth() | 1)) / 3)) } },
988988 else => {},
989989 },
src/link/C.zig+1-1
......@@ -327,7 +327,7 @@ pub fn updateNav(self: *C, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) !
327327 .variable => |variable| variable.init,
328328 else => nav.status.resolved.val,
329329 };
330 if (nav_init != .none and !Value.fromInterned(nav_init).typeOf(zcu).hasRuntimeBits(pt)) return;
330 if (nav_init != .none and !Value.fromInterned(nav_init).typeOf(zcu).hasRuntimeBits(zcu)) return;
331331
332332 const gop = try self.navs.getOrPut(gpa, nav_index);
333333 errdefer _ = self.navs.pop();
src/link/Coff.zig+1-1
......@@ -1221,7 +1221,7 @@ pub fn updateNav(
12211221 else => nav_val,
12221222 };
12231223
1224 if (nav_init.typeOf(zcu).hasRuntimeBits(pt)) {
1224 if (nav_init.typeOf(zcu).hasRuntimeBits(zcu)) {
12251225 const atom_index = try self.getOrCreateAtomForNav(nav_index);
12261226 Atom.freeRelocations(self, atom_index);
12271227 const atom = self.getAtom(atom_index);
src/link/Dwarf.zig+43-43
......@@ -780,7 +780,7 @@ const Entry = struct {
780780 else
781781 "?", 0),
782782 });
783 const zcu = dwarf.bin_file.comp.module.?;
783 const zcu = dwarf.bin_file.comp.zcu.?;
784784 const ip = &zcu.intern_pool;
785785 for (dwarf.types.keys(), dwarf.types.values()) |ty, other_entry| {
786786 const ty_unit: Unit.Index = if (Type.fromInterned(ty).typeDeclInst(zcu)) |inst_index|
......@@ -1429,7 +1429,7 @@ pub const WipNav = struct {
14291429 }
14301430 } else {
14311431 try wip_nav.abbrevCode(abbrev_code.block);
1432 const bytes = Type.fromInterned(loaded_enum.tag_ty).abiSize(wip_nav.pt);
1432 const bytes = Type.fromInterned(loaded_enum.tag_ty).abiSize(wip_nav.pt.zcu);
14331433 try uleb128(diw, bytes);
14341434 big_int.writeTwosComplement(try wip_nav.debug_info.addManyAsSlice(wip_nav.dwarf.gpa, @intCast(bytes)), wip_nav.dwarf.endian);
14351435 }
......@@ -1770,7 +1770,7 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
17701770 const ty_reloc_index = try wip_nav.refForward();
17711771 try wip_nav.exprloc(.{ .addr = .{ .sym = sym_index } });
17721772 try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse
1773 ty.abiAlignment(pt).toByteUnits().?);
1773 ty.abiAlignment(zcu).toByteUnits().?);
17741774 try diw.writeByte(@intFromBool(false));
17751775 wip_nav.finishForward(ty_reloc_index);
17761776 try wip_nav.abbrevCode(.is_const);
......@@ -1821,7 +1821,7 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
18211821 const addr: Loc = .{ .addr = .{ .sym = sym_index } };
18221822 try wip_nav.exprloc(if (variable.is_threadlocal) .{ .form_tls_address = &addr } else addr);
18231823 try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse
1824 ty.abiAlignment(pt).toByteUnits().?);
1824 ty.abiAlignment(zcu).toByteUnits().?);
18251825 try diw.writeByte(@intFromBool(false));
18261826 },
18271827 .func => |func| {
......@@ -2158,8 +2158,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
21582158 try diw.writeByte(accessibility);
21592159 try wip_nav.strp(nav.name.toSlice(ip));
21602160 if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else {
2161 try uleb128(diw, nav_val.toType().abiSize(pt));
2162 try uleb128(diw, nav_val.toType().abiAlignment(pt).toByteUnits().?);
2161 try uleb128(diw, nav_val.toType().abiSize(zcu));
2162 try uleb128(diw, nav_val.toType().abiAlignment(zcu).toByteUnits().?);
21632163 for (0..loaded_struct.field_types.len) |field_index| {
21642164 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);
21652165 try wip_nav.abbrevCode(if (is_comptime) .struct_field_comptime else .struct_field);
......@@ -2173,7 +2173,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
21732173 if (!is_comptime) {
21742174 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);
21752175 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
2176 field_type.abiAlignment(pt).toByteUnits().?);
2176 field_type.abiAlignment(zcu).toByteUnits().?);
21772177 }
21782178 }
21792179 try uleb128(diw, @intFromEnum(AbbrevCode.null));
......@@ -2195,7 +2195,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
21952195 const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);
21962196 try wip_nav.refType(field_type);
21972197 try uleb128(diw, field_bit_offset);
2198 field_bit_offset += @intCast(field_type.bitSize(pt));
2198 field_bit_offset += @intCast(field_type.bitSize(zcu));
21992199 }
22002200 try uleb128(diw, @intFromEnum(AbbrevCode.null));
22012201 },
......@@ -2360,7 +2360,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
23602360 try uleb128(diw, loc.column + 1);
23612361 try diw.writeByte(accessibility);
23622362 try wip_nav.strp(nav.name.toSlice(ip));
2363 const union_layout = pt.getUnionLayout(loaded_union);
2363 const union_layout = Type.getUnionLayout(loaded_union, zcu);
23642364 try uleb128(diw, union_layout.abi_size);
23652365 try uleb128(diw, union_layout.abi_align.toByteUnits().?);
23662366 const loaded_tag = loaded_union.loadTagType(ip);
......@@ -2391,7 +2391,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
23912391 try wip_nav.refType(field_type);
23922392 try uleb128(diw, union_layout.payloadOffset());
23932393 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
2394 if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(pt).toByteUnits().?);
2394 if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?);
23952395 }
23962396 try uleb128(diw, @intFromEnum(AbbrevCode.null));
23972397 }
......@@ -2406,7 +2406,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
24062406 const field_type = Type.fromInterned(loaded_union.field_types.get(ip)[field_index]);
24072407 try wip_nav.refType(field_type);
24082408 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
2409 field_type.abiAlignment(pt).toByteUnits().?);
2409 field_type.abiAlignment(zcu).toByteUnits().?);
24102410 }
24112411 try uleb128(diw, @intFromEnum(AbbrevCode.null));
24122412 break :done;
......@@ -2560,8 +2560,8 @@ fn updateType(
25602560 inline .signed, .unsigned => |signedness| @field(DW.ATE, @tagName(signedness)),
25612561 });
25622562 try uleb128(diw, int_type.bits);
2563 try uleb128(diw, ty.abiSize(pt));
2564 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);
2563 try uleb128(diw, ty.abiSize(zcu));
2564 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
25652565 },
25662566 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
25672567 .One, .Many, .C => {
......@@ -2569,7 +2569,7 @@ fn updateType(
25692569 try wip_nav.abbrevCode(.ptr_type);
25702570 try wip_nav.strp(name);
25712571 try uleb128(diw, ptr_type.flags.alignment.toByteUnits() orelse
2572 ptr_child_type.abiAlignment(pt).toByteUnits().?);
2572 ptr_child_type.abiAlignment(zcu).toByteUnits().?);
25732573 try diw.writeByte(@intFromEnum(ptr_type.flags.address_space));
25742574 if (ptr_type.flags.is_const or ptr_type.flags.is_volatile) try wip_nav.infoSectionOffset(
25752575 .debug_info,
......@@ -2594,8 +2594,8 @@ fn updateType(
25942594 .Slice => {
25952595 try wip_nav.abbrevCode(.struct_type);
25962596 try wip_nav.strp(name);
2597 try uleb128(diw, ty.abiSize(pt));
2598 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);
2597 try uleb128(diw, ty.abiSize(zcu));
2598 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
25992599 try wip_nav.abbrevCode(.generated_field);
26002600 try wip_nav.strp("ptr");
26012601 const ptr_field_type = ty.slicePtrFieldType(zcu);
......@@ -2605,7 +2605,7 @@ fn updateType(
26052605 try wip_nav.strp("len");
26062606 const len_field_type = Type.usize;
26072607 try wip_nav.refType(len_field_type);
2608 try uleb128(diw, len_field_type.abiAlignment(pt).forward(ptr_field_type.abiSize(pt)));
2608 try uleb128(diw, len_field_type.abiAlignment(zcu).forward(ptr_field_type.abiSize(zcu)));
26092609 try uleb128(diw, @intFromEnum(AbbrevCode.null));
26102610 },
26112611 },
......@@ -2623,8 +2623,8 @@ fn updateType(
26232623 const opt_child_type = Type.fromInterned(opt_child_type_index);
26242624 try wip_nav.abbrevCode(.union_type);
26252625 try wip_nav.strp(name);
2626 try uleb128(diw, ty.abiSize(pt));
2627 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);
2626 try uleb128(diw, ty.abiSize(zcu));
2627 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
26282628 if (opt_child_type.isNoReturn(zcu)) {
26292629 try wip_nav.abbrevCode(.generated_field);
26302630 try wip_nav.strp("null");
......@@ -2652,8 +2652,8 @@ fn updateType(
26522652 switch (repr) {
26532653 .unpacked => {
26542654 try wip_nav.refType(Type.bool);
2655 try uleb128(diw, if (opt_child_type.hasRuntimeBits(pt))
2656 opt_child_type.abiSize(pt)
2655 try uleb128(diw, if (opt_child_type.hasRuntimeBits(zcu))
2656 opt_child_type.abiSize(zcu)
26572657 else
26582658 0);
26592659 },
......@@ -2700,8 +2700,8 @@ fn updateType(
27002700 const error_union_error_set_offset, const error_union_payload_offset = switch (error_union_type.payload_type) {
27012701 .generic_poison_type => .{ 0, 0 },
27022702 else => .{
2703 codegen.errUnionErrorOffset(error_union_payload_type, pt),
2704 codegen.errUnionPayloadOffset(error_union_payload_type, pt),
2703 codegen.errUnionErrorOffset(error_union_payload_type, zcu),
2704 codegen.errUnionPayloadOffset(error_union_payload_type, zcu),
27052705 },
27062706 };
27072707
......@@ -2710,8 +2710,8 @@ fn updateType(
27102710 if (error_union_type.error_set_type != .generic_poison_type and
27112711 error_union_type.payload_type != .generic_poison_type)
27122712 {
2713 try uleb128(diw, ty.abiSize(pt));
2714 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);
2713 try uleb128(diw, ty.abiSize(zcu));
2714 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
27152715 } else {
27162716 try uleb128(diw, 0);
27172717 try uleb128(diw, 1);
......@@ -2788,9 +2788,9 @@ fn updateType(
27882788 DW.ATE.unsigned
27892789 else
27902790 unreachable);
2791 try uleb128(diw, ty.bitSize(pt));
2792 try uleb128(diw, ty.abiSize(pt));
2793 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);
2791 try uleb128(diw, ty.bitSize(zcu));
2792 try uleb128(diw, ty.abiSize(zcu));
2793 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
27942794 },
27952795 .anyopaque,
27962796 .void,
......@@ -2820,8 +2820,8 @@ fn updateType(
28202820 } else {
28212821 try wip_nav.abbrevCode(.struct_type);
28222822 try wip_nav.strp(name);
2823 try uleb128(diw, ty.abiSize(pt));
2824 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);
2823 try uleb128(diw, ty.abiSize(zcu));
2824 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
28252825 var field_byte_offset: u64 = 0;
28262826 for (0..anon_struct_type.types.len) |field_index| {
28272827 const comptime_value = anon_struct_type.values.get(ip)[field_index];
......@@ -2834,11 +2834,11 @@ fn updateType(
28342834 const field_type = Type.fromInterned(anon_struct_type.types.get(ip)[field_index]);
28352835 try wip_nav.refType(field_type);
28362836 if (comptime_value == .none) {
2837 const field_align = field_type.abiAlignment(pt);
2837 const field_align = field_type.abiAlignment(zcu);
28382838 field_byte_offset = field_align.forward(field_byte_offset);
28392839 try uleb128(diw, field_byte_offset);
2840 try uleb128(diw, field_type.abiAlignment(pt).toByteUnits().?);
2841 field_byte_offset += field_type.abiSize(pt);
2840 try uleb128(diw, field_type.abiAlignment(zcu).toByteUnits().?);
2841 field_byte_offset += field_type.abiSize(zcu);
28422842 }
28432843 }
28442844 try uleb128(diw, @intFromEnum(AbbrevCode.null));
......@@ -2976,8 +2976,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
29762976 try uleb128(diw, file_gop.index);
29772977 try wip_nav.strp(loaded_struct.name.toSlice(ip));
29782978 if (loaded_struct.field_types.len > 0) {
2979 try uleb128(diw, ty.abiSize(pt));
2980 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);
2979 try uleb128(diw, ty.abiSize(zcu));
2980 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
29812981 for (0..loaded_struct.field_types.len) |field_index| {
29822982 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);
29832983 try wip_nav.abbrevCode(if (is_comptime) .struct_field_comptime else .struct_field);
......@@ -2991,7 +2991,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
29912991 if (!is_comptime) {
29922992 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);
29932993 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
2994 field_type.abiAlignment(pt).toByteUnits().?);
2994 field_type.abiAlignment(zcu).toByteUnits().?);
29952995 }
29962996 }
29972997 try uleb128(diw, @intFromEnum(AbbrevCode.null));
......@@ -3042,8 +3042,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
30423042 try wip_nav.abbrevCode(if (loaded_struct.field_types.len == 0) .namespace_struct_type else .struct_type);
30433043 try wip_nav.strp(name);
30443044 if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else {
3045 try uleb128(diw, ty.abiSize(pt));
3046 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);
3045 try uleb128(diw, ty.abiSize(zcu));
3046 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
30473047 for (0..loaded_struct.field_types.len) |field_index| {
30483048 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);
30493049 try wip_nav.abbrevCode(if (is_comptime) .struct_field_comptime else .struct_field);
......@@ -3057,7 +3057,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
30573057 if (!is_comptime) {
30583058 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);
30593059 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
3060 field_type.abiAlignment(pt).toByteUnits().?);
3060 field_type.abiAlignment(zcu).toByteUnits().?);
30613061 }
30623062 }
30633063 try uleb128(diw, @intFromEnum(AbbrevCode.null));
......@@ -3074,7 +3074,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
30743074 const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);
30753075 try wip_nav.refType(field_type);
30763076 try uleb128(diw, field_bit_offset);
3077 field_bit_offset += @intCast(field_type.bitSize(pt));
3077 field_bit_offset += @intCast(field_type.bitSize(zcu));
30783078 }
30793079 if (loaded_struct.field_types.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));
30803080 },
......@@ -3099,7 +3099,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
30993099 const loaded_union = ip.loadUnionType(type_index);
31003100 try wip_nav.abbrevCode(if (loaded_union.field_types.len > 0) .union_type else .empty_union_type);
31013101 try wip_nav.strp(name);
3102 const union_layout = pt.getUnionLayout(loaded_union);
3102 const union_layout = Type.getUnionLayout(loaded_union, zcu);
31033103 try uleb128(diw, union_layout.abi_size);
31043104 try uleb128(diw, union_layout.abi_align.toByteUnits().?);
31053105 const loaded_tag = loaded_union.loadTagType(ip);
......@@ -3130,7 +3130,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
31303130 try wip_nav.refType(field_type);
31313131 try uleb128(diw, union_layout.payloadOffset());
31323132 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
3133 if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(pt).toByteUnits().?);
3133 if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?);
31343134 }
31353135 try uleb128(diw, @intFromEnum(AbbrevCode.null));
31363136 }
......@@ -3145,7 +3145,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
31453145 const field_type = Type.fromInterned(loaded_union.field_types.get(ip)[field_index]);
31463146 try wip_nav.refType(field_type);
31473147 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
3148 field_type.abiAlignment(pt).toByteUnits().?);
3148 field_type.abiAlignment(zcu).toByteUnits().?);
31493149 }
31503150 if (loaded_union.field_types.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));
31513151 },
src/link/Elf/ZigObject.zig+3-3
......@@ -157,7 +157,7 @@ pub fn flushModule(self: *ZigObject, elf_file: *Elf, tid: Zcu.PerThread.Id) !voi
157157 }
158158
159159 if (build_options.enable_logging) {
160 const pt: Zcu.PerThread = .{ .zcu = elf_file.base.comp.module.?, .tid = tid };
160 const pt: Zcu.PerThread = .{ .zcu = elf_file.base.comp.zcu.?, .tid = tid };
161161 for (self.navs.keys(), self.navs.values()) |nav_index, meta| {
162162 checkNavAllocated(pt, nav_index, meta);
163163 }
......@@ -167,7 +167,7 @@ pub fn flushModule(self: *ZigObject, elf_file: *Elf, tid: Zcu.PerThread.Id) !voi
167167 }
168168
169169 if (self.dwarf) |*dwarf| {
170 const pt: Zcu.PerThread = .{ .zcu = elf_file.base.comp.module.?, .tid = tid };
170 const pt: Zcu.PerThread = .{ .zcu = elf_file.base.comp.zcu.?, .tid = tid };
171171 try dwarf.flushModule(pt);
172172
173173 const gpa = elf_file.base.comp.gpa;
......@@ -1306,7 +1306,7 @@ pub fn updateNav(
13061306 else => nav.status.resolved.val,
13071307 };
13081308
1309 if (nav_init != .none and Value.fromInterned(nav_init).typeOf(zcu).hasRuntimeBits(pt)) {
1309 if (nav_init != .none and Value.fromInterned(nav_init).typeOf(zcu).hasRuntimeBits(zcu)) {
13101310 const sym_index = try self.getOrCreateMetadataForNav(elf_file, nav_index);
13111311 self.symbol(sym_index).atom(elf_file).?.freeRelocs(self);
13121312
src/link/MachO/ZigObject.zig+2-2
......@@ -595,7 +595,7 @@ pub fn flushModule(self: *ZigObject, macho_file: *MachO, tid: Zcu.PerThread.Id)
595595 }
596596
597597 if (self.dwarf) |*dwarf| {
598 const pt: Zcu.PerThread = .{ .zcu = macho_file.base.comp.module.?, .tid = tid };
598 const pt: Zcu.PerThread = .{ .zcu = macho_file.base.comp.zcu.?, .tid = tid };
599599 try dwarf.flushModule(pt);
600600
601601 self.debug_abbrev_dirty = false;
......@@ -887,7 +887,7 @@ pub fn updateNav(
887887 else => nav.status.resolved.val,
888888 };
889889
890 if (nav_init != .none and Value.fromInterned(nav_init).typeOf(zcu).hasRuntimeBits(pt)) {
890 if (nav_init != .none and Value.fromInterned(nav_init).typeOf(zcu).hasRuntimeBits(zcu)) {
891891 const sym_index = try self.getOrCreateMetadataForNav(macho_file, nav_index);
892892 self.symbols.items[sym_index].getAtom(macho_file).?.freeRelocs(macho_file);
893893
src/link/Plan9.zig+1-1
......@@ -457,7 +457,7 @@ pub fn updateNav(self: *Plan9, pt: Zcu.PerThread, nav_index: InternPool.Nav.Inde
457457 else => nav_val,
458458 };
459459
460 if (nav_init.typeOf(zcu).hasRuntimeBits(pt)) {
460 if (nav_init.typeOf(zcu).hasRuntimeBits(zcu)) {
461461 const atom_idx = try self.seeNav(pt, nav_index);
462462
463463 var code_buffer = std.ArrayList(u8).init(gpa);
src/link/Wasm/ZigObject.zig+1-1
......@@ -259,7 +259,7 @@ pub fn updateNav(
259259 else => .{ false, .none, nav_val },
260260 };
261261
262 if (nav_init.typeOf(zcu).hasRuntimeBits(pt)) {
262 if (nav_init.typeOf(zcu).hasRuntimeBits(zcu)) {
263263 const gpa = wasm_file.base.comp.gpa;
264264 const atom_index = try zig_object.getOrCreateAtomForNav(wasm_file, pt, nav_index);
265265 const atom = wasm_file.getAtomPtr(atom_index);