9#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERIMPL_H
10#define LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERIMPL_H
22namespace dwarf_linker {
85 AllowNonDeterministicOutput;
131 if ((TargetDWARFVersion < 1) || (TargetDWARFVersion > 5))
133 "unsupported DWARF version: %d",
172 std::unique_ptr<CompileUnit>
Unit;
213 std::string &PCMFile,
214 unsigned Indent,
bool Quiet);
224 unsigned Indent = 0);
230 const std::string &PCMFile,
232 unsigned Indent = 0);
245 Size += Unit->getLength();
273 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.
This class represents DWARF information for source file and it's address map.
std::unique_ptr< DWARFContext > Dwarf
Source DWARF information.
std::map< std::string, std::string > ObjectPrefixMapTy
AccelTableKind
The kind of accelerator tables to be emitted.
std::function< void(const Twine &Warning, StringRef Context, const DWARFDie *DIE)> MessageHandlerTy
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
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 links debug info.
void forEachObjectSectionsSet(function_ref< void(OutputSections &SectionsSet)> SectionsSetHandler)
Enumerates sections for modules, invariant for object files, compile units.
void emitDWARFv5DebugNamesSection(const Triple &TargetTriple)
Emit .debug_names section.
void writeCompileUnitsToTheOutput()
Enumerate all compile units and put their data into the output stream.
void forEachCompileUnit(function_ref< void(CompileUnit *CU)> UnitHandler)
Enumerates all comple units.
void assignOffsetsToStrings()
Enumerate all compile units and assign offsets to their strings.
void assignOffsets()
Enumerate all compile units and assign offsets to their sections and strings.
Error link() override
Link debug info for added files.
Error validateAndUpdateOptions()
Validate specified options.
void writeCommonSectionsToTheOutput()
Enumerate common sections and put their data into the output stream.
void assignOffsetsToSections()
Enumerate all compile units and assign offsets to their sections.
void printStatistic()
Print statistic for processed Debug Info.
void glueCompileUnitsAndWriteToTheOutput()
Take already linked compile units and glue them into single file.
void emitAppleAcceleratorSections(const Triple &TargetTriple)
Emit apple accelerator sections.
void verifyInput(const DWARFFile &File)
Verify input DWARF file.
void forEachCompileAndTypeUnit(function_ref< void(DwarfUnit *CU)> UnitHandler)
Enumerates all compile and type units.
void emitStringSections()
Emit string sections.
void addObjectFile(DWARFFile &File, ObjFileLoaderTy Loader=nullptr, CompileUnitHandlerTy OnCUDieLoaded=[](const DWARFUnit &) {}) override
Add object file to be linked.
void cleanupDataAfterDWARFOutputIsWritten()
Cleanup data(string pools) after output sections are generated.
void forEachOutputString(function_ref< void(StringDestinationKind, const StringEntry *)> StringHandler)
Enumerates all strings.
void setOutputDWARFHandler(const Triple &TargetTriple, SectionHandlerTy SectionHandler) override
Set output DWARF handler.
void emitCommonSectionsAndWriteCompileUnitsToTheOutput()
Emit debug sections common for all input files.
void patchOffsetsAndSizes()
Enumerates all patches and update them with the correct values.
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.
void setTargetTriple(const Triple &TargetTriple)
Set target triple.
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.
LinkingGlobalData GlobalData
std::atomic< size_t > UniqueUnitID
Unique ID for compile unit.
uint64_t OverallNumberOfCU
Overall compile units number.
SmallVector< std::unique_ptr< LinkContext > > ObjectContexts
Keeps all linking contexts.
StringEntryToDwarfStringPoolEntryMap DebugLineStrStrings
DwarfStringPoolEntries for .debug_line_str section.
SectionHandlerTy SectionHandler
Hanler for output sections.
std::unique_ptr< TypeUnit > ArtificialTypeUnit
Type unit.
StringEntryToDwarfStringPoolEntryMap DebugStrStrings
DwarfStringPoolEntries for .debug_str section.
std::mutex ClangModulesMutex
OutputSections CommonSections
Common sections.
StringMap< uint64_t > ClangModules
Mapping the PCM filename to the DwoId.
void setNumThreads(unsigned NumThreads) override
Use specified number of threads for parallel files linking.
Error setTargetDWARFVersion(uint16_t TargetDWARFVersion) override
Set target DWARF version.
void setVerbosity(bool Verbose) override
Allows to generate log of linking process to the standard output.
void setInputVerificationHandler(InputVerificationHandlerTy Handler) override
Set verification handler which would be used to report verification errors.
void setObjectPrefixMap(ObjectPrefixMapTy *Map) override
Set prefix map for objects.
void addAccelTableKind(AccelTableKind Kind) override
Add kind of accelerator tables to be generated.
void setAllowNonDeterministicOutput(bool AllowNonDeterministicOutput) override
Allow generating valid, but non-deterministic output.
void setVerifyInputDWARF(bool Verify) override
Verify the input DWARF.
void setKeepFunctionForStatic(bool KeepFunctionForStatic) override
Set to keep the enclosing function for a static variable.
void setUpdateIndexTablesOnly(bool UpdateIndexTablesOnly) override
Update index tables only(do not modify rest of DWARF).
void setSwiftInterfacesMap(SwiftInterfacesMapTy *Map) override
Set map for Swift interfaces.
void setStatistics(bool Statistics) override
Print statistics to standard output.
void setNoODR(bool NoODR) override
Do not unique types according to ODR.
void setPrependPath(StringRef Ppath) override
Set prepend path for clang modules.
void setEstimatedObjfilesAmount(unsigned ObjFilesNum) override
Set estimated objects files amount, for preliminary data allocation.
std::function< void(std::shared_ptr< SectionDescriptorBase > Section)> SectionHandlerTy
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.
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.
uint64_t getInputDebugInfoSize() const
Computes the total size of the debug info.
bool InterCUProcessingStarted
Flag indicating that all inter-connected units are loaded and the dwarf linking process for these uni...
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...
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 ...
DWARFFile & InputDWARFFile
Object file descriptor.
uint64_t OriginalDebugInfoSize
Size of Debug info before optimizing.
Error emitInvariantSections()
Emit invariant sections.
std::pair< bool, bool > isClangModuleRef(const DWARFDie &CUDie, std::string &PCMFile, unsigned Indent, bool Quiet)
Check whether specified CUDie is a Clang module reference.
void addModulesCompileUnit(RefModuleUnit &&Unit)
Add Compile Unit corresponding to the module.
void emitFDE(uint32_t CIEOffset, uint32_t AddrSize, uint64_t Address, StringRef FDEBytes, SectionDescriptor &Section)
Emit FDE record.
UnitListTy CompileUnits
Set of Compilation Units(may be accessed asynchroniously for reading).
void linkSingleCompileUnit(CompileUnit &CU, TypeUnit *ArtificialTypeUnit, enum CompileUnit::Stage DoUntilStage=CompileUnit::Stage::Cleaned)
Link specified compile unit until specified stage.
std::atomic< bool > HasNewInterconnectedCUs
Flag indicating that new inter-connected compilation units were discovered.
StringMap< uint64_t > & ClangModules
Error cloneAndEmitDebugFrame()
Clone and emit .debug_frame.
std::atomic< size_t > & UniqueUnitID
Counter for compile units ID.
std::atomic< bool > HasNewGlobalDependency
std::function< CompileUnit *(uint64_t)> getUnitForOffset
ModuleUnitListTy ModulesCompileUnits
Set of Compile Units for modules.
bool KeepFunctionForStatic
Whether we want a static variable to force us to keep its enclosing function.
DWARFLinkerBase::ObjectPrefixMapTy * ObjectPrefixMap
A list of remappings to apply to file paths.
bool Verbose
Generate processing log to the standard output.
DWARFLinkerBase::SwiftInterfacesMapTy * ParseableSwiftInterfaces
A list of all .swiftinterface files referenced by the debug info, mapping Module name to path on disk...
SmallVector< DWARFLinkerBase::AccelTableKind, 1 > AccelTables
The accelerator table kinds.
uint16_t TargetDWARFVersion
DWARF version for the output.
bool NoODR
Do not unique types according to ODR.
bool AllowNonDeterministicOutput
Allow to generate valid, but non deterministic output.
std::string PrependPath
Prepend path for the clang modules.
bool VerifyInputDWARF
Verify the input DWARF.
bool UpdateIndexTablesOnly
Update index tables.
bool Statistics
Print statistics.
unsigned Threads
Number of threads.
DWARFLinkerBase::InputVerificationHandlerTy InputVerificationHandler
input verification handler(it might be called asynchronously).
This structure is used to keep data of the concrete section.