diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-02-09 15:50:46 +0000 |
|---|---|---|
| committer | Matthew Lugg <mlugg@mlugg.co.uk> | 2025-03-03 22:18:02 +0000 |
| commit | 501e84a96aa18fae7c345b0b54efa652cea85b38 (patch) | |
| tree | cf5464d10baaf7365140c894513c9a44431645f5 /src | |
| parent | edabcf61927f9699f9b869f304e9aed97f2c4a47 (diff) | |
| download | zig-501e84a96aa18fae7c345b0b54efa652cea85b38.tar.gz zig-501e84a96aa18fae7c345b0b54efa652cea85b38.zip | |
incremental: invalidate namespace dependencies when a name changes visibility
We could have more fine-grained dependencies here, but I think this is
fine for now.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Zcu/PerThread.zig | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig index f1f69d107a..699315835a 100644 --- a/src/Zcu/PerThread.zig +++ b/src/Zcu/PerThread.zig @@ -479,36 +479,39 @@ pub fn updateZirRefs(pt: Zcu.PerThread) Allocator.Error!void { }; if (!has_namespace) continue; - var old_names: std.AutoArrayHashMapUnmanaged(InternPool.NullTerminatedString, void) = .empty; + // Value is whether the declaration is `pub`. + var old_names: std.AutoArrayHashMapUnmanaged(InternPool.NullTerminatedString, bool) = .empty; defer old_names.deinit(zcu.gpa); { var it = old_zir.declIterator(old_inst); while (it.next()) |decl_inst| { - const name_zir = old_zir.getDeclaration(decl_inst).name; - if (name_zir == .empty) continue; + const old_decl = old_zir.getDeclaration(decl_inst); + if (old_decl.name == .empty) continue; const name_ip = try zcu.intern_pool.getOrPutString( zcu.gpa, pt.tid, - old_zir.nullTerminatedString(name_zir), + old_zir.nullTerminatedString(old_decl.name), .no_embedded_nulls, ); - try old_names.put(zcu.gpa, name_ip, {}); + try old_names.put(zcu.gpa, name_ip, old_decl.is_pub); } } var any_change = false; { var it = new_zir.declIterator(new_inst); while (it.next()) |decl_inst| { - const name_zir = new_zir.getDeclaration(decl_inst).name; - if (name_zir == .empty) continue; + const new_decl = new_zir.getDeclaration(decl_inst); + if (new_decl.name == .empty) continue; const name_ip = try zcu.intern_pool.getOrPutString( zcu.gpa, pt.tid, - new_zir.nullTerminatedString(name_zir), + new_zir.nullTerminatedString(new_decl.name), .no_embedded_nulls, ); - if (old_names.swapRemove(name_ip)) continue; - // Name added + if (old_names.fetchSwapRemove(name_ip)) |kv| { + if (kv.value == new_decl.is_pub) continue; + } + // Name added, or changed whether it's pub any_change = true; try zcu.markDependeeOutdated(.not_marked_po, .{ .namespace_name = .{ .namespace = tracked_inst_index, |
