|
LLVM 24.0.0git
|
Keeps track of data associated with one object during linking. More...
#include "DWARFLinker/Parallel/DWARFLinkerImpl.h"
Classes | |
| struct | CIELocation |
| Section + local offset of a .debug_frame CIE that has been (or will be) emitted by some LinkContext. More... | |
| struct | FrameScanResult |
| Result of scanning one LinkContext's input .debug_frame. More... | |
Public Types | |
| using | UnitListTy = SmallVector<std::unique_ptr<CompileUnit>> |
| using | CIERegistry = StringMap<CIELocation> |
| Linker-wide registry for .debug_frame CIEs. | |
Public Member Functions | |
| LinkContext (LinkingGlobalData &GlobalData, DWARFFile &File, uint64_t ObjFileIdx, StringMap< uint64_t > &ClangModules, std::atomic< size_t > &UniqueUnitID) | |
| std::pair< bool, bool > | isClangModuleRef (const DWARFDie &CUDie, std::string &PCMFile, unsigned Indent, bool Quiet) |
Check whether specified CUDie is a Clang module reference. | |
| bool | registerModuleReference (const DWARFDie &CUDie, ObjFileLoaderTy Loader, CompileUnitHandlerTy OnCUDieLoaded, unsigned Indent=0) |
| If this compile unit is really a skeleton CU that points to a clang module, register it in ClangModules and return true. | |
| Error | loadClangModule (ObjFileLoaderTy Loader, const DWARFDie &CUDie, const std::string &PCMFile, CompileUnitHandlerTy OnCUDieLoaded, unsigned Indent=0) |
| Recursively add the debug info in this clang module .pcm file (and all the modules imported by it in a bottom-up fashion) to ModuleUnits. | |
| uint64_t | getInputDebugInfoSize () const |
| Computes the total size of the debug info. | |
| Error | link (TypeUnit *ArtificialTypeUnit) |
| Link compile units for this context. | |
| void | linkSingleCompileUnit (CompileUnit &CU, TypeUnit *ArtificialTypeUnit, enum CompileUnit::Stage DoUntilStage=CompileUnit::Stage::Cleaned) |
| Link specified compile unit until specified stage. | |
| Error | emitInvariantSections () |
| Emit invariant sections. | |
| Error | unloadInput () |
| Unload the input DWARFContext after scanning the input .debug_frame into FrameScan. | |
| Error | scanFrameData () |
| Parse this context's input .debug_frame into FrameScan. | |
| void | registerCIEs (CIERegistry &CIEs) |
| Register this context's CIEs with the linker-wide registry. | |
| Error | emitDebugFrame (const CIERegistry &CIEs) |
| Emit this context's .debug_frame section. | |
| void | emitFDE (uint32_t CIEOffset, uint32_t AddrSize, uint64_t Address, StringRef FDEBytes, SectionDescriptor &Section) |
| Emit FDE record. | |
| Public Member Functions inherited from llvm::dwarf_linker::parallel::OutputSections | |
| OutputSections (LinkingGlobalData &GlobalData) | |
| void | setOutputFormat (dwarf::FormParams Format, llvm::endianness Endianness) |
| Sets output format for all keeping sections. | |
| const SectionDescriptor & | getSectionDescriptor (DebugSectionKind SectionKind) const |
Returns descriptor for the specified section of SectionKind. | |
| SectionDescriptor & | getSectionDescriptor (DebugSectionKind SectionKind) |
Returns descriptor for the specified section of SectionKind. | |
| std::optional< const SectionDescriptor * > | tryGetSectionDescriptor (DebugSectionKind SectionKind) const |
Returns descriptor for the specified section of SectionKind. | |
| std::optional< SectionDescriptor * > | tryGetSectionDescriptor (DebugSectionKind SectionKind) |
Returns descriptor for the specified section of SectionKind. | |
| SectionDescriptor & | getOrCreateSectionDescriptor (DebugSectionKind SectionKind) |
Returns descriptor for the specified section of SectionKind. | |
| void | eraseSections () |
| Erases data of all sections. | |
| void | forEach (function_ref< void(SectionDescriptor &)> Handler) |
Enumerate all sections and call Handler for each. | |
| void | forEach (function_ref< void(std::shared_ptr< SectionDescriptor > Section)> Handler) |
Enumerate all sections and call Handler for each. | |
| void | assignSectionsOffsetAndAccumulateSize (std::array< uint64_t, SectionKindsNum > &SectionSizesAccumulator) |
Enumerate all sections, for each section set current offset (kept by SectionSizesAccumulator), update current offset with section length. | |
| void | applyPatches (SectionDescriptor &Section, StringEntryToDwarfStringPoolEntryMap &DebugStrStrings, StringEntryToDwarfStringPoolEntryMap &DebugLineStrStrings, TypeUnit *TypeUnitPtr) |
| Enumerate all sections, for each section apply all section patches. | |
| llvm::endianness | getEndianness () const |
| Endiannes for the sections. | |
| uint16_t | getVersion () const |
| Return DWARF version. | |
| uint16_t | getDebugInfoHeaderSize () const |
| Return size of header of debug_info table. | |
| uint16_t | getDebugAddrHeaderSize () const |
| Return size of header of debug_ table. | |
| uint16_t | getDebugStrOffsetsHeaderSize () const |
| Return size of header of debug_str_offsets table. | |
| const dwarf::FormParams & | getFormParams () const |
| Return size of address. | |
Public Attributes | |
| DWARFFile & | InputDWARFFile |
| Object file descriptor. | |
| UnitListTy | CompileUnits |
| Set of Compilation Units(may be accessed asynchroniously for reading). | |
| UnitListTy | ModulesCompileUnits |
| Set of Compile Units for modules. | |
| uint64_t | ObjectFileIdx = 0 |
| Index of this object file in the link order (used for deterministic type DIE allocation). | |
| uint64_t | OriginalDebugInfoSize = 0 |
| Size of Debug info before optimizing. | |
| bool | InterCUProcessingStarted = false |
| Flag indicating that all inter-connected units are loaded and the dwarf linking process for these units is started. | |
| StringMap< uint64_t > & | ClangModules |
| std::atomic< bool > | HasNewInterconnectedCUs = {false} |
| Flag indicating that new inter-connected compilation units were discovered. | |
| std::atomic< bool > | HasNewGlobalDependency = {false} |
| std::atomic< size_t > & | UniqueUnitID |
| Counter for compile units ID. | |
| std::unique_ptr< FrameScanResult > | FrameScan |
| std::function< CompileUnit *(uint64_t)> | getUnitForOffset |
Additional Inherited Members | |
| Protected Types inherited from llvm::dwarf_linker::parallel::OutputSections | |
| using | SectionsSetTy |
| All keeping sections. | |
| Protected Attributes inherited from llvm::dwarf_linker::parallel::OutputSections | |
| LinkingGlobalData & | GlobalData |
| dwarf::FormParams | Format = {4, 4, dwarf::DWARF32} |
| Format for sections. | |
| llvm::endianness | Endianness = llvm::endianness::native |
| Endiannes for sections. | |
| SectionsSetTy | SectionDescriptors |
Keeps track of data associated with one object during linking.
i.e. source file descriptor, compilation units, output data for compilation units common tables.
Definition at line 158 of file DWARFLinkerImpl.h.
| using llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::CIERegistry = StringMap<CIELocation> |
Linker-wide registry for .debug_frame CIEs.
The key is the raw CIE bytes. Populated by a serial pass over ObjectContexts (so ownership is deterministic — first LinkContext wins) and then consumed read-only by a parallel emission pass that writes each context's .debug_frame section. SectionDescriptor pointers remain valid until linking completes because they live in std::map-held shared_ptrs.
Definition at line 252 of file DWARFLinkerImpl.h.
| using llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::UnitListTy = SmallVector<std::unique_ptr<CompileUnit>> |
Definition at line 159 of file DWARFLinkerImpl.h.
| DWARFLinkerImpl::LinkContext::LinkContext | ( | LinkingGlobalData & | GlobalData, |
| DWARFFile & | File, | ||
| uint64_t | ObjFileIdx, | ||
| StringMap< uint64_t > & | ClangModules, | ||
| std::atomic< size_t > & | UniqueUnitID ) |
Definition at line 29 of file DWARFLinkerImpl.cpp.
References ClangModules, llvm::dwarf_linker::parallel::OutputSections::GlobalData, InputDWARFFile, ObjectFileIdx, llvm::dwarf_linker::parallel::OutputSections::OutputSections(), and UniqueUnitID.
| Error DWARFLinkerImpl::LinkContext::emitDebugFrame | ( | const CIERegistry & | CIEs | ) |
Emit this context's .debug_frame section.
Safe to call in parallel across contexts because each call writes only to its own SectionDescriptor.
Definition at line 894 of file DWARFLinkerImpl.cpp.
References llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::FrameScanResult::FDE::Address, assert(), llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::FrameScanResult::FDE::CIEBytes, llvm::createFileError(), llvm::createStringError(), llvm::dwarf_linker::DebugFrame, emitFDE(), llvm::StringMap< ValueTy, AllocatorTy >::end(), llvm::StringMap< ValueTy, AllocatorTy >::find(), llvm::dwarf::FormatString(), FP, FrameScan, llvm::dwarf_linker::parallel::SectionDescriptorBase::getFormParams(), llvm::dwarf_linker::parallel::OutputSections::getSectionDescriptor(), InputDWARFFile, llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::FrameScanResult::FDE::Instructions, llvm::dwarf_linker::parallel::SectionDescriptor::OS, llvm::Error::success(), llvm::raw_ostream::tell(), and llvm::Twine::utohexstr().
| void DWARFLinkerImpl::LinkContext::emitFDE | ( | uint32_t | CIEOffset, |
| uint32_t | AddrSize, | ||
| uint64_t | Address, | ||
| StringRef | FDEBytes, | ||
| SectionDescriptor & | Section ) |
Emit FDE record.
Emit a FDE into the debug_frame section.
FDEBytes contains the FDE data without the length, CIE offset and address which will be replaced with the parameter values.
Definition at line 950 of file DWARFLinkerImpl.cpp.
References llvm::Address, llvm::StringRef::data(), and llvm::StringRef::size().
Referenced by emitDebugFrame().
| Error DWARFLinkerImpl::LinkContext::emitInvariantSections | ( | ) |
Emit invariant sections.
Definition at line 745 of file DWARFLinkerImpl.cpp.
References llvm::dwarf_linker::DebugAddr, llvm::dwarf_linker::DebugARanges, llvm::dwarf_linker::DebugFrame, llvm::dwarf_linker::DebugLoc, llvm::dwarf_linker::DebugLocLists, llvm::dwarf_linker::DebugRange, llvm::dwarf_linker::DebugRngLists, llvm::dwarf_linker::parallel::OutputSections::getOrCreateSectionDescriptor(), llvm::dwarf_linker::parallel::OutputSections::GlobalData, InputDWARFFile, and llvm::Error::success().
Referenced by link().
|
inline |
Computes the total size of the debug info.
Definition at line 224 of file DWARFLinkerImpl.h.
References InputDWARFFile, Size, and uint64_t.
Referenced by link().
| std::pair< bool, bool > DWARFLinkerImpl::LinkContext::isClangModuleRef | ( | const DWARFDie & | CUDie, |
| std::string & | PCMFile, | ||
| unsigned | Indent, | ||
| bool | Quiet ) |
Check whether specified CUDie is a Clang module reference.
if Quiet is false then display error messages.
Definition at line 331 of file DWARFLinkerImpl.cpp.
References ClangModules, llvm::DWARFDie::find(), llvm::getDwoId(), llvm::dwarf_linker::parallel::OutputSections::GlobalData, llvm::raw_ostream::indent(), InputDWARFFile, llvm::outs(), llvm::Quiet, and llvm::dwarf::toString().
Referenced by link(), and registerModuleReference().
Link compile units for this context.
Definition at line 481 of file DWARFLinkerImpl.cpp.
References llvm::dwarf_linker::parallel::DWARFLinkerImpl::ArtificialTypeUnit, assert(), llvm::dwarf_linker::parallel::CompileUnit::Cleaned, llvm::dwarf_linker::parallel::CompileUnit::Cloned, CompileUnits, emitInvariantSections(), llvm::dwarf_linker::finiteLoop(), llvm::dwarf_linker::parallel::OutputSections::getEndianness(), getInputDebugInfoSize(), llvm::getPCMFile(), getUnitForOffset, llvm::dwarf_linker::parallel::OutputSections::GlobalData, HasNewGlobalDependency, HasNewInterconnectedCUs, InputDWARFFile, InterCUProcessingStarted, isClangModuleRef(), linkSingleCompileUnit(), llvm::dwarf_linker::parallel::CompileUnit::LivenessAnalysisDone, llvm::dwarf_linker::parallel::CompileUnit::Loaded, llvm::Mod, ModulesCompileUnits, ObjectFileIdx, OriginalDebugInfoSize, llvm::outs(), llvm::parallelForEach(), llvm::dwarf_linker::parallel::CompileUnit::PatchesUpdated, llvm::Error::success(), llvm::dwarf_linker::parallel::CompileUnit::TypeNamesAssigned, UniqueUnitID, and llvm::dwarf_linker::parallel::CompileUnit::UpdateDependenciesCompleteness.
| void DWARFLinkerImpl::LinkContext::linkSingleCompileUnit | ( | CompileUnit & | CU, |
| TypeUnit * | ArtificialTypeUnit, | ||
| enum CompileUnit::Stage | DoUntilStage = CompileUnit::Stage::Cleaned ) |
Link specified compile unit until specified stage.
Definition at line 627 of file DWARFLinkerImpl.cpp.
References llvm::dwarf_linker::parallel::DWARFLinkerImpl::ArtificialTypeUnit, assert(), llvm::dwarf_linker::parallel::CompileUnit::Cleaned, llvm::dwarf_linker::parallel::CompileUnit::Cloned, llvm::dwarf_linker::parallel::CompileUnit::CreatedNotLoaded, llvm::dwarf_linker::finiteLoop(), llvm::dwarf_linker::parallel::OutputSections::GlobalData, HasNewGlobalDependency, HasNewInterconnectedCUs, InterCUProcessingStarted, llvm::dwarf_linker::parallel::CompileUnit::LivenessAnalysisDone, llvm::dwarf_linker::parallel::CompileUnit::Loaded, llvm::dwarf_linker::parallel::CompileUnit::PatchesUpdated, registerModuleReference(), llvm::dwarf_linker::parallel::CompileUnit::Skipped, llvm::dwarf_linker::parallel::CompileUnit::TypeNamesAssigned, and llvm::dwarf_linker::parallel::CompileUnit::UpdateDependenciesCompleteness.
Referenced by link().
| Error DWARFLinkerImpl::LinkContext::loadClangModule | ( | ObjFileLoaderTy | Loader, |
| const DWARFDie & | CUDie, | ||
| const std::string & | PCMFile, | ||
| CompileUnitHandlerTy | OnCUDieLoaded, | ||
| unsigned | Indent = 0 ) |
Recursively add the debug info in this clang module .pcm file (and all the modules imported by it in a bottom-up fashion) to ModuleUnits.
Using a SmallString<0> because loadClangModule() is recursive.
Definition at line 406 of file DWARFLinkerImpl.cpp.
References llvm::sys::path::append(), ClangModules, llvm::DWARFDie::find(), llvm::getDwoId(), llvm::dwarf_linker::parallel::OutputSections::getEndianness(), getUnitForOffset, llvm::dwarf_linker::parallel::OutputSections::GlobalData, llvm::inconvertibleErrorCode(), InputDWARFFile, llvm::sys::path::is_relative(), llvm::make_error(), ModulesCompileUnits, registerModuleReference(), llvm::resolveRelativeObjectPath(), llvm::Error::success(), llvm::dwarf::toString(), and UniqueUnitID.
Referenced by registerModuleReference().
| void DWARFLinkerImpl::LinkContext::registerCIEs | ( | CIERegistry & | CIEs | ) |
Register this context's CIEs with the linker-wide registry.
Definition at line 878 of file DWARFLinkerImpl.cpp.
References assert(), llvm::dwarf_linker::DebugFrame, FrameScan, llvm::dwarf_linker::parallel::OutputSections::getOrCreateSectionDescriptor(), llvm::StringRef::size(), and llvm::StringMap< ValueTy, AllocatorTy >::try_emplace().
| bool DWARFLinkerImpl::LinkContext::registerModuleReference | ( | const DWARFDie & | CUDie, |
| ObjFileLoaderTy | Loader, | ||
| CompileUnitHandlerTy | OnCUDieLoaded, | ||
| unsigned | Indent = 0 ) |
If this compile unit is really a skeleton CU that points to a clang module, register it in ClangModules and return true.
A skeleton CU is a CU without children, a DW_AT_gnu_dwo_name pointing to the module, and a DW_AT_gnu_dwo_id with the module hash.
Definition at line 377 of file DWARFLinkerImpl.cpp.
References ClangModules, llvm::consumeError(), llvm::getDwoId(), llvm::getPCMFile(), llvm::dwarf_linker::parallel::OutputSections::GlobalData, isClangModuleRef(), loadClangModule(), and llvm::outs().
Referenced by linkSingleCompileUnit(), and loadClangModule().
| Error DWARFLinkerImpl::LinkContext::scanFrameData | ( | ) |
Parse this context's input .debug_frame into FrameScan.
Deferred CIE/FDE emission happens later against the scan result alone.
Definition at line 767 of file DWARFLinkerImpl.cpp.
References CompileUnits, llvm::createFileError(), llvm::createStringError(), llvm::Data, llvm::DWARFSection::Data, llvm::StringRef::empty(), FrameScan, llvm::DWARFObject::getAddressSize(), llvm::DWARFObject::getFrameSection(), llvm::AddressRangesBase< T >::getRangeThatContains(), llvm::dwarf_linker::parallel::OutputSections::GlobalData, InputDWARFFile, llvm::AddressRangesMap::insert(), llvm::detail::DenseSetImpl< ValueT, MapTy >::insert(), llvm::DWARFObject::isLittleEndian(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::lookup(), Range, llvm::StringRef::size(), llvm::StringRef::substr(), and llvm::Error::success().
Referenced by unloadInput().
| Error DWARFLinkerImpl::LinkContext::unloadInput | ( | ) |
Unload the input DWARFContext after scanning the input .debug_frame into FrameScan.
Definition at line 938 of file DWARFLinkerImpl.cpp.
References InputDWARFFile, and scanFrameData().
Definition at line 181 of file DWARFLinkerImpl.h.
Referenced by isClangModuleRef(), LinkContext(), loadClangModule(), and registerModuleReference().
| UnitListTy llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::CompileUnits |
Set of Compilation Units(may be accessed asynchroniously for reading).
Definition at line 165 of file DWARFLinkerImpl.h.
Referenced by link(), and scanFrameData().
| std::unique_ptr<FrameScanResult> llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::FrameScan |
Definition at line 287 of file DWARFLinkerImpl.h.
Referenced by emitDebugFrame(), registerCIEs(), and scanFrameData().
| std::function<CompileUnit *(uint64_t)> llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::getUnitForOffset |
Definition at line 320 of file DWARFLinkerImpl.h.
Referenced by link(), and loadClangModule().
| std::atomic<bool> llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::HasNewGlobalDependency = {false} |
Definition at line 188 of file DWARFLinkerImpl.h.
Referenced by link(), and linkSingleCompileUnit().
| std::atomic<bool> llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::HasNewInterconnectedCUs = {false} |
Flag indicating that new inter-connected compilation units were discovered.
It is used for restarting units processing if new inter-connected units were found.
Definition at line 186 of file DWARFLinkerImpl.h.
Referenced by link(), and linkSingleCompileUnit().
| DWARFFile& llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::InputDWARFFile |
Object file descriptor.
Definition at line 162 of file DWARFLinkerImpl.h.
Referenced by emitDebugFrame(), emitInvariantSections(), getInputDebugInfoSize(), isClangModuleRef(), link(), LinkContext(), loadClangModule(), scanFrameData(), and unloadInput().
| bool llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::InterCUProcessingStarted = false |
Flag indicating that all inter-connected units are loaded and the dwarf linking process for these units is started.
Definition at line 179 of file DWARFLinkerImpl.h.
Referenced by link(), and linkSingleCompileUnit().
| UnitListTy llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::ModulesCompileUnits |
Set of Compile Units for modules.
Definition at line 168 of file DWARFLinkerImpl.h.
Referenced by link(), and loadClangModule().
| uint64_t llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::ObjectFileIdx = 0 |
Index of this object file in the link order (used for deterministic type DIE allocation).
Definition at line 172 of file DWARFLinkerImpl.h.
Referenced by link(), and LinkContext().
| uint64_t llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::OriginalDebugInfoSize = 0 |
Size of Debug info before optimizing.
Definition at line 175 of file DWARFLinkerImpl.h.
Referenced by link().
| std::atomic<size_t>& llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::UniqueUnitID |
Counter for compile units ID.
Definition at line 191 of file DWARFLinkerImpl.h.
Referenced by link(), LinkContext(), and loadClangModule().