| ... | ... | @@ -700,7 +700,7 @@ fn analyzeMemoizedState(pt: Zcu.PerThread, stage: InternPool.MemoizedStateStage) |
| 700 | 700 | |
| 701 | 701 | const unit: AnalUnit = .wrap(.{ .memoized_state = stage }); |
| 702 | 702 | |
| 703 | | try zcu.analysis_in_progress.put(gpa, unit, {}); |
| 703 | try zcu.analysis_in_progress.putNoClobber(gpa, unit, {}); |
| 704 | 704 | defer assert(zcu.analysis_in_progress.swapRemove(unit)); |
| 705 | 705 | |
| 706 | 706 | // Before we begin, collect: |
| ... | ... | @@ -864,7 +864,7 @@ fn analyzeComptimeUnit(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu |
| 864 | 864 | const file = zcu.fileByIndex(inst_resolved.file); |
| 865 | 865 | const zir = file.zir.?; |
| 866 | 866 | |
| 867 | | try zcu.analysis_in_progress.put(gpa, anal_unit, {}); |
| 867 | try zcu.analysis_in_progress.putNoClobber(gpa, anal_unit, {}); |
| 868 | 868 | defer assert(zcu.analysis_in_progress.swapRemove(anal_unit)); |
| 869 | 869 | |
| 870 | 870 | var analysis_arena: std.heap.ArenaAllocator = .init(gpa); |
| ... | ... | @@ -958,6 +958,8 @@ pub fn ensureNavValUpToDate(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu |
| 958 | 958 | |
| 959 | 959 | log.debug("ensureNavValUpToDate {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 960 | 960 | |
| 961 | assert(!zcu.analysis_in_progress.contains(anal_unit)); |
| 962 | |
| 961 | 963 | // Determine whether or not this `Nav`'s value is outdated. This also includes checking if the |
| 962 | 964 | // status is `.unresolved`, which indicates that the value is outdated because it has *never* |
| 963 | 965 | // been analyzed so far. |
| ... | ... | @@ -1090,10 +1092,19 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr |
| 1090 | 1092 | const inst_resolved = old_nav.analysis.?.zir_index.resolveFull(ip) orelse return error.AnalysisFail; |
| 1091 | 1093 | const file = zcu.fileByIndex(inst_resolved.file); |
| 1092 | 1094 | const zir = file.zir.?; |
| 1095 | const zir_decl = zir.getDeclaration(inst_resolved.inst); |
| 1093 | 1096 | |
| 1094 | | try zcu.analysis_in_progress.put(gpa, anal_unit, {}); |
| 1097 | try zcu.analysis_in_progress.putNoClobber(gpa, anal_unit, {}); |
| 1095 | 1098 | errdefer _ = zcu.analysis_in_progress.swapRemove(anal_unit); |
| 1096 | 1099 | |
| 1100 | // If there's no type body, we are also resolving the type here. |
| 1101 | if (zir_decl.type_body == null) { |
| 1102 | try zcu.analysis_in_progress.putNoClobber(gpa, .wrap(.{ .nav_ty = nav_id }), {}); |
| 1103 | } |
| 1104 | errdefer if (zir_decl.type_body == null) { |
| 1105 | _ = zcu.analysis_in_progress.swapRemove(.wrap(.{ .nav_ty = nav_id })); |
| 1106 | }; |
| 1107 | |
| 1097 | 1108 | var analysis_arena: std.heap.ArenaAllocator = .init(gpa); |
| 1098 | 1109 | defer analysis_arena.deinit(); |
| 1099 | 1110 | |
| ... | ... | @@ -1133,8 +1144,6 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr |
| 1133 | 1144 | }; |
| 1134 | 1145 | defer block.instructions.deinit(gpa); |
| 1135 | 1146 | |
| 1136 | | const zir_decl = zir.getDeclaration(inst_resolved.inst); |
| 1137 | | |
| 1138 | 1147 | const ty_src = block.src(.{ .node_offset_var_decl_ty = .zero }); |
| 1139 | 1148 | const init_src = block.src(.{ .node_offset_var_decl_init = .zero }); |
| 1140 | 1149 | const align_src = block.src(.{ .node_offset_var_decl_align = .zero }); |
| ... | ... | @@ -1305,6 +1314,9 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr |
| 1305 | 1314 | |
| 1306 | 1315 | // Mark the unit as completed before evaluating the export! |
| 1307 | 1316 | assert(zcu.analysis_in_progress.swapRemove(anal_unit)); |
| 1317 | if (zir_decl.type_body == null) { |
| 1318 | assert(zcu.analysis_in_progress.swapRemove(.wrap(.{ .nav_ty = nav_id }))); |
| 1319 | } |
| 1308 | 1320 | |
| 1309 | 1321 | if (zir_decl.linkage == .@"export") { |
| 1310 | 1322 | const export_src = block.src(.{ .token_offset = @enumFromInt(@intFromBool(zir_decl.is_pub)) }); |
| ... | ... | @@ -1347,6 +1359,8 @@ pub fn ensureNavTypeUpToDate(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zc |
| 1347 | 1359 | |
| 1348 | 1360 | log.debug("ensureNavTypeUpToDate {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 1349 | 1361 | |
| 1362 | assert(!zcu.analysis_in_progress.contains(anal_unit)); |
| 1363 | |
| 1350 | 1364 | const type_resolved_by_value: bool = from_val: { |
| 1351 | 1365 | const analysis = nav.analysis orelse break :from_val false; |
| 1352 | 1366 | const inst_resolved = analysis.zir_index.resolveFull(ip) orelse break :from_val false; |
| ... | ... | @@ -1463,8 +1477,8 @@ fn analyzeNavType(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileEr |
| 1463 | 1477 | const file = zcu.fileByIndex(inst_resolved.file); |
| 1464 | 1478 | const zir = file.zir.?; |
| 1465 | 1479 | |
| 1466 | | try zcu.analysis_in_progress.put(gpa, anal_unit, {}); |
| 1467 | | defer _ = zcu.analysis_in_progress.swapRemove(anal_unit); |
| 1480 | try zcu.analysis_in_progress.putNoClobber(gpa, anal_unit, {}); |
| 1481 | defer assert(zcu.analysis_in_progress.swapRemove(anal_unit)); |
| 1468 | 1482 | |
| 1469 | 1483 | const zir_decl = zir.getDeclaration(inst_resolved.inst); |
| 1470 | 1484 | const type_body = zir_decl.type_body.?; |
| ... | ... | @@ -1587,6 +1601,8 @@ pub fn ensureFuncBodyUpToDate(pt: Zcu.PerThread, func_index: InternPool.Index) Z |
| 1587 | 1601 | |
| 1588 | 1602 | log.debug("ensureFuncBodyUpToDate {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 1589 | 1603 | |
| 1604 | assert(!zcu.analysis_in_progress.contains(anal_unit)); |
| 1605 | |
| 1590 | 1606 | const func = zcu.funcInfo(func_index); |
| 1591 | 1607 | |
| 1592 | 1608 | assert(func.ty == func.uncoerced_ty); // analyze the body of the original function, not a coerced one |
| ... | ... | @@ -2781,7 +2797,7 @@ fn analyzeFnBodyInner(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaE |
| 2781 | 2797 | const file = zcu.fileByIndex(inst_info.file); |
| 2782 | 2798 | const zir = file.zir.?; |
| 2783 | 2799 | |
| 2784 | | try zcu.analysis_in_progress.put(gpa, anal_unit, {}); |
| 2800 | try zcu.analysis_in_progress.putNoClobber(gpa, anal_unit, {}); |
| 2785 | 2801 | errdefer _ = zcu.analysis_in_progress.swapRemove(anal_unit); |
| 2786 | 2802 | |
| 2787 | 2803 | func.setAnalyzed(ip); |