LLVM 24.0.0git
llvm::dwarf_linker::parallel::DwarfUnit Class Referenceabstract

Base class for all Dwarf units(Compile unit/Type table unit). More...

#include "DWARFLinker/Parallel/DWARFLinkerUnit.h"

Inheritance diagram for llvm::dwarf_linker::parallel::DwarfUnit:
[legend]

Classes

struct  AccelInfo
 This structure keeps fields which would be used for creating accelerator table. More...

Public Types

enum class  AccelType : uint8_t {
  AccelType::None , AccelType::Name , AccelType::Namespace , AccelType::ObjC ,
  AccelType::Type
}

Public Member Functions

virtual ~DwarfUnit ()=default
 DwarfUnit (LinkingGlobalData &GlobalData, unsigned ID, StringRef ClangModuleName)
unsigned getUniqueID () const
 Unique id of the unit.
uint64_t getUnitSize () const
 Returns size of this(newly generated) compile unit.
StringRef getUnitName () const
 Returns this unit name.
StringRef getSysRoot ()
 Return the DW_AT_LLVM_sysroot of the compile unit or an empty StringRef.
bool isClangModule () const
 Return true if this compile unit is from Clang module.
const std::string & getClangModuleName () const
 Return Clang module name;.
LinkingGlobalData & getGlobalData ()
 Return global data.
bool isInterconnectedCU () const
 Returns true if unit is inter-connected(it references/referenced by other unit).
void setInterconnectedCU ()
 Mark this unit as inter-connected(it references/referenced by other unit).
