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 {...@@ -4553,12 +4553,33 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job) JobError!void {
4553 }4553 }
4554 }4554 }
4555 assert(nav.status == .fully_resolved);4555 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 }
4556 comp.dispatchLinkTask(tid, .{ .link_nav = nav_index });4562 comp.dispatchLinkTask(tid, .{ .link_nav = nav_index });
4557 },4563 },
4558 .link_func => |func| {4564 .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 }
4559 comp.dispatchLinkTask(tid, .{ .link_func = func });4572 comp.dispatchLinkTask(tid, .{ .link_func = func });
4560 },4573 },
4561 .link_type => |ty| {4574 .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 }
4562 comp.dispatchLinkTask(tid, .{ .link_type = ty });4583 comp.dispatchLinkTask(tid, .{ .link_type = ty });
4563 },4584 },
4564 .update_line_number => |ti| {4585 .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...@@ -1739,14 +1739,6 @@ pub fn linkerUpdateFunc(pt: Zcu.PerThread, func_index: InternPool.Index, air: *A
1739 const codegen_prog_node = zcu.codegen_prog_node.start(nav.fqn.toSlice(ip), 0);1739 const codegen_prog_node = zcu.codegen_prog_node.start(nav.fqn.toSlice(ip), 0);
1740 defer codegen_prog_node.end();1740 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
1750 legalize: {1742 legalize: {
1751 try air.legalize(pt, @import("../codegen.zig").legalizeFeatures(pt, nav_index) orelse break :legalize);1743 try air.legalize(pt, @import("../codegen.zig").legalizeFeatures(pt, nav_index) orelse break :legalize);
1752 }1744 }
src/link.zig-13
...@@ -1424,12 +1424,6 @@ pub fn doTask(comp: *Compilation, tid: usize, task: Task) void {...@@ -1424,12 +1424,6 @@ pub fn doTask(comp: *Compilation, tid: usize, task: Task) void {
1424 const zcu = comp.zcu.?;1424 const zcu = comp.zcu.?;
1425 const pt: Zcu.PerThread = .activate(zcu, @enumFromInt(tid));1425 const pt: Zcu.PerThread = .activate(zcu, @enumFromInt(tid));
1426 defer pt.deactivate();1426 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 }
1433 if (zcu.llvm_object) |llvm_object| {1427 if (zcu.llvm_object) |llvm_object| {
1434 llvm_object.updateNav(pt, nav_index) catch |err| switch (err) {1428 llvm_object.updateNav(pt, nav_index) catch |err| switch (err) {
1435 error.OutOfMemory => diags.setAllocFailure(),1429 error.OutOfMemory => diags.setAllocFailure(),
...@@ -1473,13 +1467,6 @@ pub fn doTask(comp: *Compilation, tid: usize, task: Task) void {...@@ -1473,13 +1467,6 @@ pub fn doTask(comp: *Compilation, tid: usize, task: Task) void {
1473 const zcu = comp.zcu.?;1467 const zcu = comp.zcu.?;
1474 const pt: Zcu.PerThread = .activate(zcu, @enumFromInt(tid));1468 const pt: Zcu.PerThread = .activate(zcu, @enumFromInt(tid));
1475 defer pt.deactivate();1469 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 }
1483 if (zcu.llvm_object == null) {1470 if (zcu.llvm_object == null) {
1484 if (comp.bin_file) |lf| {1471 if (comp.bin_file) |lf| {
1485 lf.updateContainerType(pt, ty) catch |err| switch (err) {1472 lf.updateContainerType(pt, ty) catch |err| switch (err) {