mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
InternPool: add and use a mutate mutex for each list
This allows the mutate mutex to only be locked during actual grows, which are rare. For the lists that didn't previously have a mutex, this change has little effect since grows are rare and there is zero contention on a mutex that is only ever locked by one thread. This change allows `extra` to be mutated without racing with a grow.
This commit is contained in:
parent
d72a8db2db
commit
a1053e8e1d
@ -501,8 +501,8 @@ fn checkType(ty: Type, zcu: *Zcu) bool {
|
||||
.struct_type => {
|
||||
const struct_obj = zcu.typeToStruct(ty).?;
|
||||
return switch (struct_obj.layout) {
|
||||
.@"packed" => struct_obj.backingIntType(ip).* != .none,
|
||||
.auto, .@"extern" => struct_obj.flagsPtr(ip).fully_resolved,
|
||||
.@"packed" => struct_obj.backingIntTypeUnordered(ip) != .none,
|
||||
.auto, .@"extern" => struct_obj.flagsUnordered(ip).fully_resolved,
|
||||
};
|
||||
},
|
||||
.anon_struct_type => |tuple| {
|
||||
@ -516,6 +516,6 @@ fn checkType(ty: Type, zcu: *Zcu) bool {
|
||||
},
|
||||
else => unreachable,
|
||||
},
|
||||
.Union => return zcu.typeToUnion(ty).?.flagsPtr(ip).status == .fully_resolved,
|
||||
.Union => return zcu.typeToUnion(ty).?.flagsUnordered(ip).status == .fully_resolved,
|
||||
};
|
||||
}
|
||||
|
||||
@ -3011,7 +3011,7 @@ pub fn totalErrorCount(comp: *Compilation) u32 {
|
||||
}
|
||||
}
|
||||
|
||||
if (zcu.intern_pool.global_error_set.mutate.list.len > zcu.error_limit) {
|
||||
if (zcu.intern_pool.global_error_set.getNamesFromMainThread().len > zcu.error_limit) {
|
||||
total += 1;
|
||||
}
|
||||
}
|
||||
@ -3140,7 +3140,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
|
||||
try addModuleErrorMsg(zcu, &bundle, value.*, &all_references);
|
||||
}
|
||||
|
||||
const actual_error_count = zcu.intern_pool.global_error_set.mutate.list.len;
|
||||
const actual_error_count = zcu.intern_pool.global_error_set.getNamesFromMainThread().len;
|
||||
if (actual_error_count > zcu.error_limit) {
|
||||
try bundle.addRootErrorMessage(.{
|
||||
.msg = try bundle.printString("ZCU used more errors than possible: used {d}, max {d}", .{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
213
src/Sema.zig
213
src/Sema.zig
@ -2535,13 +2535,13 @@ pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Module.Error
|
||||
}
|
||||
|
||||
if (sema.owner_func_index != .none) {
|
||||
ip.funcAnalysis(sema.owner_func_index).state = .sema_failure;
|
||||
ip.funcSetAnalysisState(sema.owner_func_index, .sema_failure);
|
||||
} else {
|
||||
sema.owner_decl.analysis = .sema_failure;
|
||||
}
|
||||
|
||||
if (sema.func_index != .none) {
|
||||
ip.funcAnalysis(sema.func_index).state = .sema_failure;
|
||||
ip.funcSetAnalysisState(sema.func_index, .sema_failure);
|
||||
}
|
||||
|
||||
return error.AnalysisFail;
|
||||
@ -6555,14 +6555,7 @@ fn zirSetAlignStack(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
|
||||
}
|
||||
sema.prev_stack_alignment_src = src;
|
||||
|
||||
const ip = &mod.intern_pool;
|
||||
const a = ip.funcAnalysis(sema.func_index);
|
||||
if (a.stack_alignment != .none) {
|
||||
a.stack_alignment = @enumFromInt(@max(
|
||||
@intFromEnum(alignment),
|
||||
@intFromEnum(a.stack_alignment),
|
||||
));
|
||||
}
|
||||
mod.intern_pool.funcMaxStackAlignment(sema.func_index, alignment);
|
||||
}
|
||||
|
||||
fn zirSetCold(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
|
||||
@ -6575,7 +6568,7 @@ fn zirSetCold(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData)
|
||||
.needed_comptime_reason = "operand to @setCold must be comptime-known",
|
||||
});
|
||||
if (sema.func_index == .none) return; // does nothing outside a function
|
||||
ip.funcAnalysis(sema.func_index).is_cold = is_cold;
|
||||
ip.funcSetCold(sema.func_index, is_cold);
|
||||
}
|
||||
|
||||
fn zirSetFloatMode(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
|
||||
@ -7090,7 +7083,7 @@ fn zirCall(
|
||||
const call_inst = try sema.analyzeCall(block, func, func_ty, callee_src, call_src, modifier, ensure_result_used, args_info, call_dbg_node, .call);
|
||||
|
||||
if (sema.owner_func_index == .none or
|
||||
!mod.intern_pool.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn)
|
||||
!mod.intern_pool.funcAnalysisUnordered(sema.owner_func_index).calls_or_awaits_errorable_fn)
|
||||
{
|
||||
// No errorable fn actually called; we have no error return trace
|
||||
input_is_error = false;
|
||||
@ -7798,7 +7791,7 @@ fn analyzeCall(
|
||||
_ = ics.callee();
|
||||
|
||||
if (!inlining.has_comptime_args) {
|
||||
if (module_fn.analysis(ip).state == .sema_failure)
|
||||
if (module_fn.analysisUnordered(ip).state == .sema_failure)
|
||||
return error.AnalysisFail;
|
||||
|
||||
var block_it = block;
|
||||
@ -7821,7 +7814,7 @@ fn analyzeCall(
|
||||
try sema.resolveInst(fn_info.ret_ty_ref);
|
||||
const ret_ty_src: LazySrcLoc = .{ .base_node_inst = module_fn.zir_body_inst, .offset = .{ .node_offset_fn_type_ret_ty = 0 } };
|
||||
sema.fn_ret_ty = try sema.analyzeAsType(&child_block, ret_ty_src, ret_ty_inst);
|
||||
if (module_fn.analysis(ip).inferred_error_set) {
|
||||
if (module_fn.analysisUnordered(ip).inferred_error_set) {
|
||||
// Create a fresh inferred error set type for inline/comptime calls.
|
||||
const ies = try sema.arena.create(InferredErrorSet);
|
||||
ies.* = .{ .func = .none };
|
||||
@ -7947,7 +7940,7 @@ fn analyzeCall(
|
||||
if (call_dbg_node) |some| try sema.zirDbgStmt(block, some);
|
||||
|
||||
if (sema.owner_func_index != .none and Type.fromInterned(func_ty_info.return_type).isError(mod)) {
|
||||
ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn = true;
|
||||
ip.funcSetCallsOrAwaitsErrorableFn(sema.owner_func_index);
|
||||
}
|
||||
|
||||
if (try sema.resolveValue(func)) |func_val| {
|
||||
@ -8391,7 +8384,7 @@ fn instantiateGenericCall(
|
||||
const callee_index = (child_sema.resolveConstDefinedValue(&child_block, LazySrcLoc.unneeded, new_func_inst, undefined) catch unreachable).toIntern();
|
||||
|
||||
const callee = zcu.funcInfo(callee_index);
|
||||
callee.branchQuota(ip).* = @max(callee.branchQuota(ip).*, sema.branch_quota);
|
||||
callee.maxBranchQuota(ip, sema.branch_quota);
|
||||
|
||||
// Make a runtime call to the new function, making sure to omit the comptime args.
|
||||
const func_ty = Type.fromInterned(callee.ty);
|
||||
@ -8413,7 +8406,7 @@ fn instantiateGenericCall(
|
||||
if (sema.owner_func_index != .none and
|
||||
Type.fromInterned(func_ty_info.return_type).isError(zcu))
|
||||
{
|
||||
ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn = true;
|
||||
ip.funcSetCallsOrAwaitsErrorableFn(sema.owner_func_index);
|
||||
}
|
||||
|
||||
try sema.addReferenceEntry(call_src, AnalUnit.wrap(.{ .func = callee_index }));
|
||||
@ -8774,9 +8767,9 @@ fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD
|
||||
const int = try sema.usizeCast(block, operand_src, try value.toUnsignedIntSema(pt));
|
||||
if (int > len: {
|
||||
const mutate = &ip.global_error_set.mutate;
|
||||
mutate.mutex.lock();
|
||||
defer mutate.mutex.unlock();
|
||||
break :len mutate.list.len;
|
||||
mutate.map.mutex.lock();
|
||||
defer mutate.map.mutex.unlock();
|
||||
break :len mutate.names.len;
|
||||
} or int == 0)
|
||||
return sema.fail(block, operand_src, "integer value '{d}' represents no error", .{int});
|
||||
return Air.internedToRef((try pt.intern(.{ .err = .{
|
||||
@ -18400,7 +18393,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
|
||||
try ty.resolveLayout(pt); // Getting alignment requires type layout
|
||||
const union_obj = mod.typeToUnion(ty).?;
|
||||
const tag_type = union_obj.loadTagType(ip);
|
||||
const layout = union_obj.getLayout(ip);
|
||||
const layout = union_obj.flagsUnordered(ip).layout;
|
||||
|
||||
const union_field_vals = try gpa.alloc(InternPool.Index, tag_type.names.len);
|
||||
defer gpa.free(union_field_vals);
|
||||
@ -18718,8 +18711,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
|
||||
const backing_integer_val = try pt.intern(.{ .opt = .{
|
||||
.ty = (try pt.optionalType(.type_type)).toIntern(),
|
||||
.val = if (mod.typeToPackedStruct(ty)) |packed_struct| val: {
|
||||
assert(Type.fromInterned(packed_struct.backingIntType(ip).*).isInt(mod));
|
||||
break :val packed_struct.backingIntType(ip).*;
|
||||
assert(Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)).isInt(mod));
|
||||
break :val packed_struct.backingIntTypeUnordered(ip);
|
||||
} else .none,
|
||||
} });
|
||||
|
||||
@ -19800,7 +19793,7 @@ fn restoreErrRetIndex(sema: *Sema, start_block: *Block, src: LazySrcLoc, target_
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mod.intern_pool.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn) return;
|
||||
if (!mod.intern_pool.funcAnalysisUnordered(sema.owner_func_index).calls_or_awaits_errorable_fn) return;
|
||||
if (!start_block.ownerModule().error_tracing) return;
|
||||
|
||||
assert(saved_index != .none); // The .error_return_trace_index field was dropped somewhere
|
||||
@ -21058,7 +21051,7 @@ fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref {
|
||||
const opt_ptr_stack_trace_ty = try pt.optionalType(ptr_stack_trace_ty.toIntern());
|
||||
|
||||
if (sema.owner_func_index != .none and
|
||||
ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn and
|
||||
ip.funcAnalysisUnordered(sema.owner_func_index).calls_or_awaits_errorable_fn and
|
||||
block.ownerModule().error_tracing)
|
||||
{
|
||||
return block.addTy(.err_return_trace, opt_ptr_stack_trace_ty);
|
||||
@ -22206,8 +22199,8 @@ fn reifyUnion(
|
||||
if (any_aligns) {
|
||||
loaded_union.setFieldAligns(ip, field_aligns);
|
||||
}
|
||||
loaded_union.tagTypePtr(ip).* = enum_tag_ty;
|
||||
loaded_union.flagsPtr(ip).status = .have_field_types;
|
||||
loaded_union.setTagType(ip, enum_tag_ty);
|
||||
loaded_union.setStatus(ip, .have_field_types);
|
||||
|
||||
try pt.finalizeAnonDecl(new_decl_index);
|
||||
try mod.comp.work_queue.writeItem(.{ .resolve_type_fully = wip_ty.index });
|
||||
@ -22469,10 +22462,10 @@ fn reifyStruct(
|
||||
if (opt_backing_int_val.optionalValue(mod)) |backing_int_val| {
|
||||
const backing_int_ty = backing_int_val.toType();
|
||||
try sema.checkBackingIntType(block, src, backing_int_ty, fields_bit_sum);
|
||||
struct_type.backingIntType(ip).* = backing_int_ty.toIntern();
|
||||
struct_type.setBackingIntType(ip, backing_int_ty.toIntern());
|
||||
} else {
|
||||
const backing_int_ty = try pt.intType(.unsigned, @intCast(fields_bit_sum));
|
||||
struct_type.backingIntType(ip).* = backing_int_ty.toIntern();
|
||||
struct_type.setBackingIntType(ip, backing_int_ty.toIntern());
|
||||
}
|
||||
}
|
||||
|
||||
@ -28352,7 +28345,7 @@ fn unionFieldPtr(
|
||||
.is_const = union_ptr_info.flags.is_const,
|
||||
.is_volatile = union_ptr_info.flags.is_volatile,
|
||||
.address_space = union_ptr_info.flags.address_space,
|
||||
.alignment = if (union_obj.getLayout(ip) == .auto) blk: {
|
||||
.alignment = if (union_obj.flagsUnordered(ip).layout == .auto) blk: {
|
||||
const union_align = if (union_ptr_info.flags.alignment != .none)
|
||||
union_ptr_info.flags.alignment
|
||||
else
|
||||
@ -28380,7 +28373,7 @@ fn unionFieldPtr(
|
||||
}
|
||||
|
||||
if (try sema.resolveDefinedValue(block, src, union_ptr)) |union_ptr_val| ct: {
|
||||
switch (union_obj.getLayout(ip)) {
|
||||
switch (union_obj.flagsUnordered(ip).layout) {
|
||||
.auto => if (initializing) {
|
||||
// Store to the union to initialize the tag.
|
||||
const field_tag = try pt.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index);
|
||||
@ -28418,7 +28411,7 @@ fn unionFieldPtr(
|
||||
}
|
||||
|
||||
try sema.requireRuntimeBlock(block, src, null);
|
||||
if (!initializing and union_obj.getLayout(ip) == .auto and block.wantSafety() and
|
||||
if (!initializing and union_obj.flagsUnordered(ip).layout == .auto and block.wantSafety() and
|
||||
union_ty.unionTagTypeSafety(mod) != null and union_obj.field_types.len > 1)
|
||||
{
|
||||
const wanted_tag_val = try pt.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index);
|
||||
@ -28461,7 +28454,7 @@ fn unionFieldVal(
|
||||
const un = ip.indexToKey(union_val.toIntern()).un;
|
||||
const field_tag = try pt.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index);
|
||||
const tag_matches = un.tag == field_tag.toIntern();
|
||||
switch (union_obj.getLayout(ip)) {
|
||||
switch (union_obj.flagsUnordered(ip).layout) {
|
||||
.auto => {
|
||||
if (tag_matches) {
|
||||
return Air.internedToRef(un.val);
|
||||
@ -28495,7 +28488,7 @@ fn unionFieldVal(
|
||||
}
|
||||
|
||||
try sema.requireRuntimeBlock(block, src, null);
|
||||
if (union_obj.getLayout(ip) == .auto and block.wantSafety() and
|
||||
if (union_obj.flagsUnordered(ip).layout == .auto and block.wantSafety() and
|
||||
union_ty.unionTagTypeSafety(zcu) != null and union_obj.field_types.len > 1)
|
||||
{
|
||||
const wanted_tag_val = try pt.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index);
|
||||
@ -32042,7 +32035,7 @@ pub fn ensureDeclAnalyzed(sema: *Sema, decl_index: InternPool.DeclIndex) Compile
|
||||
|
||||
pt.ensureDeclAnalyzed(decl_index) catch |err| {
|
||||
if (sema.owner_func_index != .none) {
|
||||
ip.funcAnalysis(sema.owner_func_index).state = .dependency_failure;
|
||||
ip.funcSetAnalysisState(sema.owner_func_index, .dependency_failure);
|
||||
} else {
|
||||
sema.owner_decl.analysis = .dependency_failure;
|
||||
}
|
||||
@ -32056,7 +32049,7 @@ fn ensureFuncBodyAnalyzed(sema: *Sema, func: InternPool.Index) CompileError!void
|
||||
const ip = &mod.intern_pool;
|
||||
pt.ensureFuncBodyAnalyzed(func) catch |err| {
|
||||
if (sema.owner_func_index != .none) {
|
||||
ip.funcAnalysis(sema.owner_func_index).state = .dependency_failure;
|
||||
ip.funcSetAnalysisState(sema.owner_func_index, .dependency_failure);
|
||||
} else {
|
||||
sema.owner_decl.analysis = .dependency_failure;
|
||||
}
|
||||
@ -32402,7 +32395,7 @@ fn analyzeIsNonErrComptimeOnly(
|
||||
// If the error set is empty, we must return a comptime true or false.
|
||||
// However we want to avoid unnecessarily resolving an inferred error set
|
||||
// in case it is already non-empty.
|
||||
switch (ip.funcIesResolved(func_index).*) {
|
||||
switch (ip.funcIesResolvedUnordered(func_index)) {
|
||||
.anyerror_type => break :blk,
|
||||
.none => {},
|
||||
else => |i| if (ip.indexToKey(i).error_set_type.names.len != 0) break :blk,
|
||||
@ -33471,7 +33464,7 @@ fn wrapErrorUnionSet(
|
||||
.inferred_error_set_type => |func_index| ok: {
|
||||
// We carefully do this in an order that avoids unnecessarily
|
||||
// resolving the destination error set type.
|
||||
switch (ip.funcIesResolved(func_index).*) {
|
||||
switch (ip.funcIesResolvedUnordered(func_index)) {
|
||||
.anyerror_type => break :ok,
|
||||
.none => if (.ok == try sema.coerceInMemoryAllowedErrorSets(block, dest_err_set_ty, inst_ty, inst_src, inst_src)) {
|
||||
break :ok;
|
||||
@ -35076,33 +35069,25 @@ pub fn resolveStructAlignment(
|
||||
|
||||
assert(sema.ownerUnit().unwrap().decl == struct_type.decl.unwrap().?);
|
||||
|
||||
assert(struct_type.flagsPtr(ip).alignment == .none);
|
||||
assert(struct_type.layout != .@"packed");
|
||||
assert(struct_type.flagsUnordered(ip).alignment == .none);
|
||||
|
||||
if (struct_type.flagsPtr(ip).field_types_wip) {
|
||||
// We'll guess "pointer-aligned", if the struct has an
|
||||
// underaligned pointer field then some allocations
|
||||
// might require explicit alignment.
|
||||
struct_type.flagsPtr(ip).assumed_pointer_aligned = true;
|
||||
const result = Alignment.fromByteUnits(@divExact(target.ptrBitWidth(), 8));
|
||||
struct_type.flagsPtr(ip).alignment = result;
|
||||
return;
|
||||
}
|
||||
const ptr_align = Alignment.fromByteUnits(@divExact(target.ptrBitWidth(), 8));
|
||||
|
||||
// We'll guess "pointer-aligned", if the struct has an
|
||||
// underaligned pointer field then some allocations
|
||||
// might require explicit alignment.
|
||||
if (struct_type.assumePointerAlignedIfFieldTypesWip(ip, ptr_align)) return;
|
||||
|
||||
try sema.resolveTypeFieldsStruct(ty, struct_type);
|
||||
|
||||
if (struct_type.setAlignmentWip(ip)) {
|
||||
// We'll guess "pointer-aligned", if the struct has an
|
||||
// underaligned pointer field then some allocations
|
||||
// might require explicit alignment.
|
||||
struct_type.flagsPtr(ip).assumed_pointer_aligned = true;
|
||||
const result = Alignment.fromByteUnits(@divExact(target.ptrBitWidth(), 8));
|
||||
struct_type.flagsPtr(ip).alignment = result;
|
||||
return;
|
||||
}
|
||||
// We'll guess "pointer-aligned", if the struct has an
|
||||
// underaligned pointer field then some allocations
|
||||
// might require explicit alignment.
|
||||
if (struct_type.assumePointerAlignedIfWip(ip, ptr_align)) return;
|
||||
defer struct_type.clearAlignmentWip(ip);
|
||||
|
||||
var result: Alignment = .@"1";
|
||||
var alignment: Alignment = .@"1";
|
||||
|
||||
for (0..struct_type.field_types.len) |i| {
|
||||
const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]);
|
||||
@ -35114,10 +35099,10 @@ pub fn resolveStructAlignment(
|
||||
struct_type.layout,
|
||||
.sema,
|
||||
);
|
||||
result = result.maxStrict(field_align);
|
||||
alignment = alignment.maxStrict(field_align);
|
||||
}
|
||||
|
||||
struct_type.flagsPtr(ip).alignment = result;
|
||||
struct_type.setAlignment(ip, alignment);
|
||||
}
|
||||
|
||||
pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void {
|
||||
@ -35182,7 +35167,7 @@ pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void {
|
||||
big_align = big_align.maxStrict(field_align.*);
|
||||
}
|
||||
|
||||
if (struct_type.flagsPtr(ip).assumed_runtime_bits and !(try sema.typeHasRuntimeBits(ty))) {
|
||||
if (struct_type.flagsUnordered(ip).assumed_runtime_bits and !(try sema.typeHasRuntimeBits(ty))) {
|
||||
const msg = try sema.errMsg(
|
||||
ty.srcLoc(zcu),
|
||||
"struct layout depends on it having runtime bits",
|
||||
@ -35191,7 +35176,7 @@ pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void {
|
||||
return sema.failWithOwnedErrorMsg(null, msg);
|
||||
}
|
||||
|
||||
if (struct_type.flagsPtr(ip).assumed_pointer_aligned and
|
||||
if (struct_type.flagsUnordered(ip).assumed_pointer_aligned and
|
||||
big_align.compareStrict(.neq, Alignment.fromByteUnits(@divExact(zcu.getTarget().ptrBitWidth(), 8))))
|
||||
{
|
||||
const msg = try sema.errMsg(
|
||||
@ -35259,10 +35244,7 @@ pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void {
|
||||
offsets[i] = @intCast(aligns[i].forward(offset));
|
||||
offset = offsets[i] + sizes[i];
|
||||
}
|
||||
struct_type.size(ip).* = @intCast(big_align.forward(offset));
|
||||
const flags = struct_type.flagsPtr(ip);
|
||||
flags.alignment = big_align;
|
||||
flags.layout_resolved = true;
|
||||
struct_type.setLayoutResolved(ip, @intCast(big_align.forward(offset)), big_align);
|
||||
_ = try sema.typeRequiresComptime(ty);
|
||||
}
|
||||
|
||||
@ -35355,13 +35337,13 @@ fn semaBackingIntType(pt: Zcu.PerThread, struct_type: InternPool.LoadedStructTyp
|
||||
};
|
||||
|
||||
try sema.checkBackingIntType(&block, backing_int_src, backing_int_ty, fields_bit_sum);
|
||||
struct_type.backingIntType(ip).* = backing_int_ty.toIntern();
|
||||
struct_type.setBackingIntType(ip, backing_int_ty.toIntern());
|
||||
} else {
|
||||
if (fields_bit_sum > std.math.maxInt(u16)) {
|
||||
return sema.fail(&block, block.nodeOffset(0), "size of packed struct '{d}' exceeds maximum bit width of 65535", .{fields_bit_sum});
|
||||
}
|
||||
const backing_int_ty = try pt.intType(.unsigned, @intCast(fields_bit_sum));
|
||||
struct_type.backingIntType(ip).* = backing_int_ty.toIntern();
|
||||
struct_type.setBackingIntType(ip, backing_int_ty.toIntern());
|
||||
}
|
||||
|
||||
try sema.flushExports();
|
||||
@ -35435,15 +35417,12 @@ pub fn resolveUnionAlignment(
|
||||
|
||||
assert(!union_type.haveLayout(ip));
|
||||
|
||||
if (union_type.flagsPtr(ip).status == .field_types_wip) {
|
||||
// We'll guess "pointer-aligned", if the union has an
|
||||
// underaligned pointer field then some allocations
|
||||
// might require explicit alignment.
|
||||
union_type.flagsPtr(ip).assumed_pointer_aligned = true;
|
||||
const result = Alignment.fromByteUnits(@divExact(target.ptrBitWidth(), 8));
|
||||
union_type.flagsPtr(ip).alignment = result;
|
||||
return;
|
||||
}
|
||||
const ptr_align = Alignment.fromByteUnits(@divExact(target.ptrBitWidth(), 8));
|
||||
|
||||
// We'll guess "pointer-aligned", if the union has an
|
||||
// underaligned pointer field then some allocations
|
||||
// might require explicit alignment.
|
||||
if (union_type.assumePointerAlignedIfFieldTypesWip(ip, ptr_align)) return;
|
||||
|
||||
try sema.resolveTypeFieldsUnion(ty, union_type);
|
||||
|
||||
@ -35461,7 +35440,7 @@ pub fn resolveUnionAlignment(
|
||||
max_align = max_align.max(field_align);
|
||||
}
|
||||
|
||||
union_type.flagsPtr(ip).alignment = max_align;
|
||||
union_type.setAlignment(ip, max_align);
|
||||
}
|
||||
|
||||
/// This logic must be kept in sync with `Module.getUnionLayout`.
|
||||
@ -35476,7 +35455,8 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void {
|
||||
|
||||
assert(sema.ownerUnit().unwrap().decl == union_type.decl);
|
||||
|
||||
switch (union_type.flagsPtr(ip).status) {
|
||||
const old_flags = union_type.flagsUnordered(ip);
|
||||
switch (old_flags.status) {
|
||||
.none, .have_field_types => {},
|
||||
.field_types_wip, .layout_wip => {
|
||||
const msg = try sema.errMsg(
|
||||
@ -35489,12 +35469,9 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void {
|
||||
.have_layout, .fully_resolved_wip, .fully_resolved => return,
|
||||
}
|
||||
|
||||
const prev_status = union_type.flagsPtr(ip).status;
|
||||
errdefer if (union_type.flagsPtr(ip).status == .layout_wip) {
|
||||
union_type.flagsPtr(ip).status = prev_status;
|
||||
};
|
||||
errdefer union_type.setStatusIfLayoutWip(ip, old_flags.status);
|
||||
|
||||
union_type.flagsPtr(ip).status = .layout_wip;
|
||||
union_type.setStatus(ip, .layout_wip);
|
||||
|
||||
var max_size: u64 = 0;
|
||||
var max_align: Alignment = .@"1";
|
||||
@ -35521,8 +35498,8 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void {
|
||||
max_align = max_align.max(field_align);
|
||||
}
|
||||
|
||||
const flags = union_type.flagsPtr(ip);
|
||||
const has_runtime_tag = flags.runtime_tag.hasTag() and try sema.typeHasRuntimeBits(Type.fromInterned(union_type.enum_tag_ty));
|
||||
const has_runtime_tag = union_type.flagsUnordered(ip).runtime_tag.hasTag() and
|
||||
try sema.typeHasRuntimeBits(Type.fromInterned(union_type.enum_tag_ty));
|
||||
const size, const alignment, const padding = if (has_runtime_tag) layout: {
|
||||
const enum_tag_type = Type.fromInterned(union_type.enum_tag_ty);
|
||||
const tag_align = try sema.typeAbiAlignment(enum_tag_type);
|
||||
@ -35556,12 +35533,9 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void {
|
||||
break :layout .{ size, max_align.max(tag_align), padding };
|
||||
} else .{ max_align.forward(max_size), max_align, 0 };
|
||||
|
||||
union_type.size(ip).* = @intCast(size);
|
||||
union_type.padding(ip).* = padding;
|
||||
flags.alignment = alignment;
|
||||
flags.status = .have_layout;
|
||||
union_type.setHaveLayout(ip, @intCast(size), padding, alignment);
|
||||
|
||||
if (union_type.flagsPtr(ip).assumed_runtime_bits and !(try sema.typeHasRuntimeBits(ty))) {
|
||||
if (union_type.flagsUnordered(ip).assumed_runtime_bits and !(try sema.typeHasRuntimeBits(ty))) {
|
||||
const msg = try sema.errMsg(
|
||||
ty.srcLoc(pt.zcu),
|
||||
"union layout depends on it having runtime bits",
|
||||
@ -35570,7 +35544,7 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void {
|
||||
return sema.failWithOwnedErrorMsg(null, msg);
|
||||
}
|
||||
|
||||
if (union_type.flagsPtr(ip).assumed_pointer_aligned and
|
||||
if (union_type.flagsUnordered(ip).assumed_pointer_aligned and
|
||||
alignment.compareStrict(.neq, Alignment.fromByteUnits(@divExact(pt.zcu.getTarget().ptrBitWidth(), 8))))
|
||||
{
|
||||
const msg = try sema.errMsg(
|
||||
@ -35617,7 +35591,7 @@ pub fn resolveUnionFully(sema: *Sema, ty: Type) SemaError!void {
|
||||
|
||||
assert(sema.ownerUnit().unwrap().decl == union_obj.decl);
|
||||
|
||||
switch (union_obj.flagsPtr(ip).status) {
|
||||
switch (union_obj.flagsUnordered(ip).status) {
|
||||
.none, .have_field_types, .field_types_wip, .layout_wip, .have_layout => {},
|
||||
.fully_resolved_wip, .fully_resolved => return,
|
||||
}
|
||||
@ -35626,15 +35600,15 @@ pub fn resolveUnionFully(sema: *Sema, ty: Type) SemaError!void {
|
||||
// After we have resolve union layout we have to go over the fields again to
|
||||
// make sure pointer fields get their child types resolved as well.
|
||||
// See also similar code for structs.
|
||||
const prev_status = union_obj.flagsPtr(ip).status;
|
||||
errdefer union_obj.flagsPtr(ip).status = prev_status;
|
||||
const prev_status = union_obj.flagsUnordered(ip).status;
|
||||
errdefer union_obj.setStatus(ip, prev_status);
|
||||
|
||||
union_obj.flagsPtr(ip).status = .fully_resolved_wip;
|
||||
union_obj.setStatus(ip, .fully_resolved_wip);
|
||||
for (0..union_obj.field_types.len) |field_index| {
|
||||
const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);
|
||||
try field_ty.resolveFully(pt);
|
||||
}
|
||||
union_obj.flagsPtr(ip).status = .fully_resolved;
|
||||
union_obj.setStatus(ip, .fully_resolved);
|
||||
}
|
||||
|
||||
// And let's not forget comptime-only status.
|
||||
@ -35667,7 +35641,7 @@ pub fn resolveTypeFieldsStruct(
|
||||
|
||||
if (struct_type.haveFieldTypes(ip)) return;
|
||||
|
||||
if (struct_type.setTypesWip(ip)) {
|
||||
if (struct_type.setFieldTypesWip(ip)) {
|
||||
const msg = try sema.errMsg(
|
||||
Type.fromInterned(ty).srcLoc(zcu),
|
||||
"struct '{}' depends on itself",
|
||||
@ -35675,7 +35649,7 @@ pub fn resolveTypeFieldsStruct(
|
||||
);
|
||||
return sema.failWithOwnedErrorMsg(null, msg);
|
||||
}
|
||||
defer struct_type.clearTypesWip(ip);
|
||||
defer struct_type.clearFieldTypesWip(ip);
|
||||
|
||||
semaStructFields(pt, sema.arena, struct_type) catch |err| switch (err) {
|
||||
error.AnalysisFail => {
|
||||
@ -35744,7 +35718,7 @@ pub fn resolveTypeFieldsUnion(sema: *Sema, ty: Type, union_type: InternPool.Load
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
switch (union_type.flagsPtr(ip).status) {
|
||||
switch (union_type.flagsUnordered(ip).status) {
|
||||
.none => {},
|
||||
.field_types_wip => {
|
||||
const msg = try sema.errMsg(
|
||||
@ -35762,8 +35736,8 @@ pub fn resolveTypeFieldsUnion(sema: *Sema, ty: Type, union_type: InternPool.Load
|
||||
=> return,
|
||||
}
|
||||
|
||||
union_type.flagsPtr(ip).status = .field_types_wip;
|
||||
errdefer union_type.flagsPtr(ip).status = .none;
|
||||
union_type.setStatus(ip, .field_types_wip);
|
||||
errdefer union_type.setStatus(ip, .none);
|
||||
semaUnionFields(pt, sema.arena, union_type) catch |err| switch (err) {
|
||||
error.AnalysisFail => {
|
||||
if (owner_decl.analysis == .complete) {
|
||||
@ -35774,7 +35748,7 @@ pub fn resolveTypeFieldsUnion(sema: *Sema, ty: Type, union_type: InternPool.Load
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.ComptimeBreak, error.ComptimeReturn, error.GenericPoison => unreachable,
|
||||
};
|
||||
union_type.flagsPtr(ip).status = .have_field_types;
|
||||
union_type.setStatus(ip, .have_field_types);
|
||||
}
|
||||
|
||||
/// Returns a normal error set corresponding to the fully populated inferred
|
||||
@ -35795,10 +35769,10 @@ fn resolveInferredErrorSet(
|
||||
|
||||
// TODO: during an incremental update this might not be `.none`, but the
|
||||
// function might be out-of-date!
|
||||
const resolved_ty = func.resolvedErrorSet(ip).*;
|
||||
const resolved_ty = func.resolvedErrorSetUnordered(ip);
|
||||
if (resolved_ty != .none) return resolved_ty;
|
||||
|
||||
if (func.analysis(ip).state == .in_progress)
|
||||
if (func.analysisUnordered(ip).state == .in_progress)
|
||||
return sema.fail(block, src, "unable to resolve inferred error set", .{});
|
||||
|
||||
// In order to ensure that all dependencies are properly added to the set,
|
||||
@ -35835,7 +35809,7 @@ fn resolveInferredErrorSet(
|
||||
|
||||
// This will now have been resolved by the logic at the end of `Module.analyzeFnBody`
|
||||
// which calls `resolveInferredErrorSetPtr`.
|
||||
const final_resolved_ty = func.resolvedErrorSet(ip).*;
|
||||
const final_resolved_ty = func.resolvedErrorSetUnordered(ip);
|
||||
assert(final_resolved_ty != .none);
|
||||
return final_resolved_ty;
|
||||
}
|
||||
@ -36001,8 +35975,7 @@ fn semaStructFields(
|
||||
return;
|
||||
},
|
||||
.auto, .@"extern" => {
|
||||
struct_type.size(ip).* = 0;
|
||||
struct_type.flagsPtr(ip).layout_resolved = true;
|
||||
struct_type.setLayoutResolved(ip, 0, .none);
|
||||
return;
|
||||
},
|
||||
};
|
||||
@ -36196,7 +36169,7 @@ fn semaStructFields(
|
||||
extra_index += zir_field.init_body_len;
|
||||
}
|
||||
|
||||
struct_type.clearTypesWip(ip);
|
||||
struct_type.clearFieldTypesWip(ip);
|
||||
if (!any_inits) struct_type.setHaveFieldInits(ip);
|
||||
|
||||
try sema.flushExports();
|
||||
@ -36472,7 +36445,7 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_type: InternPool.L
|
||||
}
|
||||
} else {
|
||||
// The provided type is the enum tag type.
|
||||
union_type.tagTypePtr(ip).* = provided_ty.toIntern();
|
||||
union_type.setTagType(ip, provided_ty.toIntern());
|
||||
const enum_type = switch (ip.indexToKey(provided_ty.toIntern())) {
|
||||
.enum_type => ip.loadEnumType(provided_ty.toIntern()),
|
||||
else => return sema.fail(&block_scope, tag_ty_src, "expected enum tag type, found '{}'", .{provided_ty.fmt(pt)}),
|
||||
@ -36610,10 +36583,11 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_type: InternPool.L
|
||||
}
|
||||
|
||||
if (explicit_tags_seen.len > 0) {
|
||||
const tag_info = ip.loadEnumType(union_type.tagTypePtr(ip).*);
|
||||
const tag_ty = union_type.tagTypeUnordered(ip);
|
||||
const tag_info = ip.loadEnumType(tag_ty);
|
||||
const enum_index = tag_info.nameIndex(ip, field_name) orelse {
|
||||
return sema.fail(&block_scope, name_src, "no field named '{}' in enum '{}'", .{
|
||||
field_name.fmt(ip), Type.fromInterned(union_type.tagTypePtr(ip).*).fmt(pt),
|
||||
field_name.fmt(ip), Type.fromInterned(tag_ty).fmt(pt),
|
||||
});
|
||||
};
|
||||
|
||||
@ -36650,7 +36624,7 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_type: InternPool.L
|
||||
};
|
||||
return sema.failWithOwnedErrorMsg(&block_scope, msg);
|
||||
}
|
||||
const layout = union_type.getLayout(ip);
|
||||
const layout = union_type.flagsUnordered(ip).layout;
|
||||
if (layout == .@"extern" and
|
||||
!try sema.validateExternType(field_ty, .union_field))
|
||||
{
|
||||
@ -36693,7 +36667,8 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_type: InternPool.L
|
||||
union_type.setFieldAligns(ip, field_aligns.items);
|
||||
|
||||
if (explicit_tags_seen.len > 0) {
|
||||
const tag_info = ip.loadEnumType(union_type.tagTypePtr(ip).*);
|
||||
const tag_ty = union_type.tagTypeUnordered(ip);
|
||||
const tag_info = ip.loadEnumType(tag_ty);
|
||||
if (tag_info.names.len > fields_len) {
|
||||
const msg = msg: {
|
||||
const msg = try sema.errMsg(src, "enum field(s) missing in union", .{});
|
||||
@ -36701,21 +36676,21 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_type: InternPool.L
|
||||
|
||||
for (tag_info.names.get(ip), 0..) |field_name, field_index| {
|
||||
if (explicit_tags_seen[field_index]) continue;
|
||||
try sema.addFieldErrNote(Type.fromInterned(union_type.tagTypePtr(ip).*), field_index, msg, "field '{}' missing, declared here", .{
|
||||
try sema.addFieldErrNote(Type.fromInterned(tag_ty), field_index, msg, "field '{}' missing, declared here", .{
|
||||
field_name.fmt(ip),
|
||||
});
|
||||
}
|
||||
try sema.addDeclaredHereNote(msg, Type.fromInterned(union_type.tagTypePtr(ip).*));
|
||||
try sema.addDeclaredHereNote(msg, Type.fromInterned(tag_ty));
|
||||
break :msg msg;
|
||||
};
|
||||
return sema.failWithOwnedErrorMsg(&block_scope, msg);
|
||||
}
|
||||
} else if (enum_field_vals.count() > 0) {
|
||||
const enum_ty = try sema.generateUnionTagTypeNumbered(&block_scope, enum_field_names, enum_field_vals.keys(), zcu.declPtr(union_type.decl));
|
||||
union_type.tagTypePtr(ip).* = enum_ty;
|
||||
union_type.setTagType(ip, enum_ty);
|
||||
} else {
|
||||
const enum_ty = try sema.generateUnionTagTypeSimple(&block_scope, enum_field_names, zcu.declPtr(union_type.decl));
|
||||
union_type.tagTypePtr(ip).* = enum_ty;
|
||||
union_type.setTagType(ip, enum_ty);
|
||||
}
|
||||
|
||||
try sema.flushExports();
|
||||
@ -37091,7 +37066,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
|
||||
try ty.resolveLayout(pt);
|
||||
|
||||
const union_obj = ip.loadUnionType(ty.toIntern());
|
||||
const tag_val = (try sema.typeHasOnePossibleValue(Type.fromInterned(union_obj.tagTypePtr(ip).*))) orelse
|
||||
const tag_val = (try sema.typeHasOnePossibleValue(Type.fromInterned(union_obj.tagTypeUnordered(ip)))) orelse
|
||||
return null;
|
||||
if (union_obj.field_types.len == 0) {
|
||||
const only = try pt.intern(.{ .empty_enum_value = ty.toIntern() });
|
||||
|
||||
95
src/Type.zig
95
src/Type.zig
@ -605,17 +605,15 @@ pub fn hasRuntimeBitsAdvanced(
|
||||
|
||||
.union_type => {
|
||||
const union_type = ip.loadUnionType(ty.toIntern());
|
||||
switch (union_type.flagsPtr(ip).runtime_tag) {
|
||||
const union_flags = union_type.flagsUnordered(ip);
|
||||
switch (union_flags.runtime_tag) {
|
||||
.none => {
|
||||
if (union_type.flagsPtr(ip).status == .field_types_wip) {
|
||||
// In this case, we guess that hasRuntimeBits() for this type is true,
|
||||
// and then later if our guess was incorrect, we emit a compile error.
|
||||
union_type.flagsPtr(ip).assumed_runtime_bits = true;
|
||||
return true;
|
||||
}
|
||||
// In this case, we guess that hasRuntimeBits() for this type is true,
|
||||
// and then later if our guess was incorrect, we emit a compile error.
|
||||
if (union_type.assumeRuntimeBitsIfFieldTypesWip(ip)) return true;
|
||||
},
|
||||
.safety, .tagged => {
|
||||
const tag_ty = union_type.tagTypePtr(ip).*;
|
||||
const tag_ty = union_type.tagTypeUnordered(ip);
|
||||
// tag_ty will be `none` if this union's tag type is not resolved yet,
|
||||
// in which case we want control flow to continue down below.
|
||||
if (tag_ty != .none and
|
||||
@ -627,8 +625,8 @@ pub fn hasRuntimeBitsAdvanced(
|
||||
}
|
||||
switch (strat) {
|
||||
.sema => try ty.resolveFields(pt),
|
||||
.eager => assert(union_type.flagsPtr(ip).status.haveFieldTypes()),
|
||||
.lazy => if (!union_type.flagsPtr(ip).status.haveFieldTypes())
|
||||
.eager => assert(union_flags.status.haveFieldTypes()),
|
||||
.lazy => if (!union_flags.status.haveFieldTypes())
|
||||
return error.NeedLazy,
|
||||
}
|
||||
for (0..union_type.field_types.len) |field_index| {
|
||||
@ -745,8 +743,8 @@ pub fn hasWellDefinedLayout(ty: Type, mod: *Module) bool {
|
||||
},
|
||||
.union_type => {
|
||||
const union_type = ip.loadUnionType(ty.toIntern());
|
||||
return switch (union_type.flagsPtr(ip).runtime_tag) {
|
||||
.none, .safety => union_type.flagsPtr(ip).layout != .auto,
|
||||
return switch (union_type.flagsUnordered(ip).runtime_tag) {
|
||||
.none, .safety => union_type.flagsUnordered(ip).layout != .auto,
|
||||
.tagged => false,
|
||||
};
|
||||
},
|
||||
@ -1045,7 +1043,7 @@ pub fn abiAlignmentAdvanced(
|
||||
if (struct_type.layout == .@"packed") {
|
||||
switch (strat) {
|
||||
.sema => try ty.resolveLayout(pt),
|
||||
.lazy => if (struct_type.backingIntType(ip).* == .none) return .{
|
||||
.lazy => if (struct_type.backingIntTypeUnordered(ip) == .none) return .{
|
||||
.val = Value.fromInterned(try pt.intern(.{ .int = .{
|
||||
.ty = .comptime_int_type,
|
||||
.storage = .{ .lazy_align = ty.toIntern() },
|
||||
@ -1053,10 +1051,10 @@ pub fn abiAlignmentAdvanced(
|
||||
},
|
||||
.eager => {},
|
||||
}
|
||||
return .{ .scalar = Type.fromInterned(struct_type.backingIntType(ip).*).abiAlignment(pt) };
|
||||
return .{ .scalar = Type.fromInterned(struct_type.backingIntTypeUnordered(ip)).abiAlignment(pt) };
|
||||
}
|
||||
|
||||
if (struct_type.flagsPtr(ip).alignment == .none) switch (strat) {
|
||||
if (struct_type.flagsUnordered(ip).alignment == .none) switch (strat) {
|
||||
.eager => unreachable, // struct alignment not resolved
|
||||
.sema => try ty.resolveStructAlignment(pt),
|
||||
.lazy => return .{ .val = Value.fromInterned(try pt.intern(.{ .int = .{
|
||||
@ -1065,7 +1063,7 @@ pub fn abiAlignmentAdvanced(
|
||||
} })) },
|
||||
};
|
||||
|
||||
return .{ .scalar = struct_type.flagsPtr(ip).alignment };
|
||||
return .{ .scalar = struct_type.flagsUnordered(ip).alignment };
|
||||
},
|
||||
.anon_struct_type => |tuple| {
|
||||
var big_align: Alignment = .@"1";
|
||||
@ -1088,7 +1086,7 @@ pub fn abiAlignmentAdvanced(
|
||||
.union_type => {
|
||||
const union_type = ip.loadUnionType(ty.toIntern());
|
||||
|
||||
if (union_type.flagsPtr(ip).alignment == .none) switch (strat) {
|
||||
if (union_type.flagsUnordered(ip).alignment == .none) switch (strat) {
|
||||
.eager => unreachable, // union layout not resolved
|
||||
.sema => try ty.resolveUnionAlignment(pt),
|
||||
.lazy => return .{ .val = Value.fromInterned(try pt.intern(.{ .int = .{
|
||||
@ -1097,7 +1095,7 @@ pub fn abiAlignmentAdvanced(
|
||||
} })) },
|
||||
};
|
||||
|
||||
return .{ .scalar = union_type.flagsPtr(ip).alignment };
|
||||
return .{ .scalar = union_type.flagsUnordered(ip).alignment };
|
||||
},
|
||||
.opaque_type => return .{ .scalar = .@"1" },
|
||||
.enum_type => return .{
|
||||
@ -1420,7 +1418,7 @@ pub fn abiSizeAdvanced(
|
||||
.sema => try ty.resolveLayout(pt),
|
||||
.lazy => switch (struct_type.layout) {
|
||||
.@"packed" => {
|
||||
if (struct_type.backingIntType(ip).* == .none) return .{
|
||||
if (struct_type.backingIntTypeUnordered(ip) == .none) return .{
|
||||
.val = Value.fromInterned(try pt.intern(.{ .int = .{
|
||||
.ty = .comptime_int_type,
|
||||
.storage = .{ .lazy_size = ty.toIntern() },
|
||||
@ -1440,11 +1438,11 @@ pub fn abiSizeAdvanced(
|
||||
}
|
||||
switch (struct_type.layout) {
|
||||
.@"packed" => return .{
|
||||
.scalar = Type.fromInterned(struct_type.backingIntType(ip).*).abiSize(pt),
|
||||
.scalar = Type.fromInterned(struct_type.backingIntTypeUnordered(ip)).abiSize(pt),
|
||||
},
|
||||
.auto, .@"extern" => {
|
||||
assert(struct_type.haveLayout(ip));
|
||||
return .{ .scalar = struct_type.size(ip).* };
|
||||
return .{ .scalar = struct_type.sizeUnordered(ip) };
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -1464,7 +1462,7 @@ pub fn abiSizeAdvanced(
|
||||
const union_type = ip.loadUnionType(ty.toIntern());
|
||||
switch (strat) {
|
||||
.sema => try ty.resolveLayout(pt),
|
||||
.lazy => if (!union_type.flagsPtr(ip).status.haveLayout()) return .{
|
||||
.lazy => if (!union_type.flagsUnordered(ip).status.haveLayout()) return .{
|
||||
.val = Value.fromInterned(try pt.intern(.{ .int = .{
|
||||
.ty = .comptime_int_type,
|
||||
.storage = .{ .lazy_size = ty.toIntern() },
|
||||
@ -1474,7 +1472,7 @@ pub fn abiSizeAdvanced(
|
||||
}
|
||||
|
||||
assert(union_type.haveLayout(ip));
|
||||
return .{ .scalar = union_type.size(ip).* };
|
||||
return .{ .scalar = union_type.sizeUnordered(ip) };
|
||||
},
|
||||
.opaque_type => unreachable, // no size available
|
||||
.enum_type => return .{ .scalar = Type.fromInterned(ip.loadEnumType(ty.toIntern()).tag_ty).abiSize(pt) },
|
||||
@ -1788,7 +1786,7 @@ pub fn bitSizeAdvanced(
|
||||
if (is_packed) try ty.resolveLayout(pt);
|
||||
}
|
||||
if (is_packed) {
|
||||
return try Type.fromInterned(struct_type.backingIntType(ip).*).bitSizeAdvanced(pt, strat);
|
||||
return try Type.fromInterned(struct_type.backingIntTypeUnordered(ip)).bitSizeAdvanced(pt, strat);
|
||||
}
|
||||
return (try ty.abiSizeAdvanced(pt, strat_lazy)).scalar * 8;
|
||||
},
|
||||
@ -1808,7 +1806,7 @@ pub fn bitSizeAdvanced(
|
||||
if (!is_packed) {
|
||||
return (try ty.abiSizeAdvanced(pt, strat_lazy)).scalar * 8;
|
||||
}
|
||||
assert(union_type.flagsPtr(ip).status.haveFieldTypes());
|
||||
assert(union_type.flagsUnordered(ip).status.haveFieldTypes());
|
||||
|
||||
var size: u64 = 0;
|
||||
for (0..union_type.field_types.len) |field_index| {
|
||||
@ -2056,9 +2054,10 @@ pub fn unionTagType(ty: Type, mod: *Module) ?Type {
|
||||
else => return null,
|
||||
}
|
||||
const union_type = ip.loadUnionType(ty.toIntern());
|
||||
switch (union_type.flagsPtr(ip).runtime_tag) {
|
||||
const union_flags = union_type.flagsUnordered(ip);
|
||||
switch (union_flags.runtime_tag) {
|
||||
.tagged => {
|
||||
assert(union_type.flagsPtr(ip).status.haveFieldTypes());
|
||||
assert(union_flags.status.haveFieldTypes());
|
||||
return Type.fromInterned(union_type.enum_tag_ty);
|
||||
},
|
||||
else => return null,
|
||||
@ -2135,7 +2134,7 @@ pub fn containerLayout(ty: Type, mod: *Module) std.builtin.Type.ContainerLayout
|
||||
return switch (ip.indexToKey(ty.toIntern())) {
|
||||
.struct_type => ip.loadStructType(ty.toIntern()).layout,
|
||||
.anon_struct_type => .auto,
|
||||
.union_type => ip.loadUnionType(ty.toIntern()).flagsPtr(ip).layout,
|
||||
.union_type => ip.loadUnionType(ty.toIntern()).flagsUnordered(ip).layout,
|
||||
else => unreachable,
|
||||
};
|
||||
}
|
||||
@ -2157,7 +2156,7 @@ pub fn errorSetIsEmpty(ty: Type, mod: *Module) bool {
|
||||
.anyerror_type, .adhoc_inferred_error_set_type => false,
|
||||
else => switch (ip.indexToKey(ty.toIntern())) {
|
||||
.error_set_type => |error_set_type| error_set_type.names.len == 0,
|
||||
.inferred_error_set_type => |i| switch (ip.funcIesResolved(i).*) {
|
||||
.inferred_error_set_type => |i| switch (ip.funcIesResolvedUnordered(i)) {
|
||||
.none, .anyerror_type => false,
|
||||
else => |t| ip.indexToKey(t).error_set_type.names.len == 0,
|
||||
},
|
||||
@ -2175,7 +2174,7 @@ pub fn isAnyError(ty: Type, mod: *Module) bool {
|
||||
.anyerror_type => true,
|
||||
.adhoc_inferred_error_set_type => false,
|
||||
else => switch (mod.intern_pool.indexToKey(ty.toIntern())) {
|
||||
.inferred_error_set_type => |i| ip.funcIesResolved(i).* == .anyerror_type,
|
||||
.inferred_error_set_type => |i| ip.funcIesResolvedUnordered(i) == .anyerror_type,
|
||||
else => false,
|
||||
},
|
||||
};
|
||||
@ -2200,7 +2199,7 @@ pub fn errorSetHasFieldIp(
|
||||
.anyerror_type => true,
|
||||
else => switch (ip.indexToKey(ty)) {
|
||||
.error_set_type => |error_set_type| error_set_type.nameIndex(ip, name) != null,
|
||||
.inferred_error_set_type => |i| switch (ip.funcIesResolved(i).*) {
|
||||
.inferred_error_set_type => |i| switch (ip.funcIesResolvedUnordered(i)) {
|
||||
.anyerror_type => true,
|
||||
.none => false,
|
||||
else => |t| ip.indexToKey(t).error_set_type.nameIndex(ip, name) != null,
|
||||
@ -2336,7 +2335,7 @@ pub fn intInfo(starting_ty: Type, mod: *Module) InternPool.Key.IntType {
|
||||
.c_ulonglong_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulonglong) },
|
||||
else => switch (ip.indexToKey(ty.toIntern())) {
|
||||
.int_type => |int_type| return int_type,
|
||||
.struct_type => ty = Type.fromInterned(ip.loadStructType(ty.toIntern()).backingIntType(ip).*),
|
||||
.struct_type => ty = Type.fromInterned(ip.loadStructType(ty.toIntern()).backingIntTypeUnordered(ip)),
|
||||
.enum_type => ty = Type.fromInterned(ip.loadEnumType(ty.toIntern()).tag_ty),
|
||||
.vector_type => |vector_type| ty = Type.fromInterned(vector_type.child),
|
||||
|
||||
@ -2826,17 +2825,18 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, strat: ResolveStrat) Se
|
||||
return false;
|
||||
|
||||
// A struct with no fields is not comptime-only.
|
||||
return switch (struct_type.flagsPtr(ip).requires_comptime) {
|
||||
return switch (struct_type.setRequiresComptimeWip(ip)) {
|
||||
.no, .wip => false,
|
||||
.yes => true,
|
||||
.unknown => {
|
||||
assert(strat == .sema);
|
||||
|
||||
if (struct_type.flagsPtr(ip).field_types_wip)
|
||||
if (struct_type.flagsUnordered(ip).field_types_wip) {
|
||||
struct_type.setRequiresComptime(ip, .unknown);
|
||||
return false;
|
||||
}
|
||||
|
||||
struct_type.flagsPtr(ip).requires_comptime = .wip;
|
||||
errdefer struct_type.flagsPtr(ip).requires_comptime = .unknown;
|
||||
errdefer struct_type.setRequiresComptime(ip, .unknown);
|
||||
|
||||
try ty.resolveFields(pt);
|
||||
|
||||
@ -2849,12 +2849,12 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, strat: ResolveStrat) Se
|
||||
// be considered resolved. Comptime-only types
|
||||
// still maintain a layout of their
|
||||
// runtime-known fields.
|
||||
struct_type.flagsPtr(ip).requires_comptime = .yes;
|
||||
struct_type.setRequiresComptime(ip, .yes);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
struct_type.flagsPtr(ip).requires_comptime = .no;
|
||||
struct_type.setRequiresComptime(ip, .no);
|
||||
return false;
|
||||
},
|
||||
};
|
||||
@ -2870,29 +2870,30 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, strat: ResolveStrat) Se
|
||||
|
||||
.union_type => {
|
||||
const union_type = ip.loadUnionType(ty.toIntern());
|
||||
switch (union_type.flagsPtr(ip).requires_comptime) {
|
||||
switch (union_type.setRequiresComptimeWip(ip)) {
|
||||
.no, .wip => return false,
|
||||
.yes => return true,
|
||||
.unknown => {
|
||||
assert(strat == .sema);
|
||||
|
||||
if (union_type.flagsPtr(ip).status == .field_types_wip)
|
||||
if (union_type.flagsUnordered(ip).status == .field_types_wip) {
|
||||
union_type.setRequiresComptime(ip, .unknown);
|
||||
return false;
|
||||
}
|
||||
|
||||
union_type.flagsPtr(ip).requires_comptime = .wip;
|
||||
errdefer union_type.flagsPtr(ip).requires_comptime = .unknown;
|
||||
errdefer union_type.setRequiresComptime(ip, .unknown);
|
||||
|
||||
try ty.resolveFields(pt);
|
||||
|
||||
for (0..union_type.field_types.len) |field_idx| {
|
||||
const field_ty = union_type.field_types.get(ip)[field_idx];
|
||||
if (try Type.fromInterned(field_ty).comptimeOnlyAdvanced(pt, strat)) {
|
||||
union_type.flagsPtr(ip).requires_comptime = .yes;
|
||||
union_type.setRequiresComptime(ip, .yes);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
union_type.flagsPtr(ip).requires_comptime = .no;
|
||||
union_type.setRequiresComptime(ip, .no);
|
||||
return false;
|
||||
},
|
||||
}
|
||||
@ -3117,7 +3118,7 @@ pub fn errorSetNames(ty: Type, mod: *Module) InternPool.NullTerminatedString.Sli
|
||||
const ip = &mod.intern_pool;
|
||||
return switch (ip.indexToKey(ty.toIntern())) {
|
||||
.error_set_type => |x| x.names,
|
||||
.inferred_error_set_type => |i| switch (ip.funcIesResolved(i).*) {
|
||||
.inferred_error_set_type => |i| switch (ip.funcIesResolvedUnordered(i)) {
|
||||
.none => unreachable, // unresolved inferred error set
|
||||
.anyerror_type => unreachable,
|
||||
else => |t| ip.indexToKey(t).error_set_type.names,
|
||||
@ -3374,7 +3375,7 @@ pub fn isTuple(ty: Type, mod: *Module) bool {
|
||||
const struct_type = ip.loadStructType(ty.toIntern());
|
||||
if (struct_type.layout == .@"packed") return false;
|
||||
if (struct_type.decl == .none) return false;
|
||||
return struct_type.flagsPtr(ip).is_tuple;
|
||||
return struct_type.flagsUnordered(ip).is_tuple;
|
||||
},
|
||||
.anon_struct_type => |anon_struct| anon_struct.names.len == 0,
|
||||
else => false,
|
||||
@ -3396,7 +3397,7 @@ pub fn isTupleOrAnonStruct(ty: Type, mod: *Module) bool {
|
||||
const struct_type = ip.loadStructType(ty.toIntern());
|
||||
if (struct_type.layout == .@"packed") return false;
|
||||
if (struct_type.decl == .none) return false;
|
||||
return struct_type.flagsPtr(ip).is_tuple;
|
||||
return struct_type.flagsUnordered(ip).is_tuple;
|
||||
},
|
||||
.anon_struct_type => true,
|
||||
else => false,
|
||||
|
||||
@ -558,7 +558,7 @@ pub fn writeToPackedMemory(
|
||||
},
|
||||
.Union => {
|
||||
const union_obj = mod.typeToUnion(ty).?;
|
||||
switch (union_obj.getLayout(ip)) {
|
||||
switch (union_obj.flagsUnordered(ip).layout) {
|
||||
.auto, .@"extern" => unreachable, // Handled in non-packed writeToMemory
|
||||
.@"packed" => {
|
||||
if (val.unionTag(mod)) |union_tag| {
|
||||
|
||||
@ -2968,7 +2968,7 @@ pub fn ensureFuncBodyAnalysisQueued(mod: *Module, func_index: InternPool.Index)
|
||||
const is_outdated = mod.outdated.contains(func_as_depender) or
|
||||
mod.potentially_outdated.contains(func_as_depender);
|
||||
|
||||
switch (func.analysis(ip).state) {
|
||||
switch (func.analysisUnordered(ip).state) {
|
||||
.none => {},
|
||||
.queued => return,
|
||||
// As above, we don't need to forward errors here.
|
||||
@ -2989,7 +2989,7 @@ pub fn ensureFuncBodyAnalysisQueued(mod: *Module, func_index: InternPool.Index)
|
||||
// since the last update
|
||||
try mod.comp.work_queue.writeItem(.{ .emit_h_decl = decl_index });
|
||||
}
|
||||
func.analysis(ip).state = .queued;
|
||||
func.setAnalysisState(ip, .queued);
|
||||
}
|
||||
|
||||
pub const SemaDeclResult = packed struct {
|
||||
|
||||
@ -641,8 +641,8 @@ pub fn ensureFuncBodyAnalyzed(pt: Zcu.PerThread, maybe_coerced_func_index: Inter
|
||||
|
||||
// We'll want to remember what the IES used to be before the update for
|
||||
// dependency invalidation purposes.
|
||||
const old_resolved_ies = if (func.analysis(ip).inferred_error_set)
|
||||
func.resolvedErrorSet(ip).*
|
||||
const old_resolved_ies = if (func.analysisUnordered(ip).inferred_error_set)
|
||||
func.resolvedErrorSetUnordered(ip)
|
||||
else
|
||||
.none;
|
||||
|
||||
@ -671,7 +671,7 @@ pub fn ensureFuncBodyAnalyzed(pt: Zcu.PerThread, maybe_coerced_func_index: Inter
|
||||
zcu.deleteUnitReferences(func_as_depender);
|
||||
}
|
||||
|
||||
switch (func.analysis(ip).state) {
|
||||
switch (func.analysisUnordered(ip).state) {
|
||||
.success => if (!was_outdated) return,
|
||||
.sema_failure,
|
||||
.dependency_failure,
|
||||
@ -693,11 +693,11 @@ pub fn ensureFuncBodyAnalyzed(pt: Zcu.PerThread, maybe_coerced_func_index: Inter
|
||||
|
||||
var air = pt.analyzeFnBody(func_index, sema_arena) catch |err| switch (err) {
|
||||
error.AnalysisFail => {
|
||||
if (func.analysis(ip).state == .in_progress) {
|
||||
if (func.analysisUnordered(ip).state == .in_progress) {
|
||||
// If this decl caused the compile error, the analysis field would
|
||||
// be changed to indicate it was this Decl's fault. Because this
|
||||
// did not happen, we infer here that it was a dependency failure.
|
||||
func.analysis(ip).state = .dependency_failure;
|
||||
func.setAnalysisState(ip, .dependency_failure);
|
||||
}
|
||||
return error.AnalysisFail;
|
||||
},
|
||||
@ -707,8 +707,8 @@ pub fn ensureFuncBodyAnalyzed(pt: Zcu.PerThread, maybe_coerced_func_index: Inter
|
||||
|
||||
const invalidate_ies_deps = i: {
|
||||
if (!was_outdated) break :i false;
|
||||
if (!func.analysis(ip).inferred_error_set) break :i true;
|
||||
const new_resolved_ies = func.resolvedErrorSet(ip).*;
|
||||
if (!func.analysisUnordered(ip).inferred_error_set) break :i true;
|
||||
const new_resolved_ies = func.resolvedErrorSetUnordered(ip);
|
||||
break :i new_resolved_ies != old_resolved_ies;
|
||||
};
|
||||
if (invalidate_ies_deps) {
|
||||
@ -783,7 +783,7 @@ pub fn linkerUpdateFunc(pt: Zcu.PerThread, func_index: InternPool.Index, air: Ai
|
||||
.{@errorName(err)},
|
||||
),
|
||||
);
|
||||
func.analysis(ip).state = .codegen_failure;
|
||||
func.setAnalysisState(ip, .codegen_failure);
|
||||
return;
|
||||
},
|
||||
};
|
||||
@ -797,12 +797,12 @@ pub fn linkerUpdateFunc(pt: Zcu.PerThread, func_index: InternPool.Index, air: Ai
|
||||
// Correcting this failure will involve changing a type this function
|
||||
// depends on, hence triggering re-analysis of this function, so this
|
||||
// interacts correctly with incremental compilation.
|
||||
func.analysis(ip).state = .codegen_failure;
|
||||
func.setAnalysisState(ip, .codegen_failure);
|
||||
} else if (comp.bin_file) |lf| {
|
||||
lf.updateFunc(pt, func_index, air, liveness) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.AnalysisFail => {
|
||||
func.analysis(ip).state = .codegen_failure;
|
||||
func.setAnalysisState(ip, .codegen_failure);
|
||||
},
|
||||
else => {
|
||||
try zcu.failed_analysis.ensureUnusedCapacity(gpa, 1);
|
||||
@ -812,7 +812,7 @@ pub fn linkerUpdateFunc(pt: Zcu.PerThread, func_index: InternPool.Index, air: Ai
|
||||
"unable to codegen: {s}",
|
||||
.{@errorName(err)},
|
||||
));
|
||||
func.analysis(ip).state = .codegen_failure;
|
||||
func.setAnalysisState(ip, .codegen_failure);
|
||||
try zcu.retryable_failures.append(zcu.gpa, InternPool.AnalUnit.wrap(.{ .func = func_index }));
|
||||
},
|
||||
};
|
||||
@ -1080,7 +1080,7 @@ fn semaDecl(pt: Zcu.PerThread, decl_index: Zcu.Decl.Index) !Zcu.SemaDeclResult {
|
||||
const old_linksection = decl.@"linksection";
|
||||
const old_addrspace = decl.@"addrspace";
|
||||
const old_is_inline = if (decl.getOwnedFunction(zcu)) |prev_func|
|
||||
prev_func.analysis(ip).state == .inline_only
|
||||
prev_func.analysisUnordered(ip).state == .inline_only
|
||||
else
|
||||
false;
|
||||
|
||||
@ -2037,7 +2037,7 @@ pub fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index, arena: All
|
||||
.fn_ret_ty = Type.fromInterned(fn_ty_info.return_type),
|
||||
.fn_ret_ty_ies = null,
|
||||
.owner_func_index = func_index,
|
||||
.branch_quota = @max(func.branchQuota(ip).*, Sema.default_branch_quota),
|
||||
.branch_quota = @max(func.branchQuotaUnordered(ip), Sema.default_branch_quota),
|
||||
.comptime_err_ret_trace = &comptime_err_ret_trace,
|
||||
};
|
||||
defer sema.deinit();
|
||||
@ -2047,14 +2047,14 @@ pub fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index, arena: All
|
||||
try sema.declareDependency(.{ .src_hash = decl.zir_decl_index.unwrap().? });
|
||||
try sema.declareDependency(.{ .decl_val = decl_index });
|
||||
|
||||
if (func.analysis(ip).inferred_error_set) {
|
||||
if (func.analysisUnordered(ip).inferred_error_set) {
|
||||
const ies = try arena.create(Sema.InferredErrorSet);
|
||||
ies.* = .{ .func = func_index };
|
||||
sema.fn_ret_ty_ies = ies;
|
||||
}
|
||||
|
||||
// reset in case calls to errorable functions are removed.
|
||||
func.analysis(ip).calls_or_awaits_errorable_fn = false;
|
||||
func.setCallsOrAwaitsErrorableFn(ip, false);
|
||||
|
||||
// First few indexes of extra are reserved and set at the end.
|
||||
const reserved_count = @typeInfo(Air.ExtraIndex).Enum.fields.len;
|
||||
@ -2080,7 +2080,7 @@ pub fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index, arena: All
|
||||
};
|
||||
defer inner_block.instructions.deinit(gpa);
|
||||
|
||||
const fn_info = sema.code.getFnInfo(func.zirBodyInst(ip).resolve(ip));
|
||||
const fn_info = sema.code.getFnInfo(func.zirBodyInstUnordered(ip).resolve(ip));
|
||||
|
||||
// Here we are performing "runtime semantic analysis" for a function body, which means
|
||||
// we must map the parameter ZIR instructions to `arg` AIR instructions.
|
||||
@ -2149,7 +2149,7 @@ pub fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index, arena: All
|
||||
});
|
||||
}
|
||||
|
||||
func.analysis(ip).state = .in_progress;
|
||||
func.setAnalysisState(ip, .in_progress);
|
||||
|
||||
const last_arg_index = inner_block.instructions.items.len;
|
||||
|
||||
@ -2176,7 +2176,7 @@ pub fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index, arena: All
|
||||
}
|
||||
|
||||
// If we don't get an error return trace from a caller, create our own.
|
||||
if (func.analysis(ip).calls_or_awaits_errorable_fn and
|
||||
if (func.analysisUnordered(ip).calls_or_awaits_errorable_fn and
|
||||
mod.comp.config.any_error_tracing and
|
||||
!sema.fn_ret_ty.isError(mod))
|
||||
{
|
||||
@ -2218,10 +2218,10 @@ pub fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index, arena: All
|
||||
else => |e| return e,
|
||||
};
|
||||
assert(ies.resolved != .none);
|
||||
ip.funcIesResolved(func_index).* = ies.resolved;
|
||||
ip.funcSetIesResolved(func_index, ies.resolved);
|
||||
}
|
||||
|
||||
func.analysis(ip).state = .success;
|
||||
func.setAnalysisState(ip, .success);
|
||||
|
||||
// Finally we must resolve the return type and parameter types so that backends
|
||||
// have full access to type information.
|
||||
@ -2415,6 +2415,7 @@ fn processExportsInner(
|
||||
) error{OutOfMemory}!void {
|
||||
const zcu = pt.zcu;
|
||||
const gpa = zcu.gpa;
|
||||
const ip = &zcu.intern_pool;
|
||||
|
||||
for (export_indices) |export_idx| {
|
||||
const new_export = &zcu.all_exports.items[export_idx];
|
||||
@ -2423,7 +2424,7 @@ fn processExportsInner(
|
||||
new_export.status = .failed_retryable;
|
||||
try zcu.failed_exports.ensureUnusedCapacity(gpa, 1);
|
||||
const msg = try Zcu.ErrorMsg.create(gpa, new_export.src, "exported symbol collision: {}", .{
|
||||
new_export.opts.name.fmt(&zcu.intern_pool),
|
||||
new_export.opts.name.fmt(ip),
|
||||
});
|
||||
errdefer msg.destroy(gpa);
|
||||
const other_export = zcu.all_exports.items[gop.value_ptr.*];
|
||||
@ -2443,8 +2444,7 @@ fn processExportsInner(
|
||||
if (!decl.owns_tv) break :failed false;
|
||||
if (decl.typeOf(zcu).zigTypeTag(zcu) != .Fn) break :failed false;
|
||||
// Check if owned function failed
|
||||
const a = zcu.funcInfo(decl.val.toIntern()).analysis(&zcu.intern_pool);
|
||||
break :failed a.state != .success;
|
||||
break :failed zcu.funcInfo(decl.val.toIntern()).analysisUnordered(ip).state != .success;
|
||||
}) {
|
||||
// This `Decl` is failed, so was never sent to codegen.
|
||||
// TODO: we should probably tell the backend to delete any old exports of this `Decl`?
|
||||
@ -3072,7 +3072,7 @@ pub fn getUnionLayout(pt: Zcu.PerThread, loaded_union: InternPool.LoadedUnionTyp
|
||||
most_aligned_field_size = field_size;
|
||||
}
|
||||
}
|
||||
const have_tag = loaded_union.flagsPtr(ip).runtime_tag.hasTag();
|
||||
const have_tag = loaded_union.flagsUnordered(ip).runtime_tag.hasTag();
|
||||
if (!have_tag or !Type.fromInterned(loaded_union.enum_tag_ty).hasRuntimeBits(pt)) {
|
||||
return .{
|
||||
.abi_size = payload_align.forward(payload_size),
|
||||
@ -3091,7 +3091,7 @@ pub fn getUnionLayout(pt: Zcu.PerThread, loaded_union: InternPool.LoadedUnionTyp
|
||||
const tag_size = Type.fromInterned(loaded_union.enum_tag_ty).abiSize(pt);
|
||||
const tag_align = Type.fromInterned(loaded_union.enum_tag_ty).abiAlignment(pt).max(.@"1");
|
||||
return .{
|
||||
.abi_size = loaded_union.size(ip).*,
|
||||
.abi_size = loaded_union.sizeUnordered(ip),
|
||||
.abi_align = tag_align.max(payload_align),
|
||||
.most_aligned_field = most_aligned_field,
|
||||
.most_aligned_field_size = most_aligned_field_size,
|
||||
@ -3100,7 +3100,7 @@ pub fn getUnionLayout(pt: Zcu.PerThread, loaded_union: InternPool.LoadedUnionTyp
|
||||
.payload_align = payload_align,
|
||||
.tag_align = tag_align,
|
||||
.tag_size = tag_size,
|
||||
.padding = loaded_union.padding(ip).*,
|
||||
.padding = loaded_union.paddingUnordered(ip),
|
||||
};
|
||||
}
|
||||
|
||||
@ -3142,7 +3142,7 @@ pub fn unionFieldNormalAlignmentAdvanced(
|
||||
strat: Type.ResolveStrat,
|
||||
) Zcu.SemaError!InternPool.Alignment {
|
||||
const ip = &pt.zcu.intern_pool;
|
||||
assert(loaded_union.flagsPtr(ip).layout != .@"packed");
|
||||
assert(loaded_union.flagsUnordered(ip).layout != .@"packed");
|
||||
const field_align = loaded_union.fieldAlign(ip, field_index);
|
||||
if (field_align != .none) return field_align;
|
||||
const field_ty = Type.fromInterned(loaded_union.field_types.get(ip)[field_index]);
|
||||
|
||||
@ -56,7 +56,7 @@ pub fn classifyType(ty: Type, pt: Zcu.PerThread, ctx: Context) Class {
|
||||
.Union => {
|
||||
const bit_size = ty.bitSize(pt);
|
||||
const union_obj = pt.zcu.typeToUnion(ty).?;
|
||||
if (union_obj.getLayout(ip) == .@"packed") {
|
||||
if (union_obj.flagsUnordered(ip).layout == .@"packed") {
|
||||
if (bit_size > 64) return .memory;
|
||||
return .byval;
|
||||
}
|
||||
|
||||
@ -768,7 +768,7 @@ pub fn generate(
|
||||
@intFromEnum(FrameIndex.stack_frame),
|
||||
FrameAlloc.init(.{
|
||||
.size = 0,
|
||||
.alignment = func.analysis(ip).stack_alignment.max(.@"1"),
|
||||
.alignment = func.analysisUnordered(ip).stack_alignment.max(.@"1"),
|
||||
}),
|
||||
);
|
||||
function.frame_allocs.set(
|
||||
|
||||
@ -1011,7 +1011,7 @@ fn typeToValtype(ty: Type, pt: Zcu.PerThread) wasm.Valtype {
|
||||
},
|
||||
.Struct => {
|
||||
if (pt.zcu.typeToPackedStruct(ty)) |packed_struct| {
|
||||
return typeToValtype(Type.fromInterned(packed_struct.backingIntType(ip).*), pt);
|
||||
return typeToValtype(Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)), pt);
|
||||
} else {
|
||||
return wasm.Valtype.i32;
|
||||
}
|
||||
@ -1746,7 +1746,7 @@ fn isByRef(ty: Type, pt: Zcu.PerThread) bool {
|
||||
=> return ty.hasRuntimeBitsIgnoreComptime(pt),
|
||||
.Union => {
|
||||
if (mod.typeToUnion(ty)) |union_obj| {
|
||||
if (union_obj.getLayout(ip) == .@"packed") {
|
||||
if (union_obj.flagsUnordered(ip).layout == .@"packed") {
|
||||
return ty.abiSize(pt) > 8;
|
||||
}
|
||||
}
|
||||
@ -1754,7 +1754,7 @@ fn isByRef(ty: Type, pt: Zcu.PerThread) bool {
|
||||
},
|
||||
.Struct => {
|
||||
if (mod.typeToPackedStruct(ty)) |packed_struct| {
|
||||
return isByRef(Type.fromInterned(packed_struct.backingIntType(ip).*), pt);
|
||||
return isByRef(Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)), pt);
|
||||
}
|
||||
return ty.hasRuntimeBitsIgnoreComptime(pt);
|
||||
},
|
||||
@ -3377,7 +3377,7 @@ fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue {
|
||||
assert(struct_type.layout == .@"packed");
|
||||
var buf: [8]u8 = .{0} ** 8; // zero the buffer so we do not read 0xaa as integer
|
||||
val.writeToPackedMemory(ty, pt, &buf, 0) catch unreachable;
|
||||
const backing_int_ty = Type.fromInterned(struct_type.backingIntType(ip).*);
|
||||
const backing_int_ty = Type.fromInterned(struct_type.backingIntTypeUnordered(ip));
|
||||
const int_val = try pt.intValue(
|
||||
backing_int_ty,
|
||||
mem.readInt(u64, &buf, .little),
|
||||
@ -3443,7 +3443,7 @@ fn emitUndefined(func: *CodeGen, ty: Type) InnerError!WValue {
|
||||
},
|
||||
.Struct => {
|
||||
const packed_struct = mod.typeToPackedStruct(ty).?;
|
||||
return func.emitUndefined(Type.fromInterned(packed_struct.backingIntType(ip).*));
|
||||
return func.emitUndefined(Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)));
|
||||
},
|
||||
else => return func.fail("Wasm TODO: emitUndefined for type: {}\n", .{ty.zigTypeTag(mod)}),
|
||||
}
|
||||
@ -3974,7 +3974,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
|
||||
.Struct => result: {
|
||||
const packed_struct = mod.typeToPackedStruct(struct_ty).?;
|
||||
const offset = pt.structPackedFieldBitOffset(packed_struct, field_index);
|
||||
const backing_ty = Type.fromInterned(packed_struct.backingIntType(ip).*);
|
||||
const backing_ty = Type.fromInterned(packed_struct.backingIntTypeUnordered(ip));
|
||||
const wasm_bits = toWasmBits(backing_ty.intInfo(mod).bits) orelse {
|
||||
return func.fail("TODO: airStructFieldVal for packed structs larger than 128 bits", .{});
|
||||
};
|
||||
@ -5377,7 +5377,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
|
||||
}
|
||||
const packed_struct = mod.typeToPackedStruct(result_ty).?;
|
||||
const field_types = packed_struct.field_types;
|
||||
const backing_type = Type.fromInterned(packed_struct.backingIntType(ip).*);
|
||||
const backing_type = Type.fromInterned(packed_struct.backingIntTypeUnordered(ip));
|
||||
|
||||
// ensure the result is zero'd
|
||||
const result = try func.allocLocal(backing_type);
|
||||
|
||||
@ -71,7 +71,7 @@ pub fn classifyType(ty: Type, pt: Zcu.PerThread) [2]Class {
|
||||
},
|
||||
.Union => {
|
||||
const union_obj = pt.zcu.typeToUnion(ty).?;
|
||||
if (union_obj.getLayout(ip) == .@"packed") {
|
||||
if (union_obj.flagsUnordered(ip).layout == .@"packed") {
|
||||
if (ty.bitSize(pt) <= 64) return direct;
|
||||
return .{ .direct, .direct };
|
||||
}
|
||||
@ -107,7 +107,7 @@ pub fn scalarType(ty: Type, pt: Zcu.PerThread) Type {
|
||||
switch (ty.zigTypeTag(mod)) {
|
||||
.Struct => {
|
||||
if (mod.typeToPackedStruct(ty)) |packed_struct| {
|
||||
return scalarType(Type.fromInterned(packed_struct.backingIntType(ip).*), pt);
|
||||
return scalarType(Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)), pt);
|
||||
} else {
|
||||
assert(ty.structFieldCount(mod) == 1);
|
||||
return scalarType(ty.structFieldType(0, mod), pt);
|
||||
@ -115,7 +115,7 @@ pub fn scalarType(ty: Type, pt: Zcu.PerThread) Type {
|
||||
},
|
||||
.Union => {
|
||||
const union_obj = mod.typeToUnion(ty).?;
|
||||
if (union_obj.getLayout(ip) != .@"packed") {
|
||||
if (union_obj.flagsUnordered(ip).layout != .@"packed") {
|
||||
const layout = pt.getUnionLayout(union_obj);
|
||||
if (layout.payload_size == 0 and layout.tag_size != 0) {
|
||||
return scalarType(ty.unionTagTypeSafety(mod).?, pt);
|
||||
|
||||
@ -856,7 +856,7 @@ pub fn generate(
|
||||
@intFromEnum(FrameIndex.stack_frame),
|
||||
FrameAlloc.init(.{
|
||||
.size = 0,
|
||||
.alignment = func.analysis(ip).stack_alignment.max(.@"1"),
|
||||
.alignment = func.analysisUnordered(ip).stack_alignment.max(.@"1"),
|
||||
}),
|
||||
);
|
||||
function.frame_allocs.set(
|
||||
|
||||
@ -349,7 +349,7 @@ fn classifySystemVStruct(
|
||||
.@"packed" => {},
|
||||
}
|
||||
} else if (pt.zcu.typeToUnion(field_ty)) |field_loaded_union| {
|
||||
switch (field_loaded_union.getLayout(ip)) {
|
||||
switch (field_loaded_union.flagsUnordered(ip).layout) {
|
||||
.auto, .@"extern" => {
|
||||
byte_offset = classifySystemVUnion(result, byte_offset, field_loaded_union, pt, target);
|
||||
continue;
|
||||
@ -362,11 +362,11 @@ fn classifySystemVStruct(
|
||||
result_class.* = result_class.combineSystemV(field_class);
|
||||
byte_offset += field_ty.abiSize(pt);
|
||||
}
|
||||
const final_byte_offset = starting_byte_offset + loaded_struct.size(ip).*;
|
||||
const final_byte_offset = starting_byte_offset + loaded_struct.sizeUnordered(ip);
|
||||
std.debug.assert(final_byte_offset == std.mem.alignForward(
|
||||
u64,
|
||||
byte_offset,
|
||||
loaded_struct.flagsPtr(ip).alignment.toByteUnits().?,
|
||||
loaded_struct.flagsUnordered(ip).alignment.toByteUnits().?,
|
||||
));
|
||||
return final_byte_offset;
|
||||
}
|
||||
@ -390,7 +390,7 @@ fn classifySystemVUnion(
|
||||
.@"packed" => {},
|
||||
}
|
||||
} else if (pt.zcu.typeToUnion(field_ty)) |field_loaded_union| {
|
||||
switch (field_loaded_union.getLayout(ip)) {
|
||||
switch (field_loaded_union.flagsUnordered(ip).layout) {
|
||||
.auto, .@"extern" => {
|
||||
_ = classifySystemVUnion(result, starting_byte_offset, field_loaded_union, pt, target);
|
||||
continue;
|
||||
@ -402,7 +402,7 @@ fn classifySystemVUnion(
|
||||
for (result[@intCast(starting_byte_offset / 8)..][0..field_classes.len], field_classes) |*result_class, field_class|
|
||||
result_class.* = result_class.combineSystemV(field_class);
|
||||
}
|
||||
return starting_byte_offset + loaded_union.size(ip).*;
|
||||
return starting_byte_offset + loaded_union.sizeUnordered(ip);
|
||||
}
|
||||
|
||||
pub const SysV = struct {
|
||||
|
||||
@ -548,8 +548,8 @@ pub fn generateSymbol(
|
||||
}
|
||||
}
|
||||
|
||||
const size = struct_type.size(ip).*;
|
||||
const alignment = struct_type.flagsPtr(ip).alignment.toByteUnits().?;
|
||||
const size = struct_type.sizeUnordered(ip);
|
||||
const alignment = struct_type.flagsUnordered(ip).alignment.toByteUnits().?;
|
||||
|
||||
const padding = math.cast(
|
||||
usize,
|
||||
|
||||
@ -1366,7 +1366,7 @@ pub const DeclGen = struct {
|
||||
const loaded_union = ip.loadUnionType(ty.toIntern());
|
||||
if (un.tag == .none) {
|
||||
const backing_ty = try ty.unionBackingType(pt);
|
||||
switch (loaded_union.getLayout(ip)) {
|
||||
switch (loaded_union.flagsUnordered(ip).layout) {
|
||||
.@"packed" => {
|
||||
if (!location.isInitializer()) {
|
||||
try writer.writeByte('(');
|
||||
@ -1401,7 +1401,7 @@ pub const DeclGen = struct {
|
||||
const field_index = zcu.unionTagFieldIndex(loaded_union, Value.fromInterned(un.tag)).?;
|
||||
const field_ty = Type.fromInterned(loaded_union.field_types.get(ip)[field_index]);
|
||||
const field_name = loaded_union.loadTagType(ip).names.get(ip)[field_index];
|
||||
if (loaded_union.getLayout(ip) == .@"packed") {
|
||||
if (loaded_union.flagsUnordered(ip).layout == .@"packed") {
|
||||
if (field_ty.hasRuntimeBits(pt)) {
|
||||
if (field_ty.isPtrAtRuntime(zcu)) {
|
||||
try writer.writeByte('(');
|
||||
@ -1629,7 +1629,7 @@ pub const DeclGen = struct {
|
||||
},
|
||||
.union_type => {
|
||||
const loaded_union = ip.loadUnionType(ty.toIntern());
|
||||
switch (loaded_union.getLayout(ip)) {
|
||||
switch (loaded_union.flagsUnordered(ip).layout) {
|
||||
.auto, .@"extern" => {
|
||||
if (!location.isInitializer()) {
|
||||
try writer.writeByte('(');
|
||||
@ -1792,7 +1792,7 @@ pub const DeclGen = struct {
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
if (fn_val.getFunction(zcu)) |func| if (func.analysis(ip).is_cold)
|
||||
if (fn_val.getFunction(zcu)) |func| if (func.analysisUnordered(ip).is_cold)
|
||||
try w.writeAll("zig_cold ");
|
||||
if (fn_info.return_type == .noreturn_type) try w.writeAll("zig_noreturn ");
|
||||
|
||||
@ -5527,7 +5527,7 @@ fn fieldLocation(
|
||||
.{ .field = field_index } },
|
||||
.union_type => {
|
||||
const loaded_union = ip.loadUnionType(container_ty.toIntern());
|
||||
switch (loaded_union.getLayout(ip)) {
|
||||
switch (loaded_union.flagsUnordered(ip).layout) {
|
||||
.auto, .@"extern" => {
|
||||
const field_ty = Type.fromInterned(loaded_union.field_types.get(ip)[field_index]);
|
||||
if (!field_ty.hasRuntimeBitsIgnoreComptime(pt))
|
||||
@ -5763,7 +5763,7 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue {
|
||||
.{ .field = extra.field_index },
|
||||
.union_type => field_name: {
|
||||
const loaded_union = ip.loadUnionType(struct_ty.toIntern());
|
||||
switch (loaded_union.getLayout(ip)) {
|
||||
switch (loaded_union.flagsUnordered(ip).layout) {
|
||||
.auto, .@"extern" => {
|
||||
const name = loaded_union.loadTagType(ip).names.get(ip)[extra.field_index];
|
||||
break :field_name if (loaded_union.hasTag(ip))
|
||||
@ -7267,7 +7267,7 @@ fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue {
|
||||
|
||||
const writer = f.object.writer();
|
||||
const local = try f.allocLocal(inst, union_ty);
|
||||
if (loaded_union.getLayout(ip) == .@"packed") return f.moveCValue(inst, union_ty, payload);
|
||||
if (loaded_union.flagsUnordered(ip).layout == .@"packed") return f.moveCValue(inst, union_ty, payload);
|
||||
|
||||
const field: CValue = if (union_ty.unionTagTypeSafety(zcu)) |tag_ty| field: {
|
||||
const layout = union_ty.unionGetLayout(pt);
|
||||
|
||||
@ -1744,7 +1744,7 @@ pub const Pool = struct {
|
||||
.@"packed" => return pool.fromType(
|
||||
allocator,
|
||||
scratch,
|
||||
Type.fromInterned(loaded_struct.backingIntType(ip).*),
|
||||
Type.fromInterned(loaded_struct.backingIntTypeUnordered(ip)),
|
||||
pt,
|
||||
mod,
|
||||
kind,
|
||||
@ -1817,7 +1817,7 @@ pub const Pool = struct {
|
||||
},
|
||||
.union_type => {
|
||||
const loaded_union = ip.loadUnionType(ip_index);
|
||||
switch (loaded_union.getLayout(ip)) {
|
||||
switch (loaded_union.flagsUnordered(ip).layout) {
|
||||
.auto, .@"extern" => {
|
||||
const has_tag = loaded_union.hasTag(ip);
|
||||
const fwd_decl = try pool.getFwdDecl(allocator, .{
|
||||
|
||||
@ -1086,7 +1086,7 @@ pub const Object = struct {
|
||||
// If there is no such function in the module, it means the source code does not need it.
|
||||
const name = o.builder.strtabStringIfExists(lt_errors_fn_name) orelse return;
|
||||
const llvm_fn = o.builder.getGlobal(name) orelse return;
|
||||
const errors_len = o.pt.zcu.intern_pool.global_error_set.mutate.list.len;
|
||||
const errors_len = o.pt.zcu.intern_pool.global_error_set.getNamesFromMainThread().len;
|
||||
|
||||
var wip = try Builder.WipFunction.init(&o.builder, .{
|
||||
.function = llvm_fn.ptrConst(&o.builder).kind.function,
|
||||
@ -1385,13 +1385,14 @@ pub const Object = struct {
|
||||
var attributes = try function_index.ptrConst(&o.builder).attributes.toWip(&o.builder);
|
||||
defer attributes.deinit(&o.builder);
|
||||
|
||||
if (func.analysis(ip).is_noinline) {
|
||||
const func_analysis = func.analysisUnordered(ip);
|
||||
if (func_analysis.is_noinline) {
|
||||
try attributes.addFnAttr(.@"noinline", &o.builder);
|
||||
} else {
|
||||
_ = try attributes.removeFnAttr(.@"noinline");
|
||||
}
|
||||
|
||||
const stack_alignment = func.analysis(ip).stack_alignment;
|
||||
const stack_alignment = func.analysisUnordered(ip).stack_alignment;
|
||||
if (stack_alignment != .none) {
|
||||
try attributes.addFnAttr(.{ .alignstack = stack_alignment.toLlvm() }, &o.builder);
|
||||
try attributes.addFnAttr(.@"noinline", &o.builder);
|
||||
@ -1399,7 +1400,7 @@ pub const Object = struct {
|
||||
_ = try attributes.removeFnAttr(.alignstack);
|
||||
}
|
||||
|
||||
if (func.analysis(ip).is_cold) {
|
||||
if (func_analysis.is_cold) {
|
||||
try attributes.addFnAttr(.cold, &o.builder);
|
||||
} else {
|
||||
_ = try attributes.removeFnAttr(.cold);
|
||||
@ -2403,7 +2404,7 @@ pub const Object = struct {
|
||||
defer gpa.free(name);
|
||||
|
||||
if (zcu.typeToPackedStruct(ty)) |struct_type| {
|
||||
const backing_int_ty = struct_type.backingIntType(ip).*;
|
||||
const backing_int_ty = struct_type.backingIntTypeUnordered(ip);
|
||||
if (backing_int_ty != .none) {
|
||||
const info = Type.fromInterned(backing_int_ty).intInfo(zcu);
|
||||
const builder_name = try o.builder.metadataString(name);
|
||||
@ -2615,7 +2616,7 @@ pub const Object = struct {
|
||||
if (!Type.fromInterned(field_ty).hasRuntimeBitsIgnoreComptime(pt)) continue;
|
||||
|
||||
const field_size = Type.fromInterned(field_ty).abiSize(pt);
|
||||
const field_align: InternPool.Alignment = switch (union_type.flagsPtr(ip).layout) {
|
||||
const field_align: InternPool.Alignment = switch (union_type.flagsUnordered(ip).layout) {
|
||||
.@"packed" => .none,
|
||||
.auto, .@"extern" => pt.unionFieldNormalAlignment(union_type, @intCast(field_index)),
|
||||
};
|
||||
@ -3303,7 +3304,7 @@ pub const Object = struct {
|
||||
const struct_type = ip.loadStructType(t.toIntern());
|
||||
|
||||
if (struct_type.layout == .@"packed") {
|
||||
const int_ty = try o.lowerType(Type.fromInterned(struct_type.backingIntType(ip).*));
|
||||
const int_ty = try o.lowerType(Type.fromInterned(struct_type.backingIntTypeUnordered(ip)));
|
||||
try o.type_map.put(o.gpa, t.toIntern(), int_ty);
|
||||
return int_ty;
|
||||
}
|
||||
@ -3346,7 +3347,7 @@ pub const Object = struct {
|
||||
// This is a zero-bit field. If there are runtime bits after this field,
|
||||
// map to the next LLVM field (which we know exists): otherwise, don't
|
||||
// map the field, indicating it's at the end of the struct.
|
||||
if (offset != struct_type.size(ip).*) {
|
||||
if (offset != struct_type.sizeUnordered(ip)) {
|
||||
try o.struct_field_map.put(o.gpa, .{
|
||||
.struct_ty = t.toIntern(),
|
||||
.field_index = field_index,
|
||||
@ -3450,7 +3451,7 @@ pub const Object = struct {
|
||||
const union_obj = ip.loadUnionType(t.toIntern());
|
||||
const layout = pt.getUnionLayout(union_obj);
|
||||
|
||||
if (union_obj.flagsPtr(ip).layout == .@"packed") {
|
||||
if (union_obj.flagsUnordered(ip).layout == .@"packed") {
|
||||
const int_ty = try o.builder.intType(@intCast(t.bitSize(pt)));
|
||||
try o.type_map.put(o.gpa, t.toIntern(), int_ty);
|
||||
return int_ty;
|
||||
@ -3697,7 +3698,7 @@ pub const Object = struct {
|
||||
if (layout.payload_size == 0) return o.lowerValue(un.tag);
|
||||
|
||||
const union_obj = mod.typeToUnion(ty).?;
|
||||
const container_layout = union_obj.getLayout(ip);
|
||||
const container_layout = union_obj.flagsUnordered(ip).layout;
|
||||
|
||||
assert(container_layout == .@"packed");
|
||||
|
||||
@ -4205,7 +4206,7 @@ pub const Object = struct {
|
||||
if (layout.payload_size == 0) return o.lowerValue(un.tag);
|
||||
|
||||
const union_obj = mod.typeToUnion(ty).?;
|
||||
const container_layout = union_obj.getLayout(ip);
|
||||
const container_layout = union_obj.flagsUnordered(ip).layout;
|
||||
|
||||
var need_unnamed = false;
|
||||
const payload = if (un.tag != .none) p: {
|
||||
@ -10045,7 +10046,7 @@ pub const FuncGen = struct {
|
||||
},
|
||||
.Struct => {
|
||||
if (mod.typeToPackedStruct(result_ty)) |struct_type| {
|
||||
const backing_int_ty = struct_type.backingIntType(ip).*;
|
||||
const backing_int_ty = struct_type.backingIntTypeUnordered(ip);
|
||||
assert(backing_int_ty != .none);
|
||||
const big_bits = Type.fromInterned(backing_int_ty).bitSize(pt);
|
||||
const int_ty = try o.builder.intType(@intCast(big_bits));
|
||||
@ -10155,7 +10156,7 @@ pub const FuncGen = struct {
|
||||
const layout = union_ty.unionGetLayout(pt);
|
||||
const union_obj = mod.typeToUnion(union_ty).?;
|
||||
|
||||
if (union_obj.getLayout(ip) == .@"packed") {
|
||||
if (union_obj.flagsUnordered(ip).layout == .@"packed") {
|
||||
const big_bits = union_ty.bitSize(pt);
|
||||
const int_llvm_ty = try o.builder.intType(@intCast(big_bits));
|
||||
const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[extra.field_index]);
|
||||
@ -11281,7 +11282,7 @@ fn lowerSystemVFnRetTy(o: *Object, fn_info: InternPool.Key.FuncType) Allocator.E
|
||||
.struct_type => {
|
||||
const struct_type = ip.loadStructType(return_type.toIntern());
|
||||
assert(struct_type.haveLayout(ip));
|
||||
const size: u64 = struct_type.size(ip).*;
|
||||
const size: u64 = struct_type.sizeUnordered(ip);
|
||||
assert((std.math.divCeil(u64, size, 8) catch unreachable) == types_index);
|
||||
if (size % 8 > 0) {
|
||||
types_buffer[types_index - 1] = try o.builder.intType(@intCast(size % 8 * 8));
|
||||
@ -11587,7 +11588,7 @@ const ParamTypeIterator = struct {
|
||||
.struct_type => {
|
||||
const struct_type = ip.loadStructType(ty.toIntern());
|
||||
assert(struct_type.haveLayout(ip));
|
||||
const size: u64 = struct_type.size(ip).*;
|
||||
const size: u64 = struct_type.sizeUnordered(ip);
|
||||
assert((std.math.divCeil(u64, size, 8) catch unreachable) == types_index);
|
||||
if (size % 8 > 0) {
|
||||
types_buffer[types_index - 1] =
|
||||
|
||||
@ -1463,7 +1463,7 @@ const DeclGen = struct {
|
||||
const ip = &mod.intern_pool;
|
||||
const union_obj = mod.typeToUnion(ty).?;
|
||||
|
||||
if (union_obj.getLayout(ip) == .@"packed") {
|
||||
if (union_obj.flagsUnordered(ip).layout == .@"packed") {
|
||||
return self.todo("packed union types", .{});
|
||||
}
|
||||
|
||||
@ -1735,7 +1735,7 @@ const DeclGen = struct {
|
||||
};
|
||||
|
||||
if (struct_type.layout == .@"packed") {
|
||||
return try self.resolveType(Type.fromInterned(struct_type.backingIntType(ip).*), .direct);
|
||||
return try self.resolveType(Type.fromInterned(struct_type.backingIntTypeUnordered(ip)), .direct);
|
||||
}
|
||||
|
||||
var member_types = std.ArrayList(IdRef).init(self.gpa);
|
||||
@ -5081,7 +5081,7 @@ const DeclGen = struct {
|
||||
const union_ty = mod.typeToUnion(ty).?;
|
||||
const tag_ty = Type.fromInterned(union_ty.enum_tag_ty);
|
||||
|
||||
if (union_ty.getLayout(ip) == .@"packed") {
|
||||
if (union_ty.flagsUnordered(ip).layout == .@"packed") {
|
||||
unreachable; // TODO
|
||||
}
|
||||
|
||||
|
||||
@ -1156,7 +1156,7 @@ pub fn updateFunc(self: *Coff, pt: Zcu.PerThread, func_index: InternPool.Index,
|
||||
const code = switch (res) {
|
||||
.ok => code_buffer.items,
|
||||
.fail => |em| {
|
||||
func.analysis(&mod.intern_pool).state = .codegen_failure;
|
||||
func.setAnalysisState(&mod.intern_pool, .codegen_failure);
|
||||
try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
|
||||
return;
|
||||
},
|
||||
|
||||
@ -1093,7 +1093,7 @@ pub fn updateFunc(
|
||||
const code = switch (res) {
|
||||
.ok => code_buffer.items,
|
||||
.fail => |em| {
|
||||
func.analysis(&mod.intern_pool).state = .codegen_failure;
|
||||
func.setAnalysisState(&mod.intern_pool, .codegen_failure);
|
||||
try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
|
||||
return;
|
||||
},
|
||||
|
||||
@ -699,7 +699,7 @@ pub fn updateFunc(
|
||||
const code = switch (res) {
|
||||
.ok => code_buffer.items,
|
||||
.fail => |em| {
|
||||
func.analysis(&mod.intern_pool).state = .codegen_failure;
|
||||
func.setAnalysisState(&mod.intern_pool, .codegen_failure);
|
||||
try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
|
||||
return;
|
||||
},
|
||||
|
||||
@ -449,7 +449,7 @@ pub fn updateFunc(self: *Plan9, pt: Zcu.PerThread, func_index: InternPool.Index,
|
||||
const code = switch (res) {
|
||||
.ok => try code_buffer.toOwnedSlice(),
|
||||
.fail => |em| {
|
||||
func.analysis(&mod.intern_pool).state = .codegen_failure;
|
||||
func.setAnalysisState(&mod.intern_pool, .codegen_failure);
|
||||
try mod.failed_analysis.put(mod.gpa, AnalUnit.wrap(.{ .decl = decl_index }), em);
|
||||
return;
|
||||
},
|
||||
|
||||
@ -1051,7 +1051,7 @@ fn setupErrorsLen(zig_object: *ZigObject, wasm_file: *Wasm) !void {
|
||||
const gpa = wasm_file.base.comp.gpa;
|
||||
const sym_index = zig_object.findGlobalSymbol("__zig_errors_len") orelse return;
|
||||
|
||||
const errors_len = 1 + wasm_file.base.comp.module.?.intern_pool.global_error_set.mutate.list.len;
|
||||
const errors_len = 1 + wasm_file.base.comp.module.?.intern_pool.global_error_set.getNamesFromMainThread().len;
|
||||
// overwrite existing atom if it already exists (maybe the error set has increased)
|
||||
// if not, allcoate a new atom.
|
||||
const atom_index = if (wasm_file.symbol_atom.get(.{ .file = zig_object.index, .index = sym_index })) |index| blk: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user