void assignAbbrev (DIEAbbrev &Abbrev)
 Adds Abbrev into unit`s abbreviation table.
const std::vector< std::unique_ptr< DIEAbbrev > > & getAbbreviations () const
 Returns abbreviations for this compile unit.
DIE * getOutUnitDIE ()
 Returns output unit DIE.
void setOutUnitDIE (DIE *UnitDie)
 Set output unit DIE.
dwarf::Tag getTag () const
 Returns unit DWARF tag.
Error emitAbbreviations ()
Error emitDebugInfo (const Triple &TargetTriple)
 Emit .debug_info section for unit DIEs.
Error emitDebugLine (const Triple &TargetTriple, const DWARFDebugLine::LineTable &OutLineTable, ArrayRef< uint64_t > OrigRowIndices={}, DenseMap< uint64_t, uint64_t > *RowIndexToSeqStartOffset=nullptr)
 Emit .debug_line section.
Error emitDebugStringOffsetSection ()
 Emit the .debug_str_offsets section for current unit.
void warn (const Twine &Warning)
void error (const Twine &Err)
void emitPubAccelerators ()
 Emit .debug_pubnames and .debug_pubtypes for Unit.
virtual void forEachAcceleratorRecord (function_ref< void(AccelInfo &)> Handler)=0
 Enumerates accelerator data.
virtual uint64_t getDebugStrIndex (const StringEntry *String)
 Returns index(inside .debug_str_offsets) of specified string.
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.

Protected Types

using FileNamesCache
 Cache for file names for this unit.
Protected Types inherited from llvm::dwarf_linker::parallel::OutputSections
using SectionsSetTy
 All keeping sections.

Protected Member Functions

void emitDwarfAbbrevEntry (const DIEAbbrev &Abbrev, SectionDescriptor &AbbrevSection)
 Emit single abbreviation entry.
std::optional< uint64_t > emitPubAcceleratorEntry (SectionDescriptor &OutSection, const AccelInfo &Info, std::optional< uint64_t > LengthOffset)
 Emit single pubnames/pubtypes accelerator entry.

Protected Attributes

unsigned ID = 0
 Unique ID for the unit.
std::string UnitName
 The name of this unit.
std::string SysRoot
 The DW_AT_LLVM_sysroot of this unit.
std::string ClangModuleName
 If this is a Clang module, this holds the module's name.
uint64_t UnitSize = 0
dwarf::Tag UnitTag = dwarf::DW_TAG_null
 DWARF unit tag.
std::atomic< bool > IsInterconnectedCU = {false}
 true if current unit references_to/is_referenced by other unit.
FoldingSet< DIEAbbrev > AbbreviationsSet
 FoldingSet that uniques the abbreviations.
std::vector< std::unique_ptr< DIEAbbrev > > Abbreviations
 Storage for the unique Abbreviations.
DIE * OutUnitDIE = nullptr
 Output unit DIE.
FileNamesCache FileNames
std::mutex FileNamesMutex
 Guards FileNames.
IndexedValuesMap< const StringEntry * > DebugStringIndexMap
 Maps a string into the index inside .debug_str_offsets section.
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

Detailed Description

Base class for all Dwarf units(Compile unit/Type table unit).

Definition at line 31 of file DWARFLinkerUnit.h.

Member Typedef Documentation

◆ FileNamesCache

Initial value:

Cache for file names for this unit.

Entries are heap-allocated so the StringRefs handed out by getDirAndFilenameFromLineTable keep pointing at valid storage when a later insertion rehashes the map.

Definition at line 221 of file DWARFLinkerUnit.h.

Constructor & Destructor Documentation

◆ ~DwarfUnit()

virtual llvm::dwarf_linker::parallel::DwarfUnit::~DwarfUnit ( )
virtualdefault

◆ DwarfUnit()

Member Function Documentation

◆ assignAbbrev()

void DwarfUnit::assignAbbrev ( DIEAbbrev & Abbrev)

◆ emitDwarfAbbrevEntry()

void DwarfUnit::emitDwarfAbbrevEntry ( const DIEAbbrev & Abbrev,
SectionDescriptor & AbbrevSection )
protected

◆ emitPubAcceleratorEntry()

◆ getAbbreviations()

const std::vector< std::unique_ptr< DIEAbbrev > > & llvm::dwarf_linker::parallel::DwarfUnit::getAbbreviations ( ) const
inline

Returns abbreviations for this compile unit.

Definition at line 71 of file DWARFLinkerUnit.h.

References Abbreviations.

Referenced by emitAbbreviations().

◆ getClangModuleName()

const std::string & llvm::dwarf_linker::parallel::DwarfUnit::getClangModuleName ( ) const
inline

Return Clang module name;.

Definition at line 55 of file DWARFLinkerUnit.h.

References ClangModuleName.

Referenced by llvm::dwarf_linker::parallel::CompileUnit::noteModuleAnchors().

◆ getDebugStrIndex()

virtual uint64_t llvm::dwarf_linker::parallel::DwarfUnit::getDebugStrIndex ( const StringEntry * String)
inlinevirtual

Returns index(inside .debug_str_offsets) of specified string.

Reimplemented in llvm::dwarf_linker::parallel::TypeUnit.

Definition at line 175 of file DWARFLinkerUnit.h.

References DebugStringIndexMap, llvm::String, and uint64_t.

◆ getGlobalData()

◆ getOutUnitDIE()

DIE * llvm::dwarf_linker::parallel::DwarfUnit::getOutUnitDIE ( )
inline

◆ getSysRoot()

StringRef llvm::dwarf_linker::parallel::DwarfUnit::getSysRoot ( )
inline

Return the DW_AT_LLVM_sysroot of the compile unit or an empty StringRef.

Definition at line 49 of file DWARFLinkerUnit.h.

References SysRoot.

Referenced by llvm::dwarf_linker::parallel::CompileUnit::analyzeImportedModule().

◆ getTag()

dwarf::Tag llvm::dwarf_linker::parallel::DwarfUnit::getTag ( ) const
inline

Returns unit DWARF tag.

Definition at line 89 of file DWARFLinkerUnit.h.

References UnitTag.

◆ getUniqueID()

unsigned llvm::dwarf_linker::parallel::DwarfUnit::getUniqueID ( ) const
inline

Unique id of the unit.

Definition at line 40 of file DWARFLinkerUnit.h.

References ID.

◆ getUnitName()

◆ getUnitSize()

uint64_t llvm::dwarf_linker::parallel::DwarfUnit::getUnitSize ( ) const
inline

Returns size of this(newly generated) compile unit.

Definition at line 43 of file DWARFLinkerUnit.h.

References uint64_t, and UnitSize.

Referenced by emitPubAcceleratorEntry().

◆ isClangModule()

bool llvm::dwarf_linker::parallel::DwarfUnit::isClangModule ( ) const
inline

Return true if this compile unit is from Clang module.

Definition at line 52 of file DWARFLinkerUnit.h.

References ClangModuleName.

◆ isInterconnectedCU()

bool llvm::dwarf_linker::parallel::DwarfUnit::isInterconnectedCU ( ) const
inline

Returns true if unit is inter-connected(it references/referenced by other unit).

Definition at line 62 of file DWARFLinkerUnit.h.

References IsInterconnectedCU.

◆ setInterconnectedCU()

void llvm::dwarf_linker::parallel::DwarfUnit::setInterconnectedCU ( )
inline

Mark this unit as inter-connected(it references/referenced by other unit).

Definition at line 65 of file DWARFLinkerUnit.h.

References IsInterconnectedCU.

◆ setOutUnitDIE()

void llvm::dwarf_linker::parallel::DwarfUnit::setOutUnitDIE ( DIE * UnitDie)
inline

Member Data Documentation

◆ Abbreviations

std::vector<std::unique_ptr<DIEAbbrev> > llvm::dwarf_linker::parallel::DwarfUnit::Abbreviations
protected

Storage for the unique Abbreviations.

Definition at line 213 of file DWARFLinkerUnit.h.

Referenced by assignAbbrev(), getAbbreviations(), and llvm::dwarf_linker::parallel::CompileUnit::maybeResetToLoadedStage().

◆ AbbreviationsSet

FoldingSet<DIEAbbrev> llvm::dwarf_linker::parallel::DwarfUnit::AbbreviationsSet
protected

◆ ClangModuleName

std::string llvm::dwarf_linker::parallel::DwarfUnit::ClangModuleName
protected

◆ DebugStringIndexMap

IndexedValuesMap<const StringEntry *> llvm::dwarf_linker::parallel::DwarfUnit::DebugStringIndexMap
protected

Maps a string into the index inside .debug_str_offsets section.

Definition at line 231 of file DWARFLinkerUnit.h.

Referenced by llvm::dwarf_linker::parallel::TypeUnit::createDIETree(), emitDebugStringOffsetSection(), getDebugStrIndex(), and llvm::dwarf_linker::parallel::TypeUnit::getDebugStrIndex().

◆ FileNames

◆ FileNamesMutex

std::mutex llvm::dwarf_linker::parallel::DwarfUnit::FileNamesMutex
protected

Guards FileNames.

During the parallel type-name assignment phase a unit's cache is filled both by its own worker and, through cross-unit type-name references, by other units' workers, so access must be serialized.

Definition at line 228 of file DWARFLinkerUnit.h.

Referenced by llvm::dwarf_linker::parallel::CompileUnit::getDirAndFilenameFromLineTable().

◆ ID

◆ IsInterconnectedCU

std::atomic<bool> llvm::dwarf_linker::parallel::DwarfUnit::IsInterconnectedCU = {false}
protected

true if current unit references_to/is_referenced by other unit.

Definition at line 207 of file DWARFLinkerUnit.h.

Referenced by isInterconnectedCU(), and setInterconnectedCU().

◆ OutUnitDIE

DIE* llvm::dwarf_linker::parallel::DwarfUnit::OutUnitDIE = nullptr
protected

◆ SysRoot

std::string llvm::dwarf_linker::parallel::DwarfUnit::SysRoot
protected

◆ UnitName

std::string llvm::dwarf_linker::parallel::DwarfUnit::UnitName
protected

◆ UnitSize

uint64_t llvm::dwarf_linker::parallel::DwarfUnit::UnitSize = 0
protected

Definition at line 201 of file DWARFLinkerUnit.h.

Referenced by getUnitSize(), and setOutUnitDIE().

◆ UnitTag

dwarf::Tag llvm::dwarf_linker::parallel::DwarfUnit::UnitTag = dwarf::DW_TAG_null
protected

DWARF unit tag.

Definition at line 204 of file DWARFLinkerUnit.h.

Referenced by getTag(), and setOutUnitDIE().


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