aboutsummaryrefslogtreecommitdiff
path: root/src/InternPool.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2024-12-05 16:59:50 +0000
committermlugg <mlugg@mlugg.co.uk>2024-12-05 19:58:42 +0000
commit7f3211a101d8763ec5f0009b219f6819dba2cd35 (patch)
treee9bb31b31381f6fe07bf9d2253c4d7d5b56e882f /src/InternPool.zig
parent4d7818a76ad951f0a16c3831b31841430b1368f7 (diff)
downloadzig-7f3211a101d8763ec5f0009b219f6819dba2cd35.tar.gz
zig-7f3211a101d8763ec5f0009b219f6819dba2cd35.zip
compiler: incremental compilation fixes
The previous commit exposed some bugs in incremental compilation. This commit fixes those, and adds a little more logging for debugging incremental compilation. Also, allow `ast-check -t` to dump ZIR when there are non-fatal AstGen errors.
Diffstat (limited to 'src/InternPool.zig')
-rw-r--r--src/InternPool.zig20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig
index 63cdd7cec8..c6f9278109 100644
--- a/src/InternPool.zig
+++ b/src/InternPool.zig
@@ -8614,6 +8614,16 @@ pub fn getFuncDecl(
defer gop.deinit();
if (gop == .existing) {
extra.mutate.len = prev_extra_len;
+
+ const zir_body_inst_ptr = ip.funcDeclInfo(gop.existing).zirBodyInstPtr(ip);
+ if (zir_body_inst_ptr.* != key.zir_body_inst) {
+ // Since this function's `owner_nav` matches `key`, this *is* the function we're talking
+ // about. The only way it could have a different ZIR `func` instruction is if the old
+ // instruction has been lost and replaced with a new `TrackedInst.Index`.
+ assert(zir_body_inst_ptr.resolve(ip) == null);
+ zir_body_inst_ptr.* = key.zir_body_inst;
+ }
+
return gop.existing;
}
@@ -8760,6 +8770,16 @@ pub fn getFuncDeclIes(
// An existing function type was found; undo the additions to our two arrays.
items.mutate.len -= 4;
extra.mutate.len = prev_extra_len;
+
+ const zir_body_inst_ptr = ip.funcDeclInfo(func_gop.existing).zirBodyInstPtr(ip);
+ if (zir_body_inst_ptr.* != key.zir_body_inst) {
+ // Since this function's `owner_nav` matches `key`, this *is* the function we're talking
+ // about. The only way it could have a different ZIR `func` instruction is if the old
+ // instruction has been lost and replaced with a new `TrackedInst.Index`.
+ assert(zir_body_inst_ptr.resolve(ip) == null);
+ zir_body_inst_ptr.* = key.zir_body_inst;
+ }
+
return func_gop.existing;
}
func_gop.putTentative(func_index);