| ... | ... | @@ -734,31 +734,25 @@ fn ensureFuncBodyAnalyzedInner( |
| 734 | 734 | const func = zcu.funcInfo(func_index); |
| 735 | 735 | const anal_unit = AnalUnit.wrap(.{ .func = func_index }); |
| 736 | 736 | |
| 737 | | // Here's an interesting question: is this function actually valid? |
| 738 | | // Maybe the signature changed, so we'll end up creating a whole different `func` |
| 739 | | // in the InternPool, and this one is a waste of time to analyze. Worse, we'd be |
| 740 | | // analyzing new ZIR with old data, and get bogus errors. They would be unused, |
| 741 | | // but they would still hang around internally! So, let's detect this case. |
| 742 | | // For function decls, we must ensure the declaration's `Cau` is up-to-date, and |
| 743 | | // check if `func_index` was removed by that update. |
| 744 | | // For function instances, we do that process on the generic owner. |
| 745 | | |
| 746 | | try pt.ensureCauAnalyzed(cau: { |
| 747 | | const func_nav = if (func.generic_owner == .none) |
| 748 | | func.owner_nav |
| 749 | | else |
| 750 | | zcu.funcInfo(func.generic_owner).owner_nav; |
| 751 | | |
| 752 | | break :cau ip.getNav(func_nav).analysis_owner.unwrap().?; |
| 753 | | }); |
| 754 | | |
| 755 | | if (ip.isRemoved(func_index) or (func.generic_owner != .none and ip.isRemoved(func.generic_owner))) { |
| 756 | | if (func_outdated) { |
| 757 | | try zcu.markDependeeOutdated(.marked_po, .{ .interned = func_index }); // IES |
| 737 | // Make sure that this function is still owned by the same `Nav`. Otherwise, analyzing |
| 738 | // it would be a waste of time in the best case, and could cause codegen to give bogus |
| 739 | // results in the worst case. |
| 740 | |
| 741 | if (func.generic_owner == .none) { |
| 742 | try pt.ensureCauAnalyzed(ip.getNav(func.owner_nav).analysis_owner.unwrap().?); |
| 743 | if (ip.getNav(func.owner_nav).status.resolved.val != func_index) { |
| 744 | // This function is no longer referenced! There's no point in re-analyzing it. |
| 745 | // Just mark a transitive failure and move on. |
| 746 | return error.AnalysisFail; |
| 747 | } |
| 748 | } else { |
| 749 | const go_nav = zcu.funcInfo(func.generic_owner).owner_nav; |
| 750 | try pt.ensureCauAnalyzed(ip.getNav(go_nav).analysis_owner.unwrap().?); |
| 751 | if (ip.getNav(go_nav).status.resolved.val != func.generic_owner) { |
| 752 | // The generic owner is no longer referenced, so this function is also unreferenced. |
| 753 | // There's no point in re-analyzing it. Just mark a transitive failure and move on. |
| 754 | return error.AnalysisFail; |
| 758 | 755 | } |
| 759 | | ip.removeDependenciesForDepender(gpa, AnalUnit.wrap(.{ .func = func_index })); |
| 760 | | ip.remove(pt.tid, func_index); |
| 761 | | @panic("TODO: remove orphaned function from binary"); |
| 762 | 756 | } |
| 763 | 757 | |
| 764 | 758 | // We'll want to remember what the IES used to be before the update for |