[llvm] [DWARFLinker] Walk each shared subtree's dependencies once (PR #218072)
Alexey Lapshin via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 23 13:18:00 PDT 2026
================
@@ -284,40 +294,121 @@ bool DependencyTracker::markCollectedLiveRootsAsKept(
return Res;
}
+void DependencyTracker::recordSubtreeDependencies(
+ LiveRootWorklistActionTy Action, const UnitEntryPairTy &RootEntry,
+ const UnitEntryPairTy &Entry) {
+ SubtreeDependencyRefs.push_back({Entry, Action, RootEntry});
+}
+
+void DependencyTracker::materializeSubtreeSummaries() {
+ // Walking a subtree appends the dependencies that belong to a subprogram
+ // nested inside it, so all walking has to finish before the dependency list
+ // is traversed.
+ for (size_t Idx = MaterializedRefs; Idx != SubtreeDependencyRefs.size();
+ ++Idx) {
+ // Copied rather than referenced so that the loop does not depend on the
+ // walk below leaving the vector alone.
+ const SubtreeDependencyRefTy Ref = SubtreeDependencyRefs[Idx];
+ SubtreeDependenciesKeyTy Key{Ref.Subtree.CU, Ref.Subtree.DieEntry,
+ Ref.Action};
+ if (SubtreeSummaries.contains(Key))
+ continue;
+
+ // Collected separately so that growing the map cannot invalidate the sink.
+ SubtreeDependenciesTy SubtreeDeps;
+ {
+ SaveAndRestore<SubtreeDependenciesTy *> CollectInto(CollectedSubtreeDeps,
+ &SubtreeDeps);
+
+ // A walk that only records dependencies neither marks nor follows
+ // references, so it cannot discover a new interconnection and cannot
+ // fail.
+ std::atomic<bool> HasNewInterconnectedCUs = false;
+ bool Res = markDIEEntryAsKeptRec(Ref.Action, Ref.ReferencedBy,
+ Ref.Subtree, InterCUProcessingWasStarted,
+ HasNewInterconnectedCUs,
+ TreeWalkKindTy::RecordSubtreeDeps);
+ assert(Res && !HasNewInterconnectedCUs && "record-deps-only walk failed");
+ (void)Res;
----------------
avl-llvm wrote:
probably mark it with [[maybe_unused]]?
[[maybe_unused]] bool Res ...
https://github.com/llvm/llvm-project/pull/218072
More information about the llvm-commits
mailing list