authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-11-03 12:08:33-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-11-03 21:24:13-04:00
log1ccc68f307d4a2208118a8798d43119d63b53e05
treebdffe5cfa63e7fe1fd6efa9a26a139cc01888210
parenta95be8f0e06b528c246b7b4f6cada557568017e2

frontend: rip out Decl dependencies

This incremental compilation logic will need to be reworked so that it does not depend on buried pointers - that is, long-lived pointers that are owned by non-top-level objects such as Decl. In the meantime, this fixes memory leaks since the memory management of these dependencies has bitrotted.

3 files changed, 2 insertions(+), 152 deletions(-)

src/Compilation.zig-1
...@@ -2266,7 +2266,6 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void...@@ -2266,7 +2266,6 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
2266 const decl_index = module.deletion_set.keys()[0];2266 const decl_index = module.deletion_set.keys()[0];
2267 const decl = module.declPtr(decl_index);2267 const decl = module.declPtr(decl_index);
2268 assert(decl.deletion_flag);2268 assert(decl.deletion_flag);
2269 assert(decl.dependants.count() == 0);
2270 assert(decl.zir_decl_index != .none);2269 assert(decl.zir_decl_index != .none);
22712270
2272 try module.clearDecl(decl_index, null);2271 try module.clearDecl(decl_index, null);
src/Module.zig+2-117
...@@ -463,13 +463,6 @@ pub const Decl = struct {...@@ -463,13 +463,6 @@ pub const Decl = struct {
463 /// What kind of a declaration is this.463 /// What kind of a declaration is this.
464 kind: Kind,464 kind: Kind,
465465
466 /// The shallow set of other decls whose typed_value could possibly change if this Decl's
467 /// typed_value is modified.
468 dependants: DepsTable = .{},
469 /// The shallow set of other decls whose typed_value changing indicates that this Decl's
470 /// typed_value may need to be regenerated.
471 dependencies: DepsTable = .{},
472
473 pub const Kind = enum {466 pub const Kind = enum {
474 @"usingnamespace",467 @"usingnamespace",
475 @"test",468 @"test",
...@@ -2626,8 +2619,6 @@ pub fn destroyDecl(mod: *Module, decl_index: Decl.Index) void {...@@ -2626,8 +2619,6 @@ pub fn destroyDecl(mod: *Module, decl_index: Decl.Index) void {
2626 mod.destroyNamespace(i);2619 mod.destroyNamespace(i);
2627 }2620 }
2628 }2621 }
2629 decl.dependants.deinit(gpa);
2630 decl.dependencies.deinit(gpa);
2631 }2622 }
26322623
2633 ip.destroyDecl(gpa, decl_index);2624 ip.destroyDecl(gpa, decl_index);
...@@ -3278,16 +3269,6 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl_index: Decl.Index) SemaError!void {...@@ -3278,16 +3269,6 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl_index: Decl.Index) SemaError!void {
3278 // prior to re-analysis.3269 // prior to re-analysis.
3279 try mod.deleteDeclExports(decl_index);3270 try mod.deleteDeclExports(decl_index);
32803271
3281 // Dependencies will be re-discovered, so we remove them here prior to re-analysis.
3282 for (decl.dependencies.keys()) |dep_index| {
3283 const dep = mod.declPtr(dep_index);
3284 dep.removeDependant(decl_index);
3285 if (dep.dependants.count() == 0 and !dep.deletion_flag) {
3286 try mod.markDeclForDeletion(dep_index);
3287 }
3288 }
3289 decl.dependencies.clearRetainingCapacity();
3290
3291 break :blk true;3272 break :blk true;
3292 },3273 },
32933274
...@@ -3331,33 +3312,8 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl_index: Decl.Index) SemaError!void {...@@ -3331,33 +3312,8 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl_index: Decl.Index) SemaError!void {
3331 };3312 };
33323313
3333 if (subsequent_analysis) {3314 if (subsequent_analysis) {
3334 // Update all dependents which have at least this level of dependency.3315 _ = type_changed;
3335 // If our type remained the same and we're a function, only update3316 @panic("TODO re-implement incremental compilation");
3336 // decls which depend on our body; otherwise, update all dependents.
3337 const update_level: Decl.DepType = if (!type_changed and decl.ty.zigTypeTag(mod) == .Fn) .function_body else .normal;
3338
3339 for (decl.dependants.keys(), decl.dependants.values()) |dep_index, dep_type| {
3340 if (@intFromEnum(dep_type) < @intFromEnum(update_level)) continue;
3341
3342 const dep = mod.declPtr(dep_index);
3343 switch (dep.analysis) {
3344 .unreferenced => unreachable,
3345 .in_progress => continue, // already doing analysis, ok
3346 .outdated => continue, // already queued for update
3347
3348 .file_failure,
3349 .dependency_failure,
3350 .sema_failure,
3351 .sema_failure_retryable,
3352 .liveness_failure,
3353 .codegen_failure,
3354 .codegen_failure_retryable,
3355 .complete,
3356 => if (dep.generation != mod.generation) {
3357 try mod.markOutdatedDecl(dep_index);
3358 },
3359 }
3360 }
3361 }3317 }
3362}3318}
33633319
...@@ -3938,37 +3894,6 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !bool {...@@ -3938,37 +3894,6 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !bool {
3938 return type_changed;3894 return type_changed;
3939}3895}
39403896
3941/// Returns the depender's index of the dependee.
3942pub fn declareDeclDependency(mod: *Module, depender_index: Decl.Index, dependee_index: Decl.Index) !void {
3943 return mod.declareDeclDependencyType(depender_index, dependee_index, .normal);
3944}
3945
3946/// Returns the depender's index of the dependee.
3947pub fn declareDeclDependencyType(mod: *Module, depender_index: Decl.Index, dependee_index: Decl.Index, dep_type: Decl.DepType) !void {
3948 if (depender_index == dependee_index) return;
3949
3950 const depender = mod.declPtr(depender_index);
3951 const dependee = mod.declPtr(dependee_index);
3952
3953 if (depender.dependencies.get(dependee_index)) |cur_type| {
3954 if (@intFromEnum(cur_type) >= @intFromEnum(dep_type)) {
3955 // We already have this dependency (or stricter) marked
3956 return;
3957 }
3958 }
3959
3960 if (dependee.deletion_flag) {
3961 dependee.deletion_flag = false;
3962 assert(mod.deletion_set.swapRemove(dependee_index));
3963 }
3964
3965 try depender.dependencies.ensureUnusedCapacity(mod.gpa, 1);
3966 try dependee.dependants.ensureUnusedCapacity(mod.gpa, 1);
3967
3968 dependee.dependants.putAssumeCapacity(depender_index, dep_type);
3969 depender.dependencies.putAssumeCapacity(dependee_index, dep_type);
3970}
3971
3972pub const ImportFileResult = struct {3897pub const ImportFileResult = struct {
3973 file: *File,3898 file: *File,
3974 is_new: bool,3899 is_new: bool,
...@@ -4508,35 +4433,10 @@ pub fn clearDecl(...@@ -4508,35 +4433,10 @@ pub fn clearDecl(
4508 const decl = mod.declPtr(decl_index);4433 const decl = mod.declPtr(decl_index);
45094434
4510 const gpa = mod.gpa;4435 const gpa = mod.gpa;
4511 try mod.deletion_set.ensureUnusedCapacity(gpa, decl.dependencies.count());
45124436
4513 if (outdated_decls) |map| {4437 if (outdated_decls) |map| {
4514 _ = map.swapRemove(decl_index);4438 _ = map.swapRemove(decl_index);
4515 try map.ensureUnusedCapacity(decl.dependants.count());
4516 }
4517
4518 // Remove itself from its dependencies.
4519 for (decl.dependencies.keys()) |dep_index| {
4520 const dep = mod.declPtr(dep_index);
4521 dep.removeDependant(decl_index);
4522 if (dep.dependants.count() == 0 and !dep.deletion_flag) {
4523 // We don't recursively perform a deletion here, because during the update,
4524 // another reference to it may turn up.
4525 dep.deletion_flag = true;
4526 mod.deletion_set.putAssumeCapacity(dep_index, {});
4527 }
4528 }
4529 decl.dependencies.clearRetainingCapacity();
4530
4531 // Anything that depends on this deleted decl needs to be re-analyzed.
4532 for (decl.dependants.keys()) |dep_index| {
4533 const dep = mod.declPtr(dep_index);
4534 dep.removeDependency(decl_index);
4535 if (outdated_decls) |map| {
4536 map.putAssumeCapacity(dep_index, {});
4537 }
4538 }4439 }
4539 decl.dependants.clearRetainingCapacity();
45404440
4541 if (mod.failed_decls.fetchSwapRemove(decl_index)) |kv| {4441 if (mod.failed_decls.fetchSwapRemove(decl_index)) |kv| {
4542 kv.value.destroy(gpa);4442 kv.value.destroy(gpa);
...@@ -4598,19 +4498,7 @@ fn markDeclForDeletion(mod: *Module, decl_index: Decl.Index) !void {...@@ -4598,19 +4498,7 @@ fn markDeclForDeletion(mod: *Module, decl_index: Decl.Index) !void {
4598/// Cancel the creation of an anon decl and delete any references to it.4498/// Cancel the creation of an anon decl and delete any references to it.
4599/// If other decls depend on this decl, they must be aborted first.4499/// If other decls depend on this decl, they must be aborted first.
4600pub fn abortAnonDecl(mod: *Module, decl_index: Decl.Index) void {4500pub fn abortAnonDecl(mod: *Module, decl_index: Decl.Index) void {
4601 const decl = mod.declPtr(decl_index);
4602
4603 assert(!mod.declIsRoot(decl_index));4501 assert(!mod.declIsRoot(decl_index));
4604
4605 // An aborted decl must not have dependants -- they must have
4606 // been aborted first and removed from this list.
4607 assert(decl.dependants.count() == 0);
4608
4609 for (decl.dependencies.keys()) |dep_index| {
4610 const dep = mod.declPtr(dep_index);
4611 dep.removeDependant(decl_index);
4612 }
4613
4614 mod.destroyDecl(decl_index);4502 mod.destroyDecl(decl_index);
4615}4503}
46164504
...@@ -5694,9 +5582,6 @@ pub fn populateTestFunctions(...@@ -5694,9 +5582,6 @@ pub fn populateTestFunctions(
5694 .storage = .{ .elems = test_fn_vals },5582 .storage = .{ .elems = test_fn_vals },
5695 } })).toValue(),5583 } })).toValue(),
5696 });5584 });
5697 for (array_decl_dependencies.items) |array_decl_dependency| {
5698 try mod.declareDeclDependency(array_decl_index, array_decl_dependency);
5699 }
57005585
5701 break :d array_decl_index;5586 break :d array_decl_index;
5702 };5587 };
src/Sema.zig-34
...@@ -4006,7 +4006,6 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com...@@ -4006,7 +4006,6 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
4006 .inferred_alloc_comptime => {4006 .inferred_alloc_comptime => {
4007 const iac = sema.air_instructions.items(.data)[ptr_inst].inferred_alloc_comptime;4007 const iac = sema.air_instructions.items(.data)[ptr_inst].inferred_alloc_comptime;
4008 const decl_index = iac.decl_index;4008 const decl_index = iac.decl_index;
4009 try mod.declareDeclDependency(sema.owner_decl_index, decl_index);
40104009
4011 const decl = mod.declPtr(decl_index);4010 const decl = mod.declPtr(decl_index);
4012 if (iac.is_const) _ = try decl.internValue(mod);4011 if (iac.is_const) _ = try decl.internValue(mod);
...@@ -6411,7 +6410,6 @@ fn lookupInNamespace(...@@ -6411,7 +6410,6 @@ fn lookupInNamespace(
6411 const namespace_decl_index = namespace.getDeclIndex(mod);6410 const namespace_decl_index = namespace.getDeclIndex(mod);
6412 const namespace_decl = mod.declPtr(namespace_decl_index);6411 const namespace_decl = mod.declPtr(namespace_decl_index);
6413 if (namespace_decl.analysis == .file_failure) {6412 if (namespace_decl.analysis == .file_failure) {
6414 try mod.declareDeclDependency(sema.owner_decl_index, namespace_decl_index);
6415 return error.AnalysisFail;6413 return error.AnalysisFail;
6416 }6414 }
64176415
...@@ -6473,7 +6471,6 @@ fn lookupInNamespace(...@@ -6473,7 +6471,6 @@ fn lookupInNamespace(
6473 0 => {},6471 0 => {},
6474 1 => {6472 1 => {
6475 const decl_index = candidates.items[0];6473 const decl_index = candidates.items[0];
6476 try mod.declareDeclDependency(sema.owner_decl_index, decl_index);
6477 return decl_index;6474 return decl_index;
6478 },6475 },
6479 else => {6476 else => {
...@@ -6491,14 +6488,9 @@ fn lookupInNamespace(...@@ -6491,14 +6488,9 @@ fn lookupInNamespace(
6491 },6488 },
6492 }6489 }
6493 } else if (namespace.decls.getKeyAdapted(ident_name, Module.DeclAdapter{ .mod = mod })) |decl_index| {6490 } else if (namespace.decls.getKeyAdapted(ident_name, Module.DeclAdapter{ .mod = mod })) |decl_index| {
6494 try mod.declareDeclDependency(sema.owner_decl_index, decl_index);
6495 return decl_index;6491 return decl_index;
6496 }6492 }
64976493
6498 // TODO This dependency is too strong. Really, it should only be a dependency
6499 // on the non-existence of `ident_name` in the namespace. We can lessen the number of
6500 // outdated declarations by making this dependency more sophisticated.
6501 try mod.declareDeclDependency(sema.owner_decl_index, namespace_decl_index);
6502 return null;6494 return null;
6503}6495}
65046496
...@@ -7318,8 +7310,6 @@ fn analyzeCall(...@@ -7318,8 +7310,6 @@ fn analyzeCall(
7318 );7310 );
7319 defer ics.deinit();7311 defer ics.deinit();
73207312
7321 try mod.declareDeclDependencyType(ics.callee().owner_decl_index, module_fn.owner_decl, .function_body);
7322
7323 var child_block: Block = .{7313 var child_block: Block = .{
7324 .parent = null,7314 .parent = null,
7325 .sema = sema,7315 .sema = sema,
...@@ -16856,7 +16846,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16856,7 +16846,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16856 type_info_ty.getNamespaceIndex(mod).unwrap().?,16846 type_info_ty.getNamespaceIndex(mod).unwrap().?,
16857 try ip.getOrPutString(gpa, "Fn"),16847 try ip.getOrPutString(gpa, "Fn"),
16858 )).?;16848 )).?;
16859 try mod.declareDeclDependency(sema.owner_decl_index, fn_info_decl_index);
16860 try sema.ensureDeclAnalyzed(fn_info_decl_index);16849 try sema.ensureDeclAnalyzed(fn_info_decl_index);
16861 const fn_info_decl = mod.declPtr(fn_info_decl_index);16850 const fn_info_decl = mod.declPtr(fn_info_decl_index);
16862 const fn_info_ty = fn_info_decl.val.toType();16851 const fn_info_ty = fn_info_decl.val.toType();
...@@ -16867,7 +16856,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16867,7 +16856,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16867 fn_info_ty.getNamespaceIndex(mod).unwrap().?,16856 fn_info_ty.getNamespaceIndex(mod).unwrap().?,
16868 try ip.getOrPutString(gpa, "Param"),16857 try ip.getOrPutString(gpa, "Param"),
16869 )).?;16858 )).?;
16870 try mod.declareDeclDependency(sema.owner_decl_index, param_info_decl_index);
16871 try sema.ensureDeclAnalyzed(param_info_decl_index);16859 try sema.ensureDeclAnalyzed(param_info_decl_index);
16872 const param_info_decl = mod.declPtr(param_info_decl_index);16860 const param_info_decl = mod.declPtr(param_info_decl_index);
16873 const param_info_ty = param_info_decl.val.toType();16861 const param_info_ty = param_info_decl.val.toType();
...@@ -16967,7 +16955,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16967,7 +16955,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16967 type_info_ty.getNamespaceIndex(mod).unwrap().?,16955 type_info_ty.getNamespaceIndex(mod).unwrap().?,
16968 try ip.getOrPutString(gpa, "Int"),16956 try ip.getOrPutString(gpa, "Int"),
16969 )).?;16957 )).?;
16970 try mod.declareDeclDependency(sema.owner_decl_index, int_info_decl_index);
16971 try sema.ensureDeclAnalyzed(int_info_decl_index);16958 try sema.ensureDeclAnalyzed(int_info_decl_index);
16972 const int_info_decl = mod.declPtr(int_info_decl_index);16959 const int_info_decl = mod.declPtr(int_info_decl_index);
16973 const int_info_ty = int_info_decl.val.toType();16960 const int_info_ty = int_info_decl.val.toType();
...@@ -16996,7 +16983,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16996,7 +16983,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16996 type_info_ty.getNamespaceIndex(mod).unwrap().?,16983 type_info_ty.getNamespaceIndex(mod).unwrap().?,
16997 try ip.getOrPutString(gpa, "Float"),16984 try ip.getOrPutString(gpa, "Float"),
16998 )).?;16985 )).?;
16999 try mod.declareDeclDependency(sema.owner_decl_index, float_info_decl_index);
17000 try sema.ensureDeclAnalyzed(float_info_decl_index);16986 try sema.ensureDeclAnalyzed(float_info_decl_index);
17001 const float_info_decl = mod.declPtr(float_info_decl_index);16987 const float_info_decl = mod.declPtr(float_info_decl_index);
17002 const float_info_ty = float_info_decl.val.toType();16988 const float_info_ty = float_info_decl.val.toType();
...@@ -17029,7 +17015,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17029,7 +17015,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17029 (try sema.getBuiltinType("Type")).getNamespaceIndex(mod).unwrap().?,17015 (try sema.getBuiltinType("Type")).getNamespaceIndex(mod).unwrap().?,
17030 try ip.getOrPutString(gpa, "Pointer"),17016 try ip.getOrPutString(gpa, "Pointer"),
17031 )).?;17017 )).?;
17032 try mod.declareDeclDependency(sema.owner_decl_index, decl_index);
17033 try sema.ensureDeclAnalyzed(decl_index);17018 try sema.ensureDeclAnalyzed(decl_index);
17034 const decl = mod.declPtr(decl_index);17019 const decl = mod.declPtr(decl_index);
17035 break :t decl.val.toType();17020 break :t decl.val.toType();
...@@ -17041,7 +17026,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17041,7 +17026,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17041 pointer_ty.getNamespaceIndex(mod).unwrap().?,17026 pointer_ty.getNamespaceIndex(mod).unwrap().?,
17042 try ip.getOrPutString(gpa, "Size"),17027 try ip.getOrPutString(gpa, "Size"),
17043 )).?;17028 )).?;
17044 try mod.declareDeclDependency(sema.owner_decl_index, decl_index);
17045 try sema.ensureDeclAnalyzed(decl_index);17029 try sema.ensureDeclAnalyzed(decl_index);
17046 const decl = mod.declPtr(decl_index);17030 const decl = mod.declPtr(decl_index);
17047 break :t decl.val.toType();17031 break :t decl.val.toType();
...@@ -17085,7 +17069,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17085,7 +17069,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17085 type_info_ty.getNamespaceIndex(mod).unwrap().?,17069 type_info_ty.getNamespaceIndex(mod).unwrap().?,
17086 try ip.getOrPutString(gpa, "Array"),17070 try ip.getOrPutString(gpa, "Array"),
17087 )).?;17071 )).?;
17088 try mod.declareDeclDependency(sema.owner_decl_index, array_field_ty_decl_index);
17089 try sema.ensureDeclAnalyzed(array_field_ty_decl_index);17072 try sema.ensureDeclAnalyzed(array_field_ty_decl_index);
17090 const array_field_ty_decl = mod.declPtr(array_field_ty_decl_index);17073 const array_field_ty_decl = mod.declPtr(array_field_ty_decl_index);
17091 break :t array_field_ty_decl.val.toType();17074 break :t array_field_ty_decl.val.toType();
...@@ -17117,7 +17100,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17117,7 +17100,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17117 type_info_ty.getNamespaceIndex(mod).unwrap().?,17100 type_info_ty.getNamespaceIndex(mod).unwrap().?,
17118 try ip.getOrPutString(gpa, "Vector"),17101 try ip.getOrPutString(gpa, "Vector"),
17119 )).?;17102 )).?;
17120 try mod.declareDeclDependency(sema.owner_decl_index, vector_field_ty_decl_index);
17121 try sema.ensureDeclAnalyzed(vector_field_ty_decl_index);17103 try sema.ensureDeclAnalyzed(vector_field_ty_decl_index);
17122 const vector_field_ty_decl = mod.declPtr(vector_field_ty_decl_index);17104 const vector_field_ty_decl = mod.declPtr(vector_field_ty_decl_index);
17123 break :t vector_field_ty_decl.val.toType();17105 break :t vector_field_ty_decl.val.toType();
...@@ -17147,7 +17129,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17147,7 +17129,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17147 type_info_ty.getNamespaceIndex(mod).unwrap().?,17129 type_info_ty.getNamespaceIndex(mod).unwrap().?,
17148 try ip.getOrPutString(gpa, "Optional"),17130 try ip.getOrPutString(gpa, "Optional"),
17149 )).?;17131 )).?;
17150 try mod.declareDeclDependency(sema.owner_decl_index, optional_field_ty_decl_index);
17151 try sema.ensureDeclAnalyzed(optional_field_ty_decl_index);17132 try sema.ensureDeclAnalyzed(optional_field_ty_decl_index);
17152 const optional_field_ty_decl = mod.declPtr(optional_field_ty_decl_index);17133 const optional_field_ty_decl = mod.declPtr(optional_field_ty_decl_index);
17153 break :t optional_field_ty_decl.val.toType();17134 break :t optional_field_ty_decl.val.toType();
...@@ -17175,7 +17156,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17175,7 +17156,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17175 type_info_ty.getNamespaceIndex(mod).unwrap().?,17156 type_info_ty.getNamespaceIndex(mod).unwrap().?,
17176 try ip.getOrPutString(gpa, "Error"),17157 try ip.getOrPutString(gpa, "Error"),
17177 )).?;17158 )).?;
17178 try mod.declareDeclDependency(sema.owner_decl_index, set_field_ty_decl_index);
17179 try sema.ensureDeclAnalyzed(set_field_ty_decl_index);17159 try sema.ensureDeclAnalyzed(set_field_ty_decl_index);
17180 const set_field_ty_decl = mod.declPtr(set_field_ty_decl_index);17160 const set_field_ty_decl = mod.declPtr(set_field_ty_decl_index);
17181 break :t set_field_ty_decl.val.toType();17161 break :t set_field_ty_decl.val.toType();
...@@ -17274,7 +17254,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17274,7 +17254,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17274 type_info_ty.getNamespaceIndex(mod).unwrap().?,17254 type_info_ty.getNamespaceIndex(mod).unwrap().?,
17275 try ip.getOrPutString(gpa, "ErrorUnion"),17255 try ip.getOrPutString(gpa, "ErrorUnion"),
17276 )).?;17256 )).?;
17277 try mod.declareDeclDependency(sema.owner_decl_index, error_union_field_ty_decl_index);
17278 try sema.ensureDeclAnalyzed(error_union_field_ty_decl_index);17257 try sema.ensureDeclAnalyzed(error_union_field_ty_decl_index);
17279 const error_union_field_ty_decl = mod.declPtr(error_union_field_ty_decl_index);17258 const error_union_field_ty_decl = mod.declPtr(error_union_field_ty_decl_index);
17280 break :t error_union_field_ty_decl.val.toType();17259 break :t error_union_field_ty_decl.val.toType();
...@@ -17305,7 +17284,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17305,7 +17284,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17305 type_info_ty.getNamespaceIndex(mod).unwrap().?,17284 type_info_ty.getNamespaceIndex(mod).unwrap().?,
17306 try ip.getOrPutString(gpa, "EnumField"),17285 try ip.getOrPutString(gpa, "EnumField"),
17307 )).?;17286 )).?;
17308 try mod.declareDeclDependency(sema.owner_decl_index, enum_field_ty_decl_index);
17309 try sema.ensureDeclAnalyzed(enum_field_ty_decl_index);17287 try sema.ensureDeclAnalyzed(enum_field_ty_decl_index);
17310 const enum_field_ty_decl = mod.declPtr(enum_field_ty_decl_index);17288 const enum_field_ty_decl = mod.declPtr(enum_field_ty_decl_index);
17311 break :t enum_field_ty_decl.val.toType();17289 break :t enum_field_ty_decl.val.toType();
...@@ -17390,7 +17368,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17390,7 +17368,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17390 type_info_ty.getNamespaceIndex(mod).unwrap().?,17368 type_info_ty.getNamespaceIndex(mod).unwrap().?,
17391 try ip.getOrPutString(gpa, "Enum"),17369 try ip.getOrPutString(gpa, "Enum"),
17392 )).?;17370 )).?;
17393 try mod.declareDeclDependency(sema.owner_decl_index, type_enum_ty_decl_index);
17394 try sema.ensureDeclAnalyzed(type_enum_ty_decl_index);17371 try sema.ensureDeclAnalyzed(type_enum_ty_decl_index);
17395 const type_enum_ty_decl = mod.declPtr(type_enum_ty_decl_index);17372 const type_enum_ty_decl = mod.declPtr(type_enum_ty_decl_index);
17396 break :t type_enum_ty_decl.val.toType();17373 break :t type_enum_ty_decl.val.toType();
...@@ -17423,7 +17400,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17423,7 +17400,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17423 type_info_ty.getNamespaceIndex(mod).unwrap().?,17400 type_info_ty.getNamespaceIndex(mod).unwrap().?,
17424 try ip.getOrPutString(gpa, "Union"),17401 try ip.getOrPutString(gpa, "Union"),
17425 )).?;17402 )).?;
17426 try mod.declareDeclDependency(sema.owner_decl_index, type_union_ty_decl_index);
17427 try sema.ensureDeclAnalyzed(type_union_ty_decl_index);17403 try sema.ensureDeclAnalyzed(type_union_ty_decl_index);
17428 const type_union_ty_decl = mod.declPtr(type_union_ty_decl_index);17404 const type_union_ty_decl = mod.declPtr(type_union_ty_decl_index);
17429 break :t type_union_ty_decl.val.toType();17405 break :t type_union_ty_decl.val.toType();
...@@ -17436,7 +17412,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17436,7 +17412,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17436 type_info_ty.getNamespaceIndex(mod).unwrap().?,17412 type_info_ty.getNamespaceIndex(mod).unwrap().?,
17437 try ip.getOrPutString(gpa, "UnionField"),17413 try ip.getOrPutString(gpa, "UnionField"),
17438 )).?;17414 )).?;
17439 try mod.declareDeclDependency(sema.owner_decl_index, union_field_ty_decl_index);
17440 try sema.ensureDeclAnalyzed(union_field_ty_decl_index);17415 try sema.ensureDeclAnalyzed(union_field_ty_decl_index);
17441 const union_field_ty_decl = mod.declPtr(union_field_ty_decl_index);17416 const union_field_ty_decl = mod.declPtr(union_field_ty_decl_index);
17442 break :t union_field_ty_decl.val.toType();17417 break :t union_field_ty_decl.val.toType();
...@@ -17531,7 +17506,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17531,7 +17506,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17531 (try sema.getBuiltinType("Type")).getNamespaceIndex(mod).unwrap().?,17506 (try sema.getBuiltinType("Type")).getNamespaceIndex(mod).unwrap().?,
17532 try ip.getOrPutString(gpa, "ContainerLayout"),17507 try ip.getOrPutString(gpa, "ContainerLayout"),
17533 )).?;17508 )).?;
17534 try mod.declareDeclDependency(sema.owner_decl_index, decl_index);
17535 try sema.ensureDeclAnalyzed(decl_index);17509 try sema.ensureDeclAnalyzed(decl_index);
17536 const decl = mod.declPtr(decl_index);17510 const decl = mod.declPtr(decl_index);
17537 break :t decl.val.toType();17511 break :t decl.val.toType();
...@@ -17565,7 +17539,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17565,7 +17539,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17565 type_info_ty.getNamespaceIndex(mod).unwrap().?,17539 type_info_ty.getNamespaceIndex(mod).unwrap().?,
17566 try ip.getOrPutString(gpa, "Struct"),17540 try ip.getOrPutString(gpa, "Struct"),
17567 )).?;17541 )).?;
17568 try mod.declareDeclDependency(sema.owner_decl_index, type_struct_ty_decl_index);
17569 try sema.ensureDeclAnalyzed(type_struct_ty_decl_index);17542 try sema.ensureDeclAnalyzed(type_struct_ty_decl_index);
17570 const type_struct_ty_decl = mod.declPtr(type_struct_ty_decl_index);17543 const type_struct_ty_decl = mod.declPtr(type_struct_ty_decl_index);
17571 break :t type_struct_ty_decl.val.toType();17544 break :t type_struct_ty_decl.val.toType();
...@@ -17578,7 +17551,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17578,7 +17551,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17578 type_info_ty.getNamespaceIndex(mod).unwrap().?,17551 type_info_ty.getNamespaceIndex(mod).unwrap().?,
17579 try ip.getOrPutString(gpa, "StructField"),17552 try ip.getOrPutString(gpa, "StructField"),
17580 )).?;17553 )).?;
17581 try mod.declareDeclDependency(sema.owner_decl_index, struct_field_ty_decl_index);
17582 try sema.ensureDeclAnalyzed(struct_field_ty_decl_index);17554 try sema.ensureDeclAnalyzed(struct_field_ty_decl_index);
17583 const struct_field_ty_decl = mod.declPtr(struct_field_ty_decl_index);17555 const struct_field_ty_decl = mod.declPtr(struct_field_ty_decl_index);
17584 break :t struct_field_ty_decl.val.toType();17556 break :t struct_field_ty_decl.val.toType();
...@@ -17751,7 +17723,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17751,7 +17723,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17751 (try sema.getBuiltinType("Type")).getNamespaceIndex(mod).unwrap().?,17723 (try sema.getBuiltinType("Type")).getNamespaceIndex(mod).unwrap().?,
17752 try ip.getOrPutString(gpa, "ContainerLayout"),17724 try ip.getOrPutString(gpa, "ContainerLayout"),
17753 )).?;17725 )).?;
17754 try mod.declareDeclDependency(sema.owner_decl_index, decl_index);
17755 try sema.ensureDeclAnalyzed(decl_index);17726 try sema.ensureDeclAnalyzed(decl_index);
17756 const decl = mod.declPtr(decl_index);17727 const decl = mod.declPtr(decl_index);
17757 break :t decl.val.toType();17728 break :t decl.val.toType();
...@@ -17788,7 +17759,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17788,7 +17759,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17788 type_info_ty.getNamespaceIndex(mod).unwrap().?,17759 type_info_ty.getNamespaceIndex(mod).unwrap().?,
17789 try ip.getOrPutString(gpa, "Opaque"),17760 try ip.getOrPutString(gpa, "Opaque"),
17790 )).?;17761 )).?;
17791 try mod.declareDeclDependency(sema.owner_decl_index, type_opaque_ty_decl_index);
17792 try sema.ensureDeclAnalyzed(type_opaque_ty_decl_index);17762 try sema.ensureDeclAnalyzed(type_opaque_ty_decl_index);
17793 const type_opaque_ty_decl = mod.declPtr(type_opaque_ty_decl_index);17763 const type_opaque_ty_decl = mod.declPtr(type_opaque_ty_decl_index);
17794 break :t type_opaque_ty_decl.val.toType();17764 break :t type_opaque_ty_decl.val.toType();
...@@ -17832,7 +17802,6 @@ fn typeInfoDecls(...@@ -17832,7 +17802,6 @@ fn typeInfoDecls(
17832 type_info_ty.getNamespaceIndex(mod).unwrap().?,17802 type_info_ty.getNamespaceIndex(mod).unwrap().?,
17833 try mod.intern_pool.getOrPutString(gpa, "Declaration"),17803 try mod.intern_pool.getOrPutString(gpa, "Declaration"),
17834 )).?;17804 )).?;
17835 try mod.declareDeclDependency(sema.owner_decl_index, declaration_ty_decl_index);
17836 try sema.ensureDeclAnalyzed(declaration_ty_decl_index);17805 try sema.ensureDeclAnalyzed(declaration_ty_decl_index);
17837 const declaration_ty_decl = mod.declPtr(declaration_ty_decl_index);17806 const declaration_ty_decl = mod.declPtr(declaration_ty_decl_index);
17838 break :t declaration_ty_decl.val.toType();17807 break :t declaration_ty_decl.val.toType();
...@@ -25237,7 +25206,6 @@ fn zirBuiltinExtern(...@@ -25237,7 +25206,6 @@ fn zirBuiltinExtern(
25237 new_decl.generation = mod.generation;25206 new_decl.generation = mod.generation;
25238 }25207 }
2523925208
25240 try mod.declareDeclDependency(sema.owner_decl_index, new_decl_index);
25241 try sema.ensureDeclAnalyzed(new_decl_index);25209 try sema.ensureDeclAnalyzed(new_decl_index);
2524225210
25243 return Air.internedToRef((try mod.getCoerced((try mod.intern(.{ .ptr = .{25211 return Air.internedToRef((try mod.getCoerced((try mod.intern(.{ .ptr = .{
...@@ -31640,7 +31608,6 @@ fn analyzeDeclRef(sema: *Sema, decl_index: Decl.Index) CompileError!Air.Inst.Ref...@@ -31640,7 +31608,6 @@ fn analyzeDeclRef(sema: *Sema, decl_index: Decl.Index) CompileError!Air.Inst.Ref
31640/// this function with `analyze_fn_body` set to true.31608/// this function with `analyze_fn_body` set to true.
31641fn analyzeDeclRefInner(sema: *Sema, decl_index: Decl.Index, analyze_fn_body: bool) CompileError!Air.Inst.Ref {31609fn analyzeDeclRefInner(sema: *Sema, decl_index: Decl.Index, analyze_fn_body: bool) CompileError!Air.Inst.Ref {
31642 const mod = sema.mod;31610 const mod = sema.mod;
31643 try mod.declareDeclDependency(sema.owner_decl_index, decl_index);
31644 try sema.ensureDeclAnalyzed(decl_index);31611 try sema.ensureDeclAnalyzed(decl_index);
3164531612
31646 const decl = mod.declPtr(decl_index);31613 const decl = mod.declPtr(decl_index);
...@@ -36895,7 +36862,6 @@ fn analyzeComptimeAlloc(...@@ -36895,7 +36862,6 @@ fn analyzeComptimeAlloc(
36895 decl.alignment = alignment;36862 decl.alignment = alignment;
3689636863
36897 try sema.comptime_mutable_decls.append(decl_index);36864 try sema.comptime_mutable_decls.append(decl_index);
36898 try mod.declareDeclDependency(sema.owner_decl_index, decl_index);
36899 return Air.internedToRef((try mod.intern(.{ .ptr = .{36865 return Air.internedToRef((try mod.intern(.{ .ptr = .{
36900 .ty = ptr_type.toIntern(),36866 .ty = ptr_type.toIntern(),
36901 .addr = .{ .mut_decl = .{36867 .addr = .{ .mut_decl = .{