|
LLVM 24.0.0git
|
This class discovers DIEs dependencies: marks "live" DIEs, marks DIE locations (whether DIE should be cloned as regular DIE or it should be put into the artificial type unit). More...
#include "DWARFLinker/Parallel/DependencyTracker.h"
Classes | |
| class | LiveRootWorklistItemTy |
| Class keeping live worklist item data. More... | |
| struct | SubtreeDependencyRefTy |
| A root referencing an already-marked subtree, standing in for all of that subtree's dependencies. More... | |
| struct | SubtreeDependencyTy |
| A completeness dependency of a subtree that belongs to whichever root references the subtree, which is not known while the subtree is walked. More... | |
Public Member Functions | |
| DependencyTracker (CompileUnit &CU) | |
| bool | resolveDependenciesAndMarkLiveness (bool InterCUProcessingStarted, std::atomic< bool > &HasNewInterconnectedCUs) |
Recursively walk the DIE tree and look for DIEs to keep. | |
| bool | updateDependenciesCompleteness () |
| Check if dependencies have incompatible placement. | |
| void | verifyKeepChain () |
Recursively walk the DIE tree and check "keepness" and "placement" information. | |
Protected Types | |
| enum class | LiveRootWorklistActionTy : uint8_t { MarkSingleLiveEntry = 0 , MarkSingleTypeEntry , MarkLiveEntryRec , MarkTypeEntryRec , MarkLiveChildrenRec , MarkTypeChildrenRec } |
| enum class | TreeWalkKindTy : uint8_t { MarkTree , RecordSubtreeDeps , RecordNestedSubprogramDeps } |
| What a tree walk does, and for a walk that only records dependencies, which root the dependencies it finds are recorded under. More... | |
| using | RootEntriesListTy = SmallVector<LiveRootWorklistItemTy> |
| using | SubtreeDependenciesTy = SmallVector<SubtreeDependencyTy> |
| using | SubtreeDependenciesKeyTy |
| A subtree paired with the action it is walked with, which selects both the visited children and the action recorded for a reference. | |
Protected Member Functions | |
| bool | isLiveAction (LiveRootWorklistActionTy Action) |
| bool | isTypeAction (LiveRootWorklistActionTy Action) |
| bool | isChildrenAction (LiveRootWorklistActionTy Action) |
| void | collectRootsToKeep (const UnitEntryPairTy &Entry, std::optional< UnitEntryPairTy > ReferencedBy, bool IsLiveParent) |
This function navigates DIEs tree starting from specified Entry. | |
| bool | markCollectedLiveRootsAsKept (bool InterCUProcessingStarted, std::atomic< bool > &HasNewInterconnectedCUs) |
| Examine worklist and mark all 'root DIE's as kept and set "Placement" property. | |
| bool | markDIEEntryAsKeptRec (LiveRootWorklistActionTy Action, const UnitEntryPairTy &RootEntry, const UnitEntryPairTy &Entry, bool InterCUProcessingStarted, std::atomic< bool > &HasNewInterconnectedCUs, TreeWalkKindTy Kind=TreeWalkKindTy::MarkTree) |
| Mark whole DIE tree as kept recursively. | |
| void | recordSubtreeDependencies (LiveRootWorklistActionTy Action, const UnitEntryPairTy &RootEntry, const UnitEntryPairTy &Entry) |
Record that RootEntry references the already-marked subtree Entry, and therefore carries the completeness dependencies of that subtree. | |
| void | materializeSubtreeSummaries () |
| Walk every subtree that a recorded reference stands for, once per subtree and action, and summarize the dependencies it contributes. | |
| bool | applySubtreeSummaries () |
| Apply each summarized subtree's dependencies to every root recorded as referencing it. | |
| bool | demoteIfIncomplete (const UnitEntryPairTy &Root, const DWARFDebugInfoEntry *ReferencedTypeDieEntry, const UnitEntryPairTy &ReferencedBy) |
Demote ReferencedBy to plain DWARF if it may not stay in the type table while the DIE it references through Root is not placed there. | |
| void | markParentsAsKeepingChildren (const UnitEntryPairTy &Entry) |
| Mark parents as keeping children. | |
| void | setPlainDwarfPlacementRec (const UnitEntryPairTy &Entry) |
| Mark whole DIE tree as placed in "PlainDwarf". | |
| bool | maybeAddReferencedRoots (LiveRootWorklistActionTy Action, const UnitEntryPairTy &RootEntry, const UnitEntryPairTy &Entry, bool InterCUProcessingStarted, std::atomic< bool > &HasNewInterconnectedCUs, TreeWalkKindTy Kind=TreeWalkKindTy::MarkTree) |
| Check referenced DIEs and add them into the worklist. | |
| bool | isTypeTableCandidate (const DWARFDebugInfoEntry *DIEEntry) |
| UnitEntryPairTy | getRootForSpecifiedEntry (UnitEntryPairTy Entry) |
| void | addActionToRootEntriesWorkList (LiveRootWorklistActionTy Action, const UnitEntryPairTy &Entry, std::optional< UnitEntryPairTy > ReferencedBy, const DWARFDebugInfoEntry *ReferencedTypeDieEntry=nullptr) |
| Add action item to the work list. | |
Static Protected Member Functions | |
| static bool | recordsDepsOnly (TreeWalkKindTy Kind) |
| static bool | isLiveVariableEntry (const UnitEntryPairTy &Entry, bool IsLiveParent) |
| Returns true if specified variable references live code section. | |
| static bool | isLiveSubprogramEntry (const UnitEntryPairTy &Entry) |
| Returns true if specified subprogram references live code section. | |
Protected Attributes | |
| CompileUnit & | CU |
| RootEntriesListTy | RootEntriesWorkList |
| List of entries which are 'root DIE's. | |
| RootEntriesListTy | Dependencies |
| List of entries dependencies. | |
| DenseMap< SubtreeDependenciesKeyTy, SubtreeDependenciesTy > | SubtreeSummaries |
| Dependency summaries of already-marked subtrees, keyed by subtree and action. | |
| SmallVector< SubtreeDependencyRefTy > | SubtreeDependencyRefs |
| Roots referencing an already-marked subtree. | |
| size_t | MaterializedRefs = 0 |
| Number of leading SubtreeDependencyRefs whose subtree is summarized. | |
| SubtreeDependenciesTy * | CollectedSubtreeDeps = nullptr |
| Where the walk in progress collects the dependencies that belong to the root referencing the walked subtree, or null when no such walk is in progress. | |
| bool | InterCUProcessingWasStarted = false |
| Whether inter-unit references could be resolved during marking. | |
This class discovers DIEs dependencies: marks "live" DIEs, marks DIE locations (whether DIE should be cloned as regular DIE or it should be put into the artificial type unit).
Definition at line 27 of file DependencyTracker.h.
|
protected |
Definition at line 251 of file DependencyTracker.h.
A subtree paired with the action it is walked with, which selects both the visited children and the action recorded for a reference.
Definition at line 265 of file DependencyTracker.h.
|
protected |
Definition at line 261 of file DependencyTracker.h.
|
strongprotected |
Definition at line 61 of file DependencyTracker.h.
|
strongprotected |
What a tree walk does, and for a walk that only records dependencies, which root the dependencies it finds are recorded under.
Only a DW_TAG_subprogram re-anchors that root, so the distinction cannot be recovered by comparing root entries: a walk of a subprogram subtree starts out anchored to the subprogram itself.
| Enumerator | |
|---|---|
| MarkTree | Mark the tree as kept and schedule the roots it references. |
| RecordSubtreeDeps | Do not mark. Record the dependencies as belonging to whichever root references the walked subtree. |
| RecordNestedSubprogramDeps | Do not mark. Record the dependencies as belonging to a subprogram inside the walked subtree, which makes them the same for every referencing root. |
Definition at line 138 of file DependencyTracker.h.
|
inline |
Definition at line 29 of file DependencyTracker.h.
|
protected |
Add action item to the work list.
Definition at line 145 of file DependencyTracker.cpp.
References RootEntriesWorkList.
Referenced by collectRootsToKeep(), markParentsAsKeepingChildren(), and maybeAddReferencedRoots().
|
protected |
Apply each summarized subtree's dependencies to every root recorded as referencing it.
Definition at line 367 of file DependencyTracker.cpp.
References assert(), demoteIfIncomplete(), llvm::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key, llvm::dwarf_linker::parallel::CompileUnit::DIEInfo::needToPlaceInTypeTable(), llvm::Ref, llvm::dwarf_linker::parallel::DependencyTracker::SubtreeDependencyTy::ReferencedTypeDieEntry, llvm::dwarf_linker::parallel::DependencyTracker::SubtreeDependencyTy::Root, SubtreeDependencyRefs, and SubtreeSummaries.
Referenced by updateDependenciesCompleteness().
|
protected |
This function navigates DIEs tree starting from specified Entry.
It puts found 'root DIE' into the worklist. The CollectLiveEntries instructs to collect either live roots(like subprograms having live
DW_AT_low_pc) or otherwise roots which is not live(they need to be collected if they are imported f.e. by DW_TAG_imported_module).
Definition at line 158 of file DependencyTracker.cpp.
References addActionToRootEntriesWorkList(), collectRootsToKeep(), llvm::DWARFDebugInfoEntry::getAbbreviationDeclarationPtr(), isLiveSubprogramEntry(), isLiveVariableEntry(), isNamespaceLikeEntry(), llvm::dwarf::isType(), llvm_unreachable, MarkLiveEntryRec, MarkSingleLiveEntry, MarkSingleTypeEntry, MarkTypeEntryRec, and llvm::dwarf::toUnsigned().
Referenced by collectRootsToKeep(), and resolveDependenciesAndMarkLiveness().
|
protected |
Demote ReferencedBy to plain DWARF if it may not stay in the type table while the DIE it references through Root is not placed there.
Definition at line 340 of file DependencyTracker.cpp.
References llvm::dwarf_linker::parallel::UnitEntryPairTy::CU, llvm::dwarf_linker::parallel::UnitEntryPairTy::DieEntry, llvm::dwarf_linker::parallel::CompileUnit::getDIEInfo(), llvm::dwarf_linker::parallel::CompileUnit::DIEInfo::needToPlaceInTypeTable(), and setPlainDwarfPlacementRec().
Referenced by applySubtreeSummaries(), and updateDependenciesCompleteness().
|
protected |
Entry. Definition at line 932 of file DependencyTracker.cpp.
References isNamespaceLikeEntry().
Referenced by maybeAddReferencedRoots().
|
inlineprotected |
case LiveRootWorklistActionTy::MarkSingleLiveEntry: case LiveRootWorklistActionTy::MarkSingleTypeEntry: return true; } }
/
Definition at line 122 of file DependencyTracker.h.
References MarkLiveChildrenRec, and MarkTypeChildrenRec.
Referenced by markDIEEntryAsKeptRec().
|
inlineprotected |
Definition at line 82 of file DependencyTracker.h.
References MarkLiveChildrenRec, MarkLiveEntryRec, and MarkSingleLiveEntry.
Referenced by markDIEEntryAsKeptRec(), and maybeAddReferencedRoots().
|
staticprotected |
Returns true if specified subprogram references live code section.
Definition at line 1012 of file DependencyTracker.cpp.
References dumpKeptDIE(), llvm::DIE::getTag(), Range, llvm::dwarf::toAddress(), llvm::dwarf::toUnsigned(), UINT64_MAX, and llvm::Verbose.
Referenced by collectRootsToKeep(), and verifyKeepChain().
|
staticprotected |
Returns true if specified variable references live code section.
Definition at line 973 of file DependencyTracker.cpp.
References dumpKeptDIE().
Referenced by collectRootsToKeep().
|
inlineprotected |
Definition at line 95 of file DependencyTracker.h.
References MarkSingleTypeEntry, MarkTypeChildrenRec, and MarkTypeEntryRec.
Referenced by markDIEEntryAsKeptRec(), and maybeAddReferencedRoots().
|
protected |
DIEEntry can possibly be put into the artificial type unit. Definition at line 762 of file DependencyTracker.cpp.
Referenced by markDIEEntryAsKeptRec().
|
protected |
Examine worklist and mark all 'root DIE's as kept and set "Placement" property.
Definition at line 277 of file DependencyTracker.cpp.
References Dependencies, llvm::dwarf_linker::parallel::DependencyTracker::LiveRootWorklistItemTy::getAction(), llvm::dwarf_linker::parallel::DependencyTracker::LiveRootWorklistItemTy::getRootEntry(), llvm::dwarf_linker::parallel::DependencyTracker::LiveRootWorklistItemTy::hasReferencedByOtherEntry(), markDIEEntryAsKeptRec(), and RootEntriesWorkList.
Referenced by resolveDependenciesAndMarkLiveness().
|
protected |
Mark whole DIE tree as kept recursively.
A walk that only records dependencies (see Kind) does not mark the tree. Instead its completeness dependencies are collected (see maybeAddReferencedRoots) so they can be applied to every root referencing the tree.
Definition at line 593 of file DependencyTracker.cpp.
References assert(), llvm::DWARFDebugInfoEntry::getAbbreviationDeclarationPtr(), getFinalPlacementForEntry(), isAlreadyMarked(), isChildrenAction(), isLiveAction(), isTypeAction(), isTypeTableCandidate(), markDIEEntryAsKeptRec(), markParentsAsKeepingChildren(), maybeAddReferencedRoots(), Placement, llvm::dwarf_linker::parallel::CompileUnit::PlainDwarf, RecordNestedSubprogramDeps, recordsDepsOnly(), recordSubtreeDependencies(), RecordSubtreeDeps, and llvm::dwarf_linker::parallel::CompileUnit::TypeTable.
Referenced by markCollectedLiveRootsAsKept(), markDIEEntryAsKeptRec(), and materializeSubtreeSummaries().
|
protected |
Mark parents as keeping children.
Definition at line 459 of file DependencyTracker.cpp.
References addActionToRootEntriesWorkList(), llvm::DWARFDebugInfoEntry::getParentIdx(), isAlreadyMarked(), isNamespaceLikeEntry(), MarkLiveChildrenRec, MarkTypeChildrenRec, llvm::dwarf_linker::parallel::CompileUnit::DIEInfo::needToPlaceInTypeTable(), llvm::dwarf_linker::parallel::CompileUnit::PlainDwarf, and llvm::dwarf_linker::parallel::CompileUnit::TypeTable.
Referenced by markDIEEntryAsKeptRec(), and setPlainDwarfPlacementRec().
|
protected |
Walk every subtree that a recorded reference stands for, once per subtree and action, and summarize the dependencies it contributes.
Called when completeness is checked, so that liveness marking and inter-unit reference resolution have settled and the summary no longer depends on the order the units were processed in.
Definition at line 303 of file DependencyTracker.cpp.
References assert(), CollectedSubtreeDeps, llvm::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key, InterCUProcessingWasStarted, markDIEEntryAsKeptRec(), MaterializedRefs, RecordSubtreeDeps, llvm::Ref, SubtreeDependencyRefs, and SubtreeSummaries.
Referenced by updateDependenciesCompleteness().
|
protected |
Check referenced DIEs and add them into the worklist.
A walk that only records dependencies (see Kind) schedules nothing, so it triggers no reference-following recursion. Each dependency it finds is instead collected for the root that carries it, which is either whichever root references the walked subtree or a subprogram nested inside it. This is used when Entry was already marked by a racing CU/root: the marking and subtree are handled elsewhere, but the referencing root's dependencies must still be recorded so the completeness fixpoint sees a complete, order-independent dependency set.
Definition at line 810 of file DependencyTracker.cpp.
References addActionToRootEntriesWorkList(), assert(), llvm::dwarf_linker::parallel::AvoidResolving, CollectedSubtreeDeps, llvm::Data, Dependencies, llvm::DWARFFormValue::extractValue(), llvm::DWARFFormValue::FC_Reference, llvm::dwarf_linker::parallel::getODRAttributes(), getRootForSpecifiedEntry(), llvm::getULEB128Size(), llvm::is_contained(), llvm::DWARFFormValue::isFormClass(), isLiveAction(), isNamespaceLikeEntry(), isTypeAction(), llvm_unreachable, MarkLiveEntryRec, MarkSingleLiveEntry, MarkSingleTypeEntry, MarkTree, MarkTypeEntryRec, llvm::Offset, RecordNestedSubprogramDeps, recordsDepsOnly(), RecordSubtreeDeps, llvm::dwarf_linker::parallel::Resolve, and llvm::DWARFFormValue::skipValue().
Referenced by markDIEEntryAsKeptRec().
|
inlinestaticprotected |
Definition at line 154 of file DependencyTracker.h.
References MarkTree.
Referenced by markDIEEntryAsKeptRec(), and maybeAddReferencedRoots().
|
protected |
Record that RootEntry references the already-marked subtree Entry, and therefore carries the completeness dependencies of that subtree.
The subtree itself is walked later, by materializeSubtreeSummaries().
Definition at line 297 of file DependencyTracker.cpp.
References SubtreeDependencyRefs.
Referenced by markDIEEntryAsKeptRec().
| bool DependencyTracker::resolveDependenciesAndMarkLiveness | ( | bool | InterCUProcessingStarted, |
| std::atomic< bool > & | HasNewInterconnectedCUs ) |
Recursively walk the DIE tree and look for DIEs to keep.
Store that information in CU's DIEInfo.
This function is the entry point of the DIE selection algorithm. It is expected to walk the DIE tree and(through the mediation of Context.File.Addresses) ask for relocation adjustment value on each DIE that might be a 'root DIE'(f.e. subprograms, variables).
Returns true if all dependencies are correctly discovered. Inter-CU dependencies cannot be discovered if referenced CU is not analyzed yet. If that is the case this method returns false.
Definition at line 121 of file DependencyTracker.cpp.
References assert(), collectRootsToKeep(), InterCUProcessingWasStarted, markCollectedLiveRootsAsKept(), llvm::dwarf_linker::parallel::CompileUnit::PlainDwarf, RootEntriesWorkList, llvm::dwarf_linker::parallel::CompileUnit::DIEInfo::setPlacement(), and SubtreeDependencyRefs.
|
protected |
Mark whole DIE tree as placed in "PlainDwarf".
Definition at line 414 of file DependencyTracker.cpp.
References llvm::DWARFDebugInfoEntry::getAbbreviationDeclarationPtr(), markParentsAsKeepingChildren(), llvm::dwarf_linker::parallel::CompileUnit::PlainDwarf, llvm::dwarf_linker::parallel::CompileUnit::DIEInfo::setPlacement(), and setPlainDwarfPlacementRec().
Referenced by demoteIfIncomplete(), and setPlainDwarfPlacementRec().
| bool DependencyTracker::updateDependenciesCompleteness | ( | ) |
Check if dependencies have incompatible placement.
If that is the case modify placement to be compatible.
Definition at line 394 of file DependencyTracker.cpp.
References applySubtreeSummaries(), assert(), demoteIfIncomplete(), Dependencies, and materializeSubtreeSummaries().
| void DependencyTracker::verifyKeepChain | ( | ) |
Recursively walk the DIE tree and check "keepness" and "placement" information.
Verify the keep chain by looking for DIEs that are kept but who's parent isn't.
It is an error if parent node does not have "keep" flag, while child has one. It is an error if parent node has "TypeTable" placement while child has "PlainDwarf" placement. This function dump error at stderr in that case.
Definition at line 29 of file DependencyTracker.cpp.
References assert(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::DWARFDie::children(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::WithColor::error(), llvm::errs(), llvm::formatv(), llvm::DWARFDie::getDebugInfoEntry(), isLiveSubprogramEntry(), llvm::DWARFDie::isValid(), llvm::dwarf_linker::parallel::CompileUnit::DIEInfo::needToKeepInPlainDwarf(), llvm::dwarf_linker::parallel::CompileUnit::DIEInfo::needToPlaceInTypeTable(), llvm::SmallVectorTemplateBase< T, bool >::pop_back(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::report_fatal_error(), and llvm::reverse().
|
protected |
Where the walk in progress collects the dependencies that belong to the root referencing the walked subtree, or null when no such walk is in progress.
Scoped by materializeSubtreeSummaries().
Definition at line 402 of file DependencyTracker.h.
Referenced by materializeSubtreeSummaries(), and maybeAddReferencedRoots().
|
protected |
Definition at line 381 of file DependencyTracker.h.
|
protected |
List of entries dependencies.
Definition at line 387 of file DependencyTracker.h.
Referenced by markCollectedLiveRootsAsKept(), maybeAddReferencedRoots(), and updateDependenciesCompleteness().
|
protected |
Whether inter-unit references could be resolved during marking.
Reused when the recorded subtrees are walked, which happens outside of marking.
Definition at line 406 of file DependencyTracker.h.
Referenced by materializeSubtreeSummaries(), and resolveDependenciesAndMarkLiveness().
|
protected |
Number of leading SubtreeDependencyRefs whose subtree is summarized.
Definition at line 397 of file DependencyTracker.h.
Referenced by materializeSubtreeSummaries().
|
protected |
List of entries which are 'root DIE's.
Definition at line 384 of file DependencyTracker.h.
Referenced by addActionToRootEntriesWorkList(), markCollectedLiveRootsAsKept(), and resolveDependenciesAndMarkLiveness().
|
protected |
Roots referencing an already-marked subtree.
Definition at line 394 of file DependencyTracker.h.
Referenced by applySubtreeSummaries(), materializeSubtreeSummaries(), recordSubtreeDependencies(), and resolveDependenciesAndMarkLiveness().
|
protected |
Dependency summaries of already-marked subtrees, keyed by subtree and action.
Filled once, when completeness is first checked.
Definition at line 391 of file DependencyTracker.h.
Referenced by applySubtreeSummaries(), and materializeSubtreeSummaries().