authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-05-29 01:27:37+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-06-12 13:55:40+01:00
log66d15d9d0974e1b493b717cf02deb435ebd13858
treee5110141a14ba06fd626b8fc98ef59808724579a
parent2fb6f5c1adcd764372ad28ed4014fdaf558da778
signaturelock-open Commit is signed but in an unrecognized format.

link: make checking for failed types the responsibility of Compilation


3 files changed, 21 insertions(+), 21 deletions(-)

src/Compilation.zig+21
......@@ -4553,12 +4553,33 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job) JobError!void {
45534553 }
45544554 }
45554555 assert(nav.status == .fully_resolved);
4556 if (!Air.valFullyResolved(zcu.navValue(nav_index), zcu)) {
4557 // Type resolution failed in a way which affects this `Nav`. This is a transitive
4558 // failure, but it doesn't need recording, because this `Nav` semantically depends
4559 // on the failed type, so when it is changed the `Nav` will be updated.
4560 return;
4561 }
45564562 comp.dispatchLinkTask(tid, .{ .link_nav = nav_index });
45574563 },
45584564 .link_func => |func| {
4565 const zcu = comp.zcu.?;
4566 if (!func.air.typesFullyResolved(zcu)) {
4567 // Type resolution failed in a way which affects this function. This is a transitive
4568 // failure, but it doesn't need recording, because this function semantically depends
4569 // on the failed type, so when it is changed the function is updated.
4570 return;
4571 }
45594572 comp.dispatchLinkTask(tid, .{ .link_func = func });
45604573 },
45614574 .link_type => |ty| {
4575 const zcu = comp.zcu.?;
4576 if (zcu.failed_types.fetchSwapRemove(ty)) |*entry| entry.value.deinit(zcu.gpa);
4577 if (!Air.typeFullyResolved(.fromInterned(ty), zcu)) {
4578 // Type resolution failed in a way which affects this type. This is a transitive
4579 // failure, but it doesn't need recording, because this type semantically depends
4580 // on the failed type, so when that is changed, this type will be updated.
4581 return;
4582 }
45624583 comp.dispatchLinkTask(tid, .{ .link_type = ty });
45634584 },
45644585 .update_line_number => |ti| {
src/Zcu/PerThread.zig-8
......@@ -1739,14 +1739,6 @@ pub fn linkerUpdateFunc(pt: Zcu.PerThread, func_index: InternPool.Index, air: *A
17391739 const codegen_prog_node = zcu.codegen_prog_node.start(nav.fqn.toSlice(ip), 0);
17401740 defer codegen_prog_node.end();
17411741
1742 if (!air.typesFullyResolved(zcu)) {
1743 // A type we depend on failed to resolve. This is a transitive failure.
1744 // Correcting this failure will involve changing a type this function
1745 // depends on, hence triggering re-analysis of this function, so this
1746 // interacts correctly with incremental compilation.
1747 return;
1748 }
1749
17501742 legalize: {
17511743 try air.legalize(pt, @import("../codegen.zig").legalizeFeatures(pt, nav_index) orelse break :legalize);
17521744 }
src/link.zig-13
......@@ -1424,12 +1424,6 @@ pub fn doTask(comp: *Compilation, tid: usize, task: Task) void {
14241424 const zcu = comp.zcu.?;
14251425 const pt: Zcu.PerThread = .activate(zcu, @enumFromInt(tid));
14261426 defer pt.deactivate();
1427 if (!Air.valFullyResolved(zcu.navValue(nav_index), zcu)) {
1428 // Type resolution failed in a way which affects this `Nav`. This is a transitive
1429 // failure, but it doesn't need recording, because this `Nav` semantically depends
1430 // on the failed type, so when it is changed the `Nav` will be updated.
1431 return;
1432 }
14331427 if (zcu.llvm_object) |llvm_object| {
14341428 llvm_object.updateNav(pt, nav_index) catch |err| switch (err) {
14351429 error.OutOfMemory => diags.setAllocFailure(),
......@@ -1473,13 +1467,6 @@ pub fn doTask(comp: *Compilation, tid: usize, task: Task) void {
14731467 const zcu = comp.zcu.?;
14741468 const pt: Zcu.PerThread = .activate(zcu, @enumFromInt(tid));
14751469 defer pt.deactivate();
1476 if (zcu.failed_types.fetchSwapRemove(ty)) |*entry| entry.value.deinit(zcu.gpa);
1477 if (!Air.typeFullyResolved(.fromInterned(ty), zcu)) {
1478 // Type resolution failed in a way which affects this type. This is a transitive
1479 // failure, but it doesn't need recording, because this type semantically depends
1480 // on the failed type, so when that is changed, this type will be updated.
1481 return;
1482 }
14831470 if (zcu.llvm_object == null) {
14841471 if (comp.bin_file) |lf| {
14851472 lf.updateContainerType(pt, ty) catch |err| switch (err) {