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 {...@@ -3091,7 +3091,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
3091 var all_references: ?std.AutoHashMapUnmanaged(InternPool.AnalUnit, ?Zcu.ResolvedReference) = null;3091 var all_references: ?std.AutoHashMapUnmanaged(InternPool.AnalUnit, ?Zcu.ResolvedReference) = null;
3092 defer if (all_references) |*a| a.deinit(gpa);3092 defer if (all_references) |*a| a.deinit(gpa);
30933093
3094 if (comp.module) |zcu| {3094 if (comp.zcu) |zcu| {
3095 const ip = &zcu.intern_pool;3095 const ip = &zcu.intern_pool;
30963096
3097 for (zcu.failed_files.keys(), zcu.failed_files.values()) |file, error_msg| {3097 for (zcu.failed_files.keys(), zcu.failed_files.values()) |file, error_msg| {
...@@ -3268,7 +3268,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {...@@ -3268,7 +3268,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
3268 }3268 }
3269 }3269 }
32703270
3271 if (comp.module) |zcu| {3271 if (comp.zcu) |zcu| {
3272 if (comp.incremental and bundle.root_list.items.len == 0) {3272 if (comp.incremental and bundle.root_list.items.len == 0) {
3273 const should_have_error = for (zcu.transitive_failed_analysis.keys()) |failed_unit| {3273 const should_have_error = for (zcu.transitive_failed_analysis.keys()) |failed_unit| {
3274 if (all_references == null) {3274 if (all_references == null) {
...@@ -3976,7 +3976,7 @@ fn processOneCodegenJob(tid: usize, comp: *Compilation, codegen_job: CodegenJob)...@@ -3976,7 +3976,7 @@ fn processOneCodegenJob(tid: usize, comp: *Compilation, codegen_job: CodegenJob)
3976 const named_frame = tracy.namedFrame("codegen_type");3976 const named_frame = tracy.namedFrame("codegen_type");
3977 defer named_frame.end();3977 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) };
3980 try pt.linkerUpdateContainerType(ty);3980 try pt.linkerUpdateContainerType(ty);
3981 },3981 },
3982 }3982 }
...@@ -4258,7 +4258,7 @@ fn workerAstGenFile(...@@ -4258,7 +4258,7 @@ fn workerAstGenFile(
4258 const child_prog_node = prog_node.start(file.sub_file_path, 0);4258 const child_prog_node = prog_node.start(file.sub_file_path, 0);
4259 defer child_prog_node.end();4259 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) };
4262 pt.astGenFile(file, path_digest) catch |err| switch (err) {4262 pt.astGenFile(file, path_digest) catch |err| switch (err) {
4263 error.AnalysisFail => return,4263 error.AnalysisFail => return,
4264 else => {4264 else => {
src/Sema.zig+7-7
...@@ -3544,7 +3544,7 @@ fn zirAllocExtended(...@@ -3544,7 +3544,7 @@ fn zirAllocExtended(
3544 }3544 }
3545 const target = pt.zcu.getTarget();3545 const target = pt.zcu.getTarget();
3546 try var_ty.resolveLayout(pt);3546 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)) {
3548 const var_src = block.src(.{ .node_offset_store_ptr = extra.data.src_node });3548 const var_src = block.src(.{ .node_offset_store_ptr = extra.data.src_node });
3549 return sema.fail(block, var_src, "local variable in naked function", .{});3549 return sema.fail(block, var_src, "local variable in naked function", .{});
3550 }3550 }
...@@ -3988,7 +3988,7 @@ fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I...@@ -3988,7 +3988,7 @@ fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
3988 if (block.is_comptime) {3988 if (block.is_comptime) {
3989 return sema.analyzeComptimeAlloc(block, var_ty, .none);3989 return sema.analyzeComptimeAlloc(block, var_ty, .none);
3990 }3990 }
3991 if (sema.func_is_naked and try sema.typeHasRuntimeBits(var_ty)) {3991 if (sema.func_is_naked and try var_ty.hasRuntimeBitsSema(pt)) {
3992 const mut_src = block.src(.{ .node_offset_store_ptr = inst_data.src_node });3992 const mut_src = block.src(.{ .node_offset_store_ptr = inst_data.src_node });
3993 return sema.fail(block, mut_src, "local variable in naked function", .{});3993 return sema.fail(block, mut_src, "local variable in naked function", .{});
3994 }3994 }
...@@ -4016,7 +4016,7 @@ fn zirAllocMut(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -4016,7 +4016,7 @@ fn zirAllocMut(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
4016 if (block.is_comptime) {4016 if (block.is_comptime) {
4017 return sema.analyzeComptimeAlloc(block, var_ty, .none);4017 return sema.analyzeComptimeAlloc(block, var_ty, .none);
4018 }4018 }
4019 if (sema.func_is_naked and try sema.typeHasRuntimeBits(var_ty)) {4019 if (sema.func_is_naked and try var_ty.hasRuntimeBitsSema(pt)) {
4020 const var_src = block.src(.{ .node_offset_store_ptr = inst_data.src_node });4020 const var_src = block.src(.{ .node_offset_store_ptr = inst_data.src_node });
4021 return sema.fail(block, var_src, "local variable in naked function", .{});4021 return sema.fail(block, var_src, "local variable in naked function", .{});
4022 }4022 }
...@@ -4153,7 +4153,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com...@@ -4153,7 +4153,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
4153 // TODO: source location of runtime control flow4153 // TODO: source location of runtime control flow
4154 return sema.fail(block, src, "value with comptime-only type '{}' depends on runtime control flow", .{final_elem_ty.fmt(pt)});4154 return sema.fail(block, src, "value with comptime-only type '{}' depends on runtime control flow", .{final_elem_ty.fmt(pt)});
4155 }4155 }
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)) {
4157 const mut_src = block.src(.{ .node_offset_store_ptr = inst_data.src_node });4157 const mut_src = block.src(.{ .node_offset_store_ptr = inst_data.src_node });
4158 return sema.fail(block, mut_src, "local variable in naked function", .{});4158 return sema.fail(block, mut_src, "local variable in naked function", .{});
4159 }4159 }
...@@ -17534,7 +17534,7 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -17534,7 +17534,7 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
17534 .AnyFrame,17534 .AnyFrame,
17535 => {},17535 => {},
17536 }17536 }
17537 const val = try ty.lazyAbiSize(pt);17537 const val = try ty.abiSizeLazy(pt);
17538 return Air.internedToRef(val.toIntern());17538 return Air.internedToRef(val.toIntern());
17539}17539}
1754017540
...@@ -35313,7 +35313,7 @@ pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void {...@@ -35313,7 +35313,7 @@ pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void {
35313 if (struct_type.haveLayout(ip))35313 if (struct_type.haveLayout(ip))
35314 return;35314 return;
3531535315
35316 try sema.resolveTypeFieldsStruct(ty.toIntern(), struct_type);35316 try sema.resolveStructFieldTypes(ty.toIntern(), struct_type);
3531735317
35318 if (struct_type.layout == .@"packed") {35318 if (struct_type.layout == .@"packed") {
35319 sema.backingIntType(struct_type) catch |err| switch (err) {35319 sema.backingIntType(struct_type) catch |err| switch (err) {
...@@ -38454,7 +38454,7 @@ pub fn resolveDeclaredEnum(...@@ -38454,7 +38454,7 @@ pub fn resolveDeclaredEnum(
38454 wip_ty.setTagTy(ip, int_tag_ty.toIntern());38454 wip_ty.setTagTy(ip, int_tag_ty.toIntern());
3845538455
38456 if (small.nonexhaustive and int_tag_ty.toIntern() != .comptime_int_type) {38456 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)) {
38458 return sema.fail(&block, src, "non-exhaustive enum specifies every value", .{});38458 return sema.fail(&block, src, "non-exhaustive enum specifies every value", .{});
38459 }38459 }
38460 }38460 }
src/Type.zig+61-2
...@@ -1259,7 +1259,7 @@ pub fn abiSize(ty: Type, zcu: *Zcu) u64 {...@@ -1259,7 +1259,7 @@ pub fn abiSize(ty: Type, zcu: *Zcu) u64 {
1259}1259}
12601260
1261/// May capture a reference to `ty`.1261/// May capture a reference to `ty`.
1262pub fn lazyAbiSize(ty: Type, pt: Zcu.PerThread) !Value {1262pub fn abiSizeLazy(ty: Type, pt: Zcu.PerThread) !Value {
1263 switch (try ty.abiSizeInner(.lazy, pt.zcu, pt.tid)) {1263 switch (try ty.abiSizeInner(.lazy, pt.zcu, pt.tid)) {
1264 .val => |val| return val,1264 .val => |val| return val,
1265 .scalar => |x| return pt.intValue(Type.comptime_int, x),1265 .scalar => |x| return pt.intValue(Type.comptime_int, x),
...@@ -3446,7 +3446,7 @@ pub fn structFieldOffset(...@@ -3446,7 +3446,7 @@ pub fn structFieldOffset(
3446 const union_type = ip.loadUnionType(ty.toIntern());3446 const union_type = ip.loadUnionType(ty.toIntern());
3447 if (!union_type.hasTag(ip))3447 if (!union_type.hasTag(ip))
3448 return 0;3448 return 0;
3449 const layout = union_type.getUnionLayout(zcu);3449 const layout = Type.getUnionLayout(union_type, zcu);
3450 if (layout.tag_align.compare(.gte, layout.payload_align)) {3450 if (layout.tag_align.compare(.gte, layout.payload_align)) {
3451 // {Tag, Payload}3451 // {Tag, Payload}
3452 return layout.payload_align.forward(layout.tag_size);3452 return layout.payload_align.forward(layout.tag_size);
...@@ -4000,6 +4000,65 @@ fn resolveUnionInner(...@@ -4000,6 +4000,65 @@ fn resolveUnionInner(
4000 };4000 };
4001}4001}
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
4003/// Returns the type of a pointer to an element.4062/// Returns the type of a pointer to an element.
4004/// Asserts that the type is a pointer, and that the element type is indexable.4063/// Asserts that the type is a pointer, and that the element type is indexable.
4005/// If the element index is comptime-known, it must be passed in `offset`.4064/// 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...@@ -4196,14 +4196,14 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
4196 const base_ptr_ty = base_ptr.typeOf(zcu);4196 const base_ptr_ty = base_ptr.typeOf(zcu);
4197 const agg_ty = base_ptr_ty.childType(zcu);4197 const agg_ty = base_ptr_ty.childType(zcu);
4198 const field_ty, const field_align = switch (agg_ty.zigTypeTag(zcu)) {4198 const field_ty, const field_align = switch (agg_ty.zigTypeTag(zcu)) {
4199 .Struct => .{ agg_ty.fieldType(field.index, zcu), try agg_ty.fieldAlignmentInner(4199 .Struct => .{ agg_ty.fieldType(@intCast(field.index), zcu), try agg_ty.fieldAlignmentInner(
4200 field.index,4200 @intCast(field.index),
4201 if (have_sema) .sema else .normal,4201 if (have_sema) .sema else .normal,
4202 pt.zcu,4202 pt.zcu,
4203 if (have_sema) pt.tid else {},4203 if (have_sema) pt.tid else {},
4204 ) },4204 ) },
4205 .Union => .{ agg_ty.unionFieldTypeByIndex(field.index, zcu), try agg_ty.fieldAlignmentInner(4205 .Union => .{ agg_ty.unionFieldTypeByIndex(@intCast(field.index), zcu), try agg_ty.fieldAlignmentInner(
4206 field.index,4206 @intCast(field.index),
4207 if (have_sema) .sema else .normal,4207 if (have_sema) .sema else .normal,
4208 pt.zcu,4208 pt.zcu,
4209 if (have_sema) pt.tid else {},4209 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...@@ -2840,9 +2840,9 @@ pub fn addTypeReference(zcu: *Zcu, src_unit: AnalUnit, referenced_type: InternPo
2840 gop.value_ptr.* = @intCast(ref_idx);2840 gop.value_ptr.* = @intCast(ref_idx);
2841}2841}
28422842
2843pub fn errorSetBits(mod: *Zcu) u16 {2843pub fn errorSetBits(zcu: *const Zcu) u16 {
2844 if (mod.error_limit == 0) return 0;2844 if (zcu.error_limit == 0) return 0;
2845 return @as(u16, std.math.log2_int(ErrorInt, mod.error_limit)) + 1;2845 return @as(u16, std.math.log2_int(ErrorInt, zcu.error_limit)) + 1;
2846}2846}
28472847
2848pub fn errNote(2848pub fn errNote(
src/Zcu/PerThread.zig+1-1
...@@ -1326,7 +1326,7 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {...@@ -1326,7 +1326,7 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {
1326 try decl_ty.resolveFully(pt);1326 try decl_ty.resolveFully(pt);
1327 }1327 }
13281328
1329 if (!resolve_type or !decl_ty.hasRuntimeBits(pt)) {1329 if (!resolve_type or !decl_ty.hasRuntimeBits(zcu)) {
1330 if (zcu.comp.config.use_llvm) break :queue_codegen;1330 if (zcu.comp.config.use_llvm) break :queue_codegen;
1331 if (file.mod.strip) break :queue_codegen;1331 if (file.mod.strip) break :queue_codegen;
1332 }1332 }
src/arch/x86_64/CodeGen.zig+1-1
...@@ -12105,7 +12105,7 @@ fn genLocalDebugInfo(...@@ -12105,7 +12105,7 @@ fn genLocalDebugInfo(
12105 self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op.operand,12105 self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op.operand,
12106 ),12106 ),
12107 };12107 };
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));
12109 try self.genSetMem(.{ .frame = frame_index }, 0, ty, mcv, .{});12109 try self.genSetMem(.{ .frame = frame_index }, 0, ty, mcv, .{});
12110 try self.asmAirMemory(.dbg_local, inst, .{12110 try self.asmAirMemory(.dbg_local, inst, .{
12111 .base = .{ .frame = frame_index },12111 .base = .{ .frame = frame_index },
src/arch/x86_64/Emit.zig+1-1
...@@ -357,7 +357,7 @@ pub fn emitMir(emit: *Emit) Error!void {...@@ -357,7 +357,7 @@ pub fn emitMir(emit: *Emit) Error!void {
357 } } };357 } } };
358 },358 },
359 };359 };
360 const ip = &emit.lower.bin_file.comp.module.?.intern_pool;360 const ip = &emit.lower.bin_file.comp.zcu.?.intern_pool;
361 const air_inst = emit.air.instructions.get(@intFromEnum(air_inst_index));361 const air_inst = emit.air.instructions.get(@intFromEnum(air_inst_index));
362 const name: Air.NullTerminatedString = switch (air_inst.tag) {362 const name: Air.NullTerminatedString = switch (air_inst.tag) {
363 else => unreachable,363 else => unreachable,
src/codegen.zig+7-7
...@@ -878,12 +878,12 @@ fn genNavRef(...@@ -878,12 +878,12 @@ fn genNavRef(
878 // TODO this feels clunky. Perhaps we should check for it in `genTypedValue`?878 // TODO this feels clunky. Perhaps we should check for it in `genTypedValue`?
879 if (ty.castPtrToFn(zcu)) |fn_ty| {879 if (ty.castPtrToFn(zcu)) |fn_ty| {
880 if (zcu.typeToFunc(fn_ty).?.is_generic) {880 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().? } };
882 }882 }
883 } else if (ty.zigTypeTag(zcu) == .Pointer) {883 } else if (ty.zigTypeTag(zcu) == .Pointer) {
884 const elem_ty = ty.elemType2(zcu);884 const elem_ty = ty.elemType2(zcu);
885 if (!elem_ty.hasRuntimeBits(pt)) {885 if (!elem_ty.hasRuntimeBits(zcu)) {
886 return .{ .mcv = .{ .immediate = elem_ty.abiAlignment(pt).toByteUnits().? } };886 return .{ .mcv = .{ .immediate = elem_ty.abiAlignment(zcu).toByteUnits().? } };
887 }887 }
888 }888 }
889889
...@@ -964,15 +964,15 @@ pub fn genTypedValue(...@@ -964,15 +964,15 @@ pub fn genTypedValue(
964 },964 },
965 else => switch (ip.indexToKey(val.toIntern())) {965 else => switch (ip.indexToKey(val.toIntern())) {
966 .int => {966 .int => {
967 return .{ .mcv = .{ .immediate = val.toUnsignedInt(pt) } };967 return .{ .mcv = .{ .immediate = val.toUnsignedInt(zcu) } };
968 },968 },
969 .ptr => |ptr| if (ptr.byte_offset == 0) switch (ptr.base_addr) {969 .ptr => |ptr| if (ptr.byte_offset == 0) switch (ptr.base_addr) {
970 .nav => |nav| return genNavRef(lf, pt, src_loc, val, nav, target),970 .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))
972 return switch (try lf.lowerUav(972 return switch (try lf.lowerUav(
973 pt,973 pt,
974 uav.val,974 uav.val,
975 Type.fromInterned(uav.orig_ty).ptrAlignment(pt),975 Type.fromInterned(uav.orig_ty).ptrAlignment(zcu),
976 src_loc,976 src_loc,
977 )) {977 )) {
978 .mcv => |mcv| return .{ .mcv = switch (mcv) {978 .mcv => |mcv| return .{ .mcv = switch (mcv) {
...@@ -983,7 +983,7 @@ pub fn genTypedValue(...@@ -983,7 +983,7 @@ pub fn genTypedValue(
983 .fail => |em| return .{ .fail = em },983 .fail => |em| return .{ .fail = em },
984 }984 }
985 else985 else
986 return .{ .mcv = .{ .immediate = Type.fromInterned(uav.orig_ty).ptrAlignment(pt)986 return .{ .mcv = .{ .immediate = Type.fromInterned(uav.orig_ty).ptrAlignment(zcu)
987 .forward(@intCast((@as(u66, 1) << @intCast(target.ptrBitWidth() | 1)) / 3)) } },987 .forward(@intCast((@as(u66, 1) << @intCast(target.ptrBitWidth() | 1)) / 3)) } },
988 else => {},988 else => {},
989 },989 },
src/link/C.zig+1-1
...@@ -327,7 +327,7 @@ pub fn updateNav(self: *C, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) !...@@ -327,7 +327,7 @@ pub fn updateNav(self: *C, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) !
327 .variable => |variable| variable.init,327 .variable => |variable| variable.init,
328 else => nav.status.resolved.val,328 else => nav.status.resolved.val,
329 };329 };
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
332 const gop = try self.navs.getOrPut(gpa, nav_index);332 const gop = try self.navs.getOrPut(gpa, nav_index);
333 errdefer _ = self.navs.pop();333 errdefer _ = self.navs.pop();
src/link/Coff.zig+1-1
...@@ -1221,7 +1221,7 @@ pub fn updateNav(...@@ -1221,7 +1221,7 @@ pub fn updateNav(
1221 else => nav_val,1221 else => nav_val,
1222 };1222 };
12231223
1224 if (nav_init.typeOf(zcu).hasRuntimeBits(pt)) {1224 if (nav_init.typeOf(zcu).hasRuntimeBits(zcu)) {
1225 const atom_index = try self.getOrCreateAtomForNav(nav_index);1225 const atom_index = try self.getOrCreateAtomForNav(nav_index);
1226 Atom.freeRelocations(self, atom_index);1226 Atom.freeRelocations(self, atom_index);
1227 const atom = self.getAtom(atom_index);1227 const atom = self.getAtom(atom_index);
src/link/Dwarf.zig+43-43
...@@ -780,7 +780,7 @@ const Entry = struct {...@@ -780,7 +780,7 @@ const Entry = struct {
780 else780 else
781 "?", 0),781 "?", 0),
782 });782 });
783 const zcu = dwarf.bin_file.comp.module.?;783 const zcu = dwarf.bin_file.comp.zcu.?;
784 const ip = &zcu.intern_pool;784 const ip = &zcu.intern_pool;
785 for (dwarf.types.keys(), dwarf.types.values()) |ty, other_entry| {785 for (dwarf.types.keys(), dwarf.types.values()) |ty, other_entry| {
786 const ty_unit: Unit.Index = if (Type.fromInterned(ty).typeDeclInst(zcu)) |inst_index|786 const ty_unit: Unit.Index = if (Type.fromInterned(ty).typeDeclInst(zcu)) |inst_index|
...@@ -1429,7 +1429,7 @@ pub const WipNav = struct {...@@ -1429,7 +1429,7 @@ pub const WipNav = struct {
1429 }1429 }
1430 } else {1430 } else {
1431 try wip_nav.abbrevCode(abbrev_code.block);1431 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);
1433 try uleb128(diw, bytes);1433 try uleb128(diw, bytes);
1434 big_int.writeTwosComplement(try wip_nav.debug_info.addManyAsSlice(wip_nav.dwarf.gpa, @intCast(bytes)), wip_nav.dwarf.endian);1434 big_int.writeTwosComplement(try wip_nav.debug_info.addManyAsSlice(wip_nav.dwarf.gpa, @intCast(bytes)), wip_nav.dwarf.endian);
1435 }1435 }
...@@ -1770,7 +1770,7 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In...@@ -1770,7 +1770,7 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
1770 const ty_reloc_index = try wip_nav.refForward();1770 const ty_reloc_index = try wip_nav.refForward();
1771 try wip_nav.exprloc(.{ .addr = .{ .sym = sym_index } });1771 try wip_nav.exprloc(.{ .addr = .{ .sym = sym_index } });
1772 try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse1772 try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse
1773 ty.abiAlignment(pt).toByteUnits().?);1773 ty.abiAlignment(zcu).toByteUnits().?);
1774 try diw.writeByte(@intFromBool(false));1774 try diw.writeByte(@intFromBool(false));
1775 wip_nav.finishForward(ty_reloc_index);1775 wip_nav.finishForward(ty_reloc_index);
1776 try wip_nav.abbrevCode(.is_const);1776 try wip_nav.abbrevCode(.is_const);
...@@ -1821,7 +1821,7 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In...@@ -1821,7 +1821,7 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
1821 const addr: Loc = .{ .addr = .{ .sym = sym_index } };1821 const addr: Loc = .{ .addr = .{ .sym = sym_index } };
1822 try wip_nav.exprloc(if (variable.is_threadlocal) .{ .form_tls_address = &addr } else addr);1822 try wip_nav.exprloc(if (variable.is_threadlocal) .{ .form_tls_address = &addr } else addr);
1823 try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse1823 try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse
1824 ty.abiAlignment(pt).toByteUnits().?);1824 ty.abiAlignment(zcu).toByteUnits().?);
1825 try diw.writeByte(@intFromBool(false));1825 try diw.writeByte(@intFromBool(false));
1826 },1826 },
1827 .func => |func| {1827 .func => |func| {
...@@ -2158,8 +2158,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2158,8 +2158,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2158 try diw.writeByte(accessibility);2158 try diw.writeByte(accessibility);
2159 try wip_nav.strp(nav.name.toSlice(ip));2159 try wip_nav.strp(nav.name.toSlice(ip));
2160 if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else {2160 if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else {
2161 try uleb128(diw, nav_val.toType().abiSize(pt));2161 try uleb128(diw, nav_val.toType().abiSize(zcu));
2162 try uleb128(diw, nav_val.toType().abiAlignment(pt).toByteUnits().?);2162 try uleb128(diw, nav_val.toType().abiAlignment(zcu).toByteUnits().?);
2163 for (0..loaded_struct.field_types.len) |field_index| {2163 for (0..loaded_struct.field_types.len) |field_index| {
2164 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);2164 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);
2165 try wip_nav.abbrevCode(if (is_comptime) .struct_field_comptime else .struct_field);2165 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...@@ -2173,7 +2173,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2173 if (!is_comptime) {2173 if (!is_comptime) {
2174 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);2174 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);
2175 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse2175 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
2176 field_type.abiAlignment(pt).toByteUnits().?);2176 field_type.abiAlignment(zcu).toByteUnits().?);
2177 }2177 }
2178 }2178 }
2179 try uleb128(diw, @intFromEnum(AbbrevCode.null));2179 try uleb128(diw, @intFromEnum(AbbrevCode.null));
...@@ -2195,7 +2195,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2195,7 +2195,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2195 const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);2195 const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);
2196 try wip_nav.refType(field_type);2196 try wip_nav.refType(field_type);
2197 try uleb128(diw, field_bit_offset);2197 try uleb128(diw, field_bit_offset);
2198 field_bit_offset += @intCast(field_type.bitSize(pt));2198 field_bit_offset += @intCast(field_type.bitSize(zcu));
2199 }2199 }
2200 try uleb128(diw, @intFromEnum(AbbrevCode.null));2200 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2201 },2201 },
...@@ -2360,7 +2360,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2360,7 +2360,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2360 try uleb128(diw, loc.column + 1);2360 try uleb128(diw, loc.column + 1);
2361 try diw.writeByte(accessibility);2361 try diw.writeByte(accessibility);
2362 try wip_nav.strp(nav.name.toSlice(ip));2362 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);
2364 try uleb128(diw, union_layout.abi_size);2364 try uleb128(diw, union_layout.abi_size);
2365 try uleb128(diw, union_layout.abi_align.toByteUnits().?);2365 try uleb128(diw, union_layout.abi_align.toByteUnits().?);
2366 const loaded_tag = loaded_union.loadTagType(ip);2366 const loaded_tag = loaded_union.loadTagType(ip);
...@@ -2391,7 +2391,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2391,7 +2391,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2391 try wip_nav.refType(field_type);2391 try wip_nav.refType(field_type);
2392 try uleb128(diw, union_layout.payloadOffset());2392 try uleb128(diw, union_layout.payloadOffset());
2393 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse2393 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().?);
2395 }2395 }
2396 try uleb128(diw, @intFromEnum(AbbrevCode.null));2396 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2397 }2397 }
...@@ -2406,7 +2406,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2406,7 +2406,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2406 const field_type = Type.fromInterned(loaded_union.field_types.get(ip)[field_index]);2406 const field_type = Type.fromInterned(loaded_union.field_types.get(ip)[field_index]);
2407 try wip_nav.refType(field_type);2407 try wip_nav.refType(field_type);
2408 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse2408 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
2409 field_type.abiAlignment(pt).toByteUnits().?);2409 field_type.abiAlignment(zcu).toByteUnits().?);
2410 }2410 }
2411 try uleb128(diw, @intFromEnum(AbbrevCode.null));2411 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2412 break :done;2412 break :done;
...@@ -2560,8 +2560,8 @@ fn updateType(...@@ -2560,8 +2560,8 @@ fn updateType(
2560 inline .signed, .unsigned => |signedness| @field(DW.ATE, @tagName(signedness)),2560 inline .signed, .unsigned => |signedness| @field(DW.ATE, @tagName(signedness)),
2561 });2561 });
2562 try uleb128(diw, int_type.bits);2562 try uleb128(diw, int_type.bits);
2563 try uleb128(diw, ty.abiSize(pt));2563 try uleb128(diw, ty.abiSize(zcu));
2564 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);2564 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
2565 },2565 },
2566 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {2566 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
2567 .One, .Many, .C => {2567 .One, .Many, .C => {
...@@ -2569,7 +2569,7 @@ fn updateType(...@@ -2569,7 +2569,7 @@ fn updateType(
2569 try wip_nav.abbrevCode(.ptr_type);2569 try wip_nav.abbrevCode(.ptr_type);
2570 try wip_nav.strp(name);2570 try wip_nav.strp(name);
2571 try uleb128(diw, ptr_type.flags.alignment.toByteUnits() orelse2571 try uleb128(diw, ptr_type.flags.alignment.toByteUnits() orelse
2572 ptr_child_type.abiAlignment(pt).toByteUnits().?);2572 ptr_child_type.abiAlignment(zcu).toByteUnits().?);
2573 try diw.writeByte(@intFromEnum(ptr_type.flags.address_space));2573 try diw.writeByte(@intFromEnum(ptr_type.flags.address_space));
2574 if (ptr_type.flags.is_const or ptr_type.flags.is_volatile) try wip_nav.infoSectionOffset(2574 if (ptr_type.flags.is_const or ptr_type.flags.is_volatile) try wip_nav.infoSectionOffset(
2575 .debug_info,2575 .debug_info,
...@@ -2594,8 +2594,8 @@ fn updateType(...@@ -2594,8 +2594,8 @@ fn updateType(
2594 .Slice => {2594 .Slice => {
2595 try wip_nav.abbrevCode(.struct_type);2595 try wip_nav.abbrevCode(.struct_type);
2596 try wip_nav.strp(name);2596 try wip_nav.strp(name);
2597 try uleb128(diw, ty.abiSize(pt));2597 try uleb128(diw, ty.abiSize(zcu));
2598 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);2598 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
2599 try wip_nav.abbrevCode(.generated_field);2599 try wip_nav.abbrevCode(.generated_field);
2600 try wip_nav.strp("ptr");2600 try wip_nav.strp("ptr");
2601 const ptr_field_type = ty.slicePtrFieldType(zcu);2601 const ptr_field_type = ty.slicePtrFieldType(zcu);
...@@ -2605,7 +2605,7 @@ fn updateType(...@@ -2605,7 +2605,7 @@ fn updateType(
2605 try wip_nav.strp("len");2605 try wip_nav.strp("len");
2606 const len_field_type = Type.usize;2606 const len_field_type = Type.usize;
2607 try wip_nav.refType(len_field_type);2607 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)));
2609 try uleb128(diw, @intFromEnum(AbbrevCode.null));2609 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2610 },2610 },
2611 },2611 },
...@@ -2623,8 +2623,8 @@ fn updateType(...@@ -2623,8 +2623,8 @@ fn updateType(
2623 const opt_child_type = Type.fromInterned(opt_child_type_index);2623 const opt_child_type = Type.fromInterned(opt_child_type_index);
2624 try wip_nav.abbrevCode(.union_type);2624 try wip_nav.abbrevCode(.union_type);
2625 try wip_nav.strp(name);2625 try wip_nav.strp(name);
2626 try uleb128(diw, ty.abiSize(pt));2626 try uleb128(diw, ty.abiSize(zcu));
2627 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);2627 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
2628 if (opt_child_type.isNoReturn(zcu)) {2628 if (opt_child_type.isNoReturn(zcu)) {
2629 try wip_nav.abbrevCode(.generated_field);2629 try wip_nav.abbrevCode(.generated_field);
2630 try wip_nav.strp("null");2630 try wip_nav.strp("null");
...@@ -2652,8 +2652,8 @@ fn updateType(...@@ -2652,8 +2652,8 @@ fn updateType(
2652 switch (repr) {2652 switch (repr) {
2653 .unpacked => {2653 .unpacked => {
2654 try wip_nav.refType(Type.bool);2654 try wip_nav.refType(Type.bool);
2655 try uleb128(diw, if (opt_child_type.hasRuntimeBits(pt))2655 try uleb128(diw, if (opt_child_type.hasRuntimeBits(zcu))
2656 opt_child_type.abiSize(pt)2656 opt_child_type.abiSize(zcu)
2657 else2657 else
2658 0);2658 0);
2659 },2659 },
...@@ -2700,8 +2700,8 @@ fn updateType(...@@ -2700,8 +2700,8 @@ fn updateType(
2700 const error_union_error_set_offset, const error_union_payload_offset = switch (error_union_type.payload_type) {2700 const error_union_error_set_offset, const error_union_payload_offset = switch (error_union_type.payload_type) {
2701 .generic_poison_type => .{ 0, 0 },2701 .generic_poison_type => .{ 0, 0 },
2702 else => .{2702 else => .{
2703 codegen.errUnionErrorOffset(error_union_payload_type, pt),2703 codegen.errUnionErrorOffset(error_union_payload_type, zcu),
2704 codegen.errUnionPayloadOffset(error_union_payload_type, pt),2704 codegen.errUnionPayloadOffset(error_union_payload_type, zcu),
2705 },2705 },
2706 };2706 };
27072707
...@@ -2710,8 +2710,8 @@ fn updateType(...@@ -2710,8 +2710,8 @@ fn updateType(
2710 if (error_union_type.error_set_type != .generic_poison_type and2710 if (error_union_type.error_set_type != .generic_poison_type and
2711 error_union_type.payload_type != .generic_poison_type)2711 error_union_type.payload_type != .generic_poison_type)
2712 {2712 {
2713 try uleb128(diw, ty.abiSize(pt));2713 try uleb128(diw, ty.abiSize(zcu));
2714 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);2714 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
2715 } else {2715 } else {
2716 try uleb128(diw, 0);2716 try uleb128(diw, 0);
2717 try uleb128(diw, 1);2717 try uleb128(diw, 1);
...@@ -2788,9 +2788,9 @@ fn updateType(...@@ -2788,9 +2788,9 @@ fn updateType(
2788 DW.ATE.unsigned2788 DW.ATE.unsigned
2789 else2789 else
2790 unreachable);2790 unreachable);
2791 try uleb128(diw, ty.bitSize(pt));2791 try uleb128(diw, ty.bitSize(zcu));
2792 try uleb128(diw, ty.abiSize(pt));2792 try uleb128(diw, ty.abiSize(zcu));
2793 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);2793 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
2794 },2794 },
2795 .anyopaque,2795 .anyopaque,
2796 .void,2796 .void,
...@@ -2820,8 +2820,8 @@ fn updateType(...@@ -2820,8 +2820,8 @@ fn updateType(
2820 } else {2820 } else {
2821 try wip_nav.abbrevCode(.struct_type);2821 try wip_nav.abbrevCode(.struct_type);
2822 try wip_nav.strp(name);2822 try wip_nav.strp(name);
2823 try uleb128(diw, ty.abiSize(pt));2823 try uleb128(diw, ty.abiSize(zcu));
2824 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);2824 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
2825 var field_byte_offset: u64 = 0;2825 var field_byte_offset: u64 = 0;
2826 for (0..anon_struct_type.types.len) |field_index| {2826 for (0..anon_struct_type.types.len) |field_index| {
2827 const comptime_value = anon_struct_type.values.get(ip)[field_index];2827 const comptime_value = anon_struct_type.values.get(ip)[field_index];
...@@ -2834,11 +2834,11 @@ fn updateType(...@@ -2834,11 +2834,11 @@ fn updateType(
2834 const field_type = Type.fromInterned(anon_struct_type.types.get(ip)[field_index]);2834 const field_type = Type.fromInterned(anon_struct_type.types.get(ip)[field_index]);
2835 try wip_nav.refType(field_type);2835 try wip_nav.refType(field_type);
2836 if (comptime_value == .none) {2836 if (comptime_value == .none) {
2837 const field_align = field_type.abiAlignment(pt);2837 const field_align = field_type.abiAlignment(zcu);
2838 field_byte_offset = field_align.forward(field_byte_offset);2838 field_byte_offset = field_align.forward(field_byte_offset);
2839 try uleb128(diw, field_byte_offset);2839 try uleb128(diw, field_byte_offset);
2840 try uleb128(diw, field_type.abiAlignment(pt).toByteUnits().?);2840 try uleb128(diw, field_type.abiAlignment(zcu).toByteUnits().?);
2841 field_byte_offset += field_type.abiSize(pt);2841 field_byte_offset += field_type.abiSize(zcu);
2842 }2842 }
2843 }2843 }
2844 try uleb128(diw, @intFromEnum(AbbrevCode.null));2844 try uleb128(diw, @intFromEnum(AbbrevCode.null));
...@@ -2976,8 +2976,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -2976,8 +2976,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
2976 try uleb128(diw, file_gop.index);2976 try uleb128(diw, file_gop.index);
2977 try wip_nav.strp(loaded_struct.name.toSlice(ip));2977 try wip_nav.strp(loaded_struct.name.toSlice(ip));
2978 if (loaded_struct.field_types.len > 0) {2978 if (loaded_struct.field_types.len > 0) {
2979 try uleb128(diw, ty.abiSize(pt));2979 try uleb128(diw, ty.abiSize(zcu));
2980 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);2980 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
2981 for (0..loaded_struct.field_types.len) |field_index| {2981 for (0..loaded_struct.field_types.len) |field_index| {
2982 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);2982 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);
2983 try wip_nav.abbrevCode(if (is_comptime) .struct_field_comptime else .struct_field);2983 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...@@ -2991,7 +2991,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
2991 if (!is_comptime) {2991 if (!is_comptime) {
2992 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);2992 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);
2993 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse2993 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
2994 field_type.abiAlignment(pt).toByteUnits().?);2994 field_type.abiAlignment(zcu).toByteUnits().?);
2995 }2995 }
2996 }2996 }
2997 try uleb128(diw, @intFromEnum(AbbrevCode.null));2997 try uleb128(diw, @intFromEnum(AbbrevCode.null));
...@@ -3042,8 +3042,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3042,8 +3042,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3042 try wip_nav.abbrevCode(if (loaded_struct.field_types.len == 0) .namespace_struct_type else .struct_type);3042 try wip_nav.abbrevCode(if (loaded_struct.field_types.len == 0) .namespace_struct_type else .struct_type);
3043 try wip_nav.strp(name);3043 try wip_nav.strp(name);
3044 if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else {3044 if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else {
3045 try uleb128(diw, ty.abiSize(pt));3045 try uleb128(diw, ty.abiSize(zcu));
3046 try uleb128(diw, ty.abiAlignment(pt).toByteUnits().?);3046 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
3047 for (0..loaded_struct.field_types.len) |field_index| {3047 for (0..loaded_struct.field_types.len) |field_index| {
3048 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);3048 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);
3049 try wip_nav.abbrevCode(if (is_comptime) .struct_field_comptime else .struct_field);3049 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...@@ -3057,7 +3057,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3057 if (!is_comptime) {3057 if (!is_comptime) {
3058 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);3058 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);
3059 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse3059 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
3060 field_type.abiAlignment(pt).toByteUnits().?);3060 field_type.abiAlignment(zcu).toByteUnits().?);
3061 }3061 }
3062 }3062 }
3063 try uleb128(diw, @intFromEnum(AbbrevCode.null));3063 try uleb128(diw, @intFromEnum(AbbrevCode.null));
...@@ -3074,7 +3074,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3074,7 +3074,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3074 const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);3074 const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);
3075 try wip_nav.refType(field_type);3075 try wip_nav.refType(field_type);
3076 try uleb128(diw, field_bit_offset);3076 try uleb128(diw, field_bit_offset);
3077 field_bit_offset += @intCast(field_type.bitSize(pt));3077 field_bit_offset += @intCast(field_type.bitSize(zcu));
3078 }3078 }
3079 if (loaded_struct.field_types.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));3079 if (loaded_struct.field_types.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));
3080 },3080 },
...@@ -3099,7 +3099,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3099,7 +3099,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3099 const loaded_union = ip.loadUnionType(type_index);3099 const loaded_union = ip.loadUnionType(type_index);
3100 try wip_nav.abbrevCode(if (loaded_union.field_types.len > 0) .union_type else .empty_union_type);3100 try wip_nav.abbrevCode(if (loaded_union.field_types.len > 0) .union_type else .empty_union_type);
3101 try wip_nav.strp(name);3101 try wip_nav.strp(name);
3102 const union_layout = pt.getUnionLayout(loaded_union);3102 const union_layout = Type.getUnionLayout(loaded_union, zcu);
3103 try uleb128(diw, union_layout.abi_size);3103 try uleb128(diw, union_layout.abi_size);
3104 try uleb128(diw, union_layout.abi_align.toByteUnits().?);3104 try uleb128(diw, union_layout.abi_align.toByteUnits().?);
3105 const loaded_tag = loaded_union.loadTagType(ip);3105 const loaded_tag = loaded_union.loadTagType(ip);
...@@ -3130,7 +3130,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3130,7 +3130,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3130 try wip_nav.refType(field_type);3130 try wip_nav.refType(field_type);
3131 try uleb128(diw, union_layout.payloadOffset());3131 try uleb128(diw, union_layout.payloadOffset());
3132 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse3132 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().?);
3134 }3134 }
3135 try uleb128(diw, @intFromEnum(AbbrevCode.null));3135 try uleb128(diw, @intFromEnum(AbbrevCode.null));
3136 }3136 }
...@@ -3145,7 +3145,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3145,7 +3145,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3145 const field_type = Type.fromInterned(loaded_union.field_types.get(ip)[field_index]);3145 const field_type = Type.fromInterned(loaded_union.field_types.get(ip)[field_index]);
3146 try wip_nav.refType(field_type);3146 try wip_nav.refType(field_type);
3147 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse3147 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
3148 field_type.abiAlignment(pt).toByteUnits().?);3148 field_type.abiAlignment(zcu).toByteUnits().?);
3149 }3149 }
3150 if (loaded_union.field_types.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));3150 if (loaded_union.field_types.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));
3151 },3151 },
src/link/Elf/ZigObject.zig+3-3
...@@ -157,7 +157,7 @@ pub fn flushModule(self: *ZigObject, elf_file: *Elf, tid: Zcu.PerThread.Id) !voi...@@ -157,7 +157,7 @@ pub fn flushModule(self: *ZigObject, elf_file: *Elf, tid: Zcu.PerThread.Id) !voi
157 }157 }
158158
159 if (build_options.enable_logging) {159 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 };
161 for (self.navs.keys(), self.navs.values()) |nav_index, meta| {161 for (self.navs.keys(), self.navs.values()) |nav_index, meta| {
162 checkNavAllocated(pt, nav_index, meta);162 checkNavAllocated(pt, nav_index, meta);
163 }163 }
...@@ -167,7 +167,7 @@ pub fn flushModule(self: *ZigObject, elf_file: *Elf, tid: Zcu.PerThread.Id) !voi...@@ -167,7 +167,7 @@ pub fn flushModule(self: *ZigObject, elf_file: *Elf, tid: Zcu.PerThread.Id) !voi
167 }167 }
168168
169 if (self.dwarf) |*dwarf| {169 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 };
171 try dwarf.flushModule(pt);171 try dwarf.flushModule(pt);
172172
173 const gpa = elf_file.base.comp.gpa;173 const gpa = elf_file.base.comp.gpa;
...@@ -1306,7 +1306,7 @@ pub fn updateNav(...@@ -1306,7 +1306,7 @@ pub fn updateNav(
1306 else => nav.status.resolved.val,1306 else => nav.status.resolved.val,
1307 };1307 };
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)) {
1310 const sym_index = try self.getOrCreateMetadataForNav(elf_file, nav_index);1310 const sym_index = try self.getOrCreateMetadataForNav(elf_file, nav_index);
1311 self.symbol(sym_index).atom(elf_file).?.freeRelocs(self);1311 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)...@@ -595,7 +595,7 @@ pub fn flushModule(self: *ZigObject, macho_file: *MachO, tid: Zcu.PerThread.Id)
595 }595 }
596596
597 if (self.dwarf) |*dwarf| {597 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 };
599 try dwarf.flushModule(pt);599 try dwarf.flushModule(pt);
600600
601 self.debug_abbrev_dirty = false;601 self.debug_abbrev_dirty = false;
...@@ -887,7 +887,7 @@ pub fn updateNav(...@@ -887,7 +887,7 @@ pub fn updateNav(
887 else => nav.status.resolved.val,887 else => nav.status.resolved.val,
888 };888 };
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)) {
891 const sym_index = try self.getOrCreateMetadataForNav(macho_file, nav_index);891 const sym_index = try self.getOrCreateMetadataForNav(macho_file, nav_index);
892 self.symbols.items[sym_index].getAtom(macho_file).?.freeRelocs(macho_file);892 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...@@ -457,7 +457,7 @@ pub fn updateNav(self: *Plan9, pt: Zcu.PerThread, nav_index: InternPool.Nav.Inde
457 else => nav_val,457 else => nav_val,
458 };458 };
459459
460 if (nav_init.typeOf(zcu).hasRuntimeBits(pt)) {460 if (nav_init.typeOf(zcu).hasRuntimeBits(zcu)) {
461 const atom_idx = try self.seeNav(pt, nav_index);461 const atom_idx = try self.seeNav(pt, nav_index);
462462
463 var code_buffer = std.ArrayList(u8).init(gpa);463 var code_buffer = std.ArrayList(u8).init(gpa);
src/link/Wasm/ZigObject.zig+1-1
...@@ -259,7 +259,7 @@ pub fn updateNav(...@@ -259,7 +259,7 @@ pub fn updateNav(
259 else => .{ false, .none, nav_val },259 else => .{ false, .none, nav_val },
260 };260 };
261261
262 if (nav_init.typeOf(zcu).hasRuntimeBits(pt)) {262 if (nav_init.typeOf(zcu).hasRuntimeBits(zcu)) {
263 const gpa = wasm_file.base.comp.gpa;263 const gpa = wasm_file.base.comp.gpa;
264 const atom_index = try zig_object.getOrCreateAtomForNav(wasm_file, pt, nav_index);264 const atom_index = try zig_object.getOrCreateAtomForNav(wasm_file, pt, nav_index);
265 const atom = wasm_file.getAtomPtr(atom_index);265 const atom = wasm_file.getAtomPtr(atom_index);