LLVM 23.0.0git
llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext Struct Reference

Keeps track of data associated with one object during linking. More...

#include "DWARFLinker/Parallel/DWARFLinkerImpl.h"

Inheritance diagram for llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext:
[legend]

Classes

struct  RefModuleUnit
 Keep information for referenced clang module: already loaded DWARF info of the clang module and a CompileUnit of the module. More...

Public Types

using UnitListTy = SmallVector<std::unique_ptr<CompileUnit>>
using ModuleUnitListTy = SmallVector<RefModuleUnit>

Public Member Functions

 LinkContext (LinkingGlobalData &GlobalData, DWARFFile &File, uint64_t ObjFileIdx, StringMap< uint64_t > &ClangModules, std::atomic< size_t > &UniqueUnitID)
std::pair< bool, boolisClangModuleRef (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.
void addModulesCompileUnit (RefModuleUnit &&Unit)
 Add Compile Unit corresponding to the module.
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 cloneAndEmitDebugFrame ()
 Clone and emit .debug_frame.
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 SectionDescriptorgetSectionDescriptor (DebugSectionKind SectionKind) const
 Returns descriptor for the specified section of SectionKind.
SectionDescriptorgetSectionDescriptor (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.
SectionDescriptorgetOrCreateSectionDescriptor (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::FormParamsgetFormParams () const
 Return size of address.

Public Attributes

DWARFFileInputDWARFFile
 Object file descriptor.
UnitListTy CompileUnits
 Set of Compilation Units(may be accessed asynchroniously for reading).
ModuleUnitListTy 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< boolHasNewInterconnectedCUs = {false}
 Flag indicating that new inter-connected compilation units were discovered.
std::atomic< boolHasNewGlobalDependency = {false}
std::atomic< size_t > & UniqueUnitID
 Counter for compile units ID.
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
LinkingGlobalDataGlobalData
dwarf::FormParams Format = {4, 4, dwarf::DWARF32}
 Format for sections.
llvm::endianness Endianness = llvm::endianness::native
 Endiannes for sections.
SectionsSetTy SectionDescriptors

Detailed Description

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 154 of file DWARFLinkerImpl.h.

Member Typedef Documentation

◆ ModuleUnitListTy

◆ UnitListTy

Constructor & Destructor Documentation

◆ LinkContext()

DWARFLinkerImpl::LinkContext::LinkContext ( LinkingGlobalData & GlobalData,
DWARFFile & File,
uint64_t ObjFileIdx,
StringMap< uint64_t > & ClangModules,
std::atomic< size_t > & UniqueUnitID )

Member Function Documentation

◆ addModulesCompileUnit()

void DWARFLinkerImpl::LinkContext::addModulesCompileUnit ( LinkContext::RefModuleUnit && Unit)

Add Compile Unit corresponding to the module.

Definition at line 57 of file DWARFLinkerImpl.cpp.

References ModulesCompileUnits.

◆ cloneAndEmitDebugFrame()

◆ emitFDE()

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 852 of file DWARFLinkerImpl.cpp.

References llvm::Address, llvm::StringRef::data(), and llvm::StringRef::size().

Referenced by cloneAndEmitDebugFrame().

◆ emitInvariantSections()

◆ getInputDebugInfoSize()

uint64_t llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::getInputDebugInfoSize ( ) const
inline

Computes the total size of the debug info.

Definition at line 235 of file DWARFLinkerImpl.h.

References InputDWARFFile, and Size.

Referenced by link().

◆ isClangModuleRef()

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.

Returns
first == true if CUDie is a Clang module reference. second == true if module is already loaded.

Definition at line 297 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()

◆ linkSingleCompileUnit()

◆ loadClangModule()

Error DWARFLinkerImpl::LinkContext::loadClangModule ( ObjFileLoaderTy Loader,
const DWARFDie & CUDie,
const std::string & PCMFile,
CompileUnitHandlerTy OnCUDieLoaded,
unsigned Indent = 0 )

◆ registerModuleReference()

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 343 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().

Member Data Documentation

◆ ClangModules

StringMap<uint64_t>& llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::ClangModules

◆ CompileUnits

UnitListTy llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::CompileUnits

Set of Compilation Units(may be accessed asynchroniously for reading).

Definition at line 173 of file DWARFLinkerImpl.h.

Referenced by cloneAndEmitDebugFrame(), and link().

◆ getUnitForOffset

std::function<CompileUnit *(uint64_t)> llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::getUnitForOffset
Initial value:
=
[](uint64_t LHS, const std::unique_ptr<CompileUnit> &RHS) {
return LHS < RHS->getOrigUnit().getNextUnitOffset();
});
return CU != CompileUnits.end() ? CU->get() : nullptr;
}
Value * RHS
Value * LHS
Stores all information related to a compile unit, be it in its original instance of the object file o...
@ Offset
Definition DWP.cpp:557
auto upper_bound(R &&Range, T &&Value)
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
Definition STLExtras.h:2064
UnitListTy CompileUnits
Set of Compilation Units(may be accessed asynchroniously for reading).

Definition at line 265 of file DWARFLinkerImpl.h.

Referenced by link(), and loadClangModule().

◆ HasNewGlobalDependency

std::atomic<bool> llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::HasNewGlobalDependency = {false}

Definition at line 196 of file DWARFLinkerImpl.h.

Referenced by link(), and linkSingleCompileUnit().

◆ HasNewInterconnectedCUs

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 194 of file DWARFLinkerImpl.h.

Referenced by link(), and linkSingleCompileUnit().

◆ InputDWARFFile

DWARFFile& llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::InputDWARFFile

◆ InterCUProcessingStarted

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 187 of file DWARFLinkerImpl.h.

Referenced by link(), and linkSingleCompileUnit().

◆ ModulesCompileUnits

ModuleUnitListTy llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::ModulesCompileUnits

Set of Compile Units for modules.

Definition at line 176 of file DWARFLinkerImpl.h.

Referenced by addModulesCompileUnit(), link(), and loadClangModule().

◆ ObjectFileIdx

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 180 of file DWARFLinkerImpl.h.

Referenced by link(), and LinkContext().

◆ OriginalDebugInfoSize

uint64_t llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::OriginalDebugInfoSize = 0

Size of Debug info before optimizing.

Definition at line 183 of file DWARFLinkerImpl.h.

Referenced by link().

◆ UniqueUnitID

std::atomic<size_t>& llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::UniqueUnitID

Counter for compile units ID.

Definition at line 199 of file DWARFLinkerImpl.h.

Referenced by link(), LinkContext(), and loadClangModule().


The documentation for this struct was generated from the following files: