9#ifndef LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERIMPL_H
10#define LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERIMPL_H
22namespace dwarflinker_parallel {
83 AllowNonDeterministicOutput;
129 if ((TargetDWARFVersion < 1) || (TargetDWARFVersion > 5))
131 "unsupported DWARF version: %d",
170 std::unique_ptr<CompileUnit>
Unit;
214 std::string &PCMFile,
215 unsigned Indent,
bool Quiet);
225 unsigned Indent = 0);
231 const std::string &PCMFile,
233 unsigned Indent = 0);
246 Size += Unit->getLength();
274 return LHS <
RHS->getOrigUnit().getNextUnitOffset();
This file contains support for writing accelerator tables.
static fatal_error_handler_t ErrorHandler
ppc ctr loops PowerPC CTR Loops Verify
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
reference emplace_back(ArgTypes &&... Args)
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
Triple - Helper class for working with autoconf configuration names.
Stores all information related to a compile unit, be it in its original instance of the object file o...
Stage
The stages of new compile unit processing.
@ Cleaned
Resources(Input DWARF, Output DWARF tree) are released.
This class represents DWARF information for source file and it's address map.
std::unique_ptr< DWARFContext > Dwarf
Source DWARF information.
This class links debug info.
void glueCompileUnitsAndWriteToTheOutput()
Take already linked compile units and glue them into single file.
void verifyInput(const DWARFFile &File)
Verify input DWARF file.
void forEachCompileUnit(function_ref< void(CompileUnit *CU)> UnitHandler)
Enumerates all comple units.
void addObjectFile(DWARFFile &File, ObjFileLoaderTy Loader=nullptr, CompileUnitHandlerTy OnCUDieLoaded=[](const DWARFUnit &) {}) override
Add object file to be linked.
void printStatistic()
Print statistic for processed Debug Info.
void forEachObjectSectionsSet(function_ref< void(OutputSections &SectionsSet)> SectionsSetHandler)
Enumerates sections for modules, invariant for object files, compile units.
void emitCommonSectionsAndWriteCompileUnitsToTheOutput()
Emit debug sections common for all input files.
void forEachOutputString(function_ref< void(StringDestinationKind, const StringEntry *)> StringHandler)
Enumerates all strings.
void emitDWARFv5DebugNamesSection(const Triple &TargetTriple)
Emit .debug_names section.
void writeCommonSectionsToTheOutput()
Enumerate common sections and put their data into the output stream.
void emitAppleAcceleratorSections(const Triple &TargetTriple)
Emit apple accelerator sections.
Error createEmitter(const Triple &TheTriple, OutputFileType FileType, raw_pwrite_stream &OutFile) override
Create debug info emitter.
void emitStringSections()
Emit string sections.
ExtraDwarfEmitter * getEmitter() override
Returns previously created dwarf emitter. May be nullptr.
void writeCompileUnitsToTheOutput()
Enumerate all compile units and put their data into the output stream.
Error link() override
Link debug info for added files.
void assignOffsetsToSections()
Enumerate all compile units and assign offsets to their sections.
Error validateAndUpdateOptions()
Validate specified options.
void forEachCompileAndTypeUnit(function_ref< void(DwarfUnit *CU)> UnitHandler)
Enumerates all compile and type units.
void cleanupDataAfterDWARFOutputIsWritten()
Cleanup data(string pools) after output sections are generated.
void assignOffsets()
Enumerate all compile units and assign offsets to their sections and strings.
void patchOffsetsAndSizes()
Enumerates all patches and update them with the correct values.
void assignOffsetsToStrings()
Enumerate all compile units and assign offsets to their strings.
std::function< void(const DWARFFile &File, llvm::StringRef Output)> InputVerificationHandlerTy
std::map< std::string, std::string > SwiftInterfacesMapTy
std::function< ErrorOr< DWARFFile & >(StringRef ContainerName, StringRef Path)> ObjFileLoaderTy
std::function< void(const Twine &Warning, StringRef Context, const DWARFDie *DIE)> MessageHandlerTy
std::map< std::string, std::string > ObjectPrefixMapTy
OutputFileType
Type of output file.
std::function< StringRef(StringRef)> TranslatorFuncTy
This class discovers DIEs dependencies: marks "live" DIEs, marks DIE locations (whether DIE should be...
Base class for all Dwarf units(Compile unit/Type table unit).
This class keeps data and services common for the whole linking process.
DWARFLinkerOptions Options
const DWARFLinkerOptions & getOptions() const
Returns linking options.
This class keeps contents and offsets to the debug sections.
LinkingGlobalData & GlobalData
This class creates a DwarfStringPoolEntry for the corresponding StringEntry.
Type Unit is used to represent an artificial compilation unit which keeps all type information.
An efficient, type-erasing, non-owning reference to a callable.
An abstract base class for streams implementations that also support a pwrite operation.
std::atomic< size_t > UniqueUnitID
Unique ID for compile unit.
OutputSections CommonSections
Common sections.
std::unique_ptr< DwarfEmitterImpl > TheDwarfEmitter
The emitter of final dwarf file.
uint64_t OverallNumberOfCU
Overall compile units number.
std::mutex ClangModulesMutex
StringEntryToDwarfStringPoolEntryMap DebugLineStrStrings
DwarfStringPoolEntries for .debug_line_str section.
SmallVector< std::unique_ptr< LinkContext > > ObjectContexts
Keeps all linking contexts.
std::unique_ptr< TypeUnit > ArtificialTypeUnit
Type unit.
LinkingGlobalData GlobalData
Data global for the whole linking process.
StringEntryToDwarfStringPoolEntryMap DebugStrStrings
StringMap< uint64_t > ClangModules
Mapping the PCM filename to the DwoId.
void setEstimatedObjfilesAmount(unsigned ObjFilesNum) override
Set estimated objects files amount, for preliminary data allocation.
void setSwiftInterfacesMap(SwiftInterfacesMapTy *Map) override
Set map for Swift interfaces.
void setUpdateIndexTablesOnly(bool UpdateIndexTablesOnly) override
Update index tables only(do not modify rest of DWARF).
void setVerifyInputDWARF(bool Verify) override
Verify the input DWARF.
void setInputVerificationHandler(InputVerificationHandlerTy Handler) override
Set verification handler which would be used to report verification errors.
void setVerbosity(bool Verbose) override
Allows to generate log of linking process to the standard output.
void setAllowNonDeterministicOutput(bool AllowNonDeterministicOutput) override
Allow generating valid, but non-deterministic output.
void addAccelTableKind(AccelTableKind Kind) override
Add kind of accelerator tables to be generated.
void setStatistics(bool Statistics) override
Print statistics to standard output.
void setNumThreads(unsigned NumThreads) override
Use specified number of threads for parallel files linking.
void setPrependPath(const std::string &Ppath) override
Set prepend path for clang modules.
void setNoODR(bool NoODR) override
Do not unique types according to ODR.
void setKeepFunctionForStatic(bool KeepFunctionForStatic) override
Set to keep the enclosing function for a static variable.
void setObjectPrefixMap(ObjectPrefixMapTy *Map) override
Set prefix map for objects.
Error setTargetDWARFVersion(uint16_t TargetDWARFVersion) override
Set target DWARF version.
This is an optimization pass for GlobalISel generic memory operations.
auto upper_bound(R &&Range, T &&Value)
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
AccelTableKind
The kind of accelerator tables we should emit.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Hold the input and output of the debug info size in bytes.
Keep information for referenced clang module: already loaded DWARF info of the clang module and a Com...
std::unique_ptr< CompileUnit > Unit
RefModuleUnit(const RefModuleUnit &)=delete
Keeps track of data associated with one object during linking.
void linkSingleCompileUnit(CompileUnit &CU, TypeUnit *ArtificialTypeUnit, enum CompileUnit::Stage DoUntilStage=CompileUnit::Stage::Cleaned)
Link specified compile unit until specified stage.
UnitListTy CompileUnits
Set of Compilation Units(may be accessed asynchroniously for reading).
std::optional< Triple > TargetTriple
ModuleUnitListTy ModulesCompileUnits
Set of Compile Units for modules.
void emitFDE(uint32_t CIEOffset, uint32_t AddrSize, uint64_t Address, StringRef FDEBytes, SectionDescriptor &Section)
Emit FDE record.
bool InterCUProcessingStarted
Flag indicating that all inter-connected units are loaded and the dwarf linking process for these uni...
uint64_t getInputDebugInfoSize() const
Computes the total size of the debug info.
std::atomic< bool > HasNewGlobalDependency
Error emitInvariantSections()
Emit invariant sections.
DWARFFile & InputDWARFFile
Object file descriptor.
Error cloneAndEmitDebugFrame()
Clone and emit .debug_frame.
void addModulesCompileUnit(RefModuleUnit &&Unit)
Add Compile Unit corresponding to the module.
StringMap< uint64_t > & ClangModules
std::atomic< size_t > & UniqueUnitID
Counter for compile units ID.
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 ...
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 ClangModul...
uint64_t OriginalDebugInfoSize
Size of Debug info before optimizing.
std::atomic< bool > HasNewInterconnectedCUs
Flag indicating that new inter-connected compilation units were discovered.
std::function< CompileUnit *(uint64_t)> getUnitForOffset
std::pair< bool, bool > isClangModuleRef(const DWARFDie &CUDie, std::string &PCMFile, unsigned Indent, bool Quiet)
Check whether specified CUDie is a Clang module reference.
uint16_t TargetDWARFVersion
DWARF version for the output.
std::string PrependPath
Prepend path for the clang modules.
bool Verbose
Generate processing log to the standard output.
unsigned Threads
Number of threads.
bool KeepFunctionForStatic
Whether we want a static variable to force us to keep its enclosing function.
SmallVector< DWARFLinker::AccelTableKind, 1 > AccelTables
The accelerator table kinds.
bool UpdateIndexTablesOnly
Update index tables.
bool AllowNonDeterministicOutput
Allow to generate valid, but non deterministic output.
bool NoODR
Do not unique types according to ODR.
DWARFLinker::InputVerificationHandlerTy InputVerificationHandler
input verification handler(it might be called asynchronously).
bool VerifyInputDWARF
Verify the input DWARF.
DWARFLinker::SwiftInterfacesMapTy * ParseableSwiftInterfaces
A list of all .swiftinterface files referenced by the debug info, mapping Module name to path on disk...
DWARFLinker::ObjectPrefixMapTy * ObjectPrefixMap
A list of remappings to apply to file paths.
bool Statistics
Print statistics.
This structure is used to keep data of the concrete section.