19namespace dwarflinker_parallel {
24 : UniqueUnitID(0), DebugStrStrings(GlobalData),
25 DebugLineStrStrings(GlobalData), CommonSections(GlobalData) {
34 std::atomic<size_t> &UniqueUnitID,
35 std::optional<Triple> TargetTriple)
37 ClangModules(ClangModules), TargetTriple(TargetTriple),
38 UniqueUnitID(UniqueUnitID) {
41 if (!File.Dwarf->compile_units().empty())
53 DWARFFile &File, std::unique_ptr<CompileUnit> Unit)
54 : File(File), Unit(
std::
move(Unit)) {}
69 TheDwarfEmitter = std::make_unique<DwarfEmitterImpl>(FileType, OutFile);
86 for (
const std::unique_ptr<DWARFUnit> &
CU :
124 std::optional<uint16_t> Language;
127 if (
Context->InputDWARFFile.Dwarf.get() ==
nullptr) {
128 Context->setOutputFormat(
Context->getFormParams(), GlobalEndianness);
133 outs() <<
"OBJECT: " <<
Context->InputDWARFFile.FileName <<
"\n";
135 for (
const std::unique_ptr<DWARFUnit> &OrigCU :
136 Context->InputDWARFFile.Dwarf->compile_units()) {
137 outs() <<
"Input compilation unit:";
141 OrigCU->getUnitDIE().dump(
outs(), 0, DumpOpts);
150 GlobalEndianness =
Context->getEndianness();
154 Context->setOutputFormat(
Context->getFormParams(), GlobalEndianness);
159 for (
const std::unique_ptr<DWARFUnit> &OrigCU :
160 Context->InputDWARFFile.Dwarf->compile_units()) {
161 DWARFDie UnitDie = OrigCU.get()->getUnitDIE();
164 if (std::optional<DWARFFormValue> Val =
165 UnitDie.
find(dwarf::DW_AT_language)) {
205 Context->InputDWARFFile.unload();
215 Context->InputDWARFFile.unload();
225 ->Children.empty()) {
227 ? std::optional<Triple>(std::nullopt)
257 "target DWARF version is not set");
264 "set number of threads to 1 to make --verbose to work properly.",
"");
283 CUDie.
find({dwarf::DW_AT_dwo_id, dwarf::DW_AT_GNU_dwo_id}));
292 if (ObjectPrefixMap.empty())
296 for (
const auto &Entry : ObjectPrefixMap)
299 return p.str().str();
305 CUDie.
find({dwarf::DW_AT_dwo_name, dwarf::DW_AT_GNU_dwo_name}),
"");
311 PCMFile =
remapPath(PCMFile, *ObjectPrefixMap);
317 const DWARFDie &CUDie, std::string &PCMFile,
unsigned Indent,
bool Quiet) {
319 return std::make_pair(
false,
false);
327 GlobalData.
warn(
"anonymous module skeleton CU for " + PCMFile +
".",
329 return std::make_pair(
true,
true);
334 outs() <<
"Found clang module reference " << PCMFile;
344 Twine(
"hash mismatch: this object file was built against a "
345 "different version of the module ") +
349 outs() <<
" [cached].\n";
350 return std::make_pair(
true,
true);
353 return std::make_pair(
true,
false);
365 std::string PCMFile =
367 std::pair<bool, bool> IsClangModuleRef =
370 if (!IsClangModuleRef.first)
373 if (IsClangModuleRef.second)
406 if (Loader ==
nullptr) {
416 std::unique_ptr<CompileUnit> Unit;
417 for (
const auto &
CU : ErrOrObj->Dwarf->compile_units()) {
420 auto ChildCUDie =
CU->getUnitDIE();
427 ": Clang modules are expected to have exactly 1 compile unit.\n");
435 if (PCMDwoId != DwoId) {
438 Twine(
"hash mismatch: this object file was built against a "
439 "different version of the module ") +
447 if (!ChildCUDie.hasChildren())
451 Unit = std::make_unique<CompileUnit>(
485 outs() <<
"No valid relocations found. Skipping.\n";
495 auto CUDie = OrigCU->getUnitDIE();
496 std::string PCMFile =
530 if (
CU->isInterconnectedCU()) {
531 CU->maybeResetToLoadedStage();
532 linkSingleCompileUnit(*CU, ArtificialTypeUnit,
533 CompileUnit::Stage::Loaded);
539 [&](std::unique_ptr<CompileUnit> &
CU) {
562 if (
CU->isInterconnectedCU() &&
606 ResultErr = std::move(Err);
621 if (
CU.getStage() >= DoUntilStage)
624 switch (
CU.getStage()) {
625 case CompileUnit::Stage::CreatedNotLoaded: {
628 if (!CU.loadInputDIEs()) {
631 CU.setStage(CompileUnit::Stage::Skipped);
633 CU.analyzeDWARFStructure();
640 if (registerModuleReference(
641 CU.getOrigUnit().getUnitDIE(), nullptr,
642 [](const DWARFUnit &) {}, 0))
643 CU.setStage(CompileUnit::Stage::PatchesUpdated);
645 CU.setStage(CompileUnit::Stage::Loaded);
652 if (!CU.resolveDependenciesAndMarkLiveness(InterCUProcessingStarted,
653 HasNewInterconnectedCUs)) {
654 assert(HasNewInterconnectedCUs &&
655 "Flag indicating new inter-connections is not set");
664 if (
CU.updateDependenciesCompleteness())
669 return CU.updateDependenciesCompleteness();
671 return std::move(Err);
679 CU.verifyDependencies();
685 return std::move(Err);
692 if (
CU.isClangModule() ||
694 CU.getContaingFile().Addresses->hasValidRelocs()) {
695 if (Error Err = CU.cloneAndEmit(TargetTriple, ArtificialTypeUnit))
696 return std::move(Err);
704 CU.updateDieRefPatchesWithClonedOffsets();
710 CU.cleanupDataAfterClonning();
725 CU.error(std::move(Err));
726 CU.cleanupDataAfterClonning();
757 if (InputDWARFFile.Dwarf.get() ==
nullptr)
760 const DWARFObject &InputDWARFObj = InputDWARFFile.Dwarf->getDWARFObj();
763 if (OrigFrameData.
empty())
767 for (std::unique_ptr<CompileUnit> &Unit : CompileUnits) {
768 for (
auto CurRange : Unit->getFunctionRanges())
769 AllUnitsRanges.
insert(CurRange.Range, CurRange.Value);
788 while (
Data.isValidOffset(InputOffset)) {
791 if (InitialLength == 0xFFFFFFFF)
794 "Dwarf64 bits no supported"));
797 if (CIEId == 0xFFFFFFFF) {
799 StringRef CIEData = OrigFrameData.
substr(EntryOffset, InitialLength + 4);
800 LocalCIES[EntryOffset] = CIEData;
802 InputOffset += InitialLength - 4;
806 uint64_t Loc =
Data.getUnsigned(&InputOffset, SrcAddrSize);
812 std::optional<AddressRangeValuePair> Range =
816 InputOffset = EntryOffset + InitialLength + 4;
827 "Inconsistent debug_frame content. Dropping."));
833 auto IteratorInserted =
834 EmittedCIEs.
insert(std::make_pair(CIEData, OffsetToCIERecord));
835 OffsetToCIERecord = IteratorInserted.first->getValue();
838 if (IteratorInserted.second)
839 OutSection.
OS << CIEData;
846 OutSection.notePatch(
852 unsigned FDERemainingBytes = InitialLength - (4 + SrcAddrSize);
853 emitFDE(OffsetToCIERecord, SrcAddrSize, Loc + Range->Value,
854 OrigFrameData.
substr(InputOffset, FDERemainingBytes), OutSection);
855 InputOffset += FDERemainingBytes;
868 Section.emitIntVal(FDEBytes.
size() + 4 + AddrSize, 4);
869 Section.emitIntVal(CIEOffset, 4);
870 Section.emitIntVal(
Address, AddrSize);
871 Section.OS.write(FDEBytes.
data(), FDEBytes.
size());
908 uint64_t AllDebugInfoSectionsSize = 0;
910 for (std::unique_ptr<CompileUnit> &
CU :
Context->CompileUnits)
911 if (std::optional<SectionDescriptor *>
DebugInfo =
913 AllDebugInfoSectionsSize += (*DebugInfo)->getContents().size();
915 SizeByObject[
Context->InputDWARFFile.FileName].Input =
916 Context->OriginalDebugInfoSize;
917 SizeByObject[
Context->InputDWARFFile.FileName].Output =
918 AllDebugInfoSectionsSize;
922 std::vector<std::pair<StringRef, DebugInfoSize>> Sorted;
923 for (
auto &
E : SizeByObject)
924 Sorted.emplace_back(
E.first(),
E.second);
926 return LHS.second.Output >
RHS.second.Output;
929 auto ComputePercentange = [](int64_t Input, int64_t Output) ->
float {
930 const float Difference = Output - Input;
931 const float Sum = Input + Output;
934 return (Difference / (Sum / 2));
937 int64_t InputTotal = 0;
938 int64_t OutputTotal = 0;
939 const char *FormatStr =
"{0,-45} {1,10}b {2,10}b {3,8:P}\n";
942 outs() <<
".debug_info section size (in bytes)\n";
943 outs() <<
"----------------------------------------------------------------"
945 outs() <<
"Filename Object "
947 outs() <<
"----------------------------------------------------------------"
951 for (
auto &
E : Sorted) {
952 InputTotal +=
E.second.Input;
953 OutputTotal +=
E.second.Output;
956 E.second.Output, ComputePercentange(
E.second.Input,
E.second.Output));
959 outs() <<
"----------------------------------------------------------------"
962 ComputePercentange(InputTotal, OutputTotal));
963 outs() <<
"----------------------------------------------------------------"
964 "---------------\n\n";
974 size_t CurDebugStrIndex = 1;
977 size_t CurDebugLineStrIndex = 0;
989 if (!Entry->isIndexed()) {
990 Entry->Offset = CurDebugStrOffset;
991 CurDebugStrOffset += Entry->String.size() + 1;
992 Entry->Index = CurDebugStrIndex++;
1000 if (!Entry->isIndexed()) {
1001 Entry->Offset = CurDebugLineStrOffset;
1002 CurDebugLineStrOffset += Entry->String.size() + 1;
1003 Entry->Index = CurDebugLineStrIndex++;
1011 std::array<uint64_t, SectionKindsNum> SectionSizesAccumulator = {0};
1028 OutSection.ListDebugStrPatch.forEach([&](
DebugStrPatch &Patch) {
1044 OutSection.ListDebugStrPatch.forEach([&](
DebugStrPatch &Patch) {
1053 if (Patch.Die ==
nullptr)
1059 OutSection.ListDebugTypeLineStrPatch.forEach(
1061 if (Patch.Die ==
nullptr)
1080 SectionsSetHandler(*ModuleUnit.
Unit);
1088 for (std::unique_ptr<CompileUnit> &
CU :
Context->CompileUnits)
1090 SectionsSetHandler(*
CU);
1103 UnitHandler(ModuleUnit.
Unit.get());
1107 for (std::unique_ptr<CompileUnit> &
CU :
Context->CompileUnits)
1109 UnitHandler(
CU.get());
1118 UnitHandler(ModuleUnit.
Unit.get());
1122 for (std::unique_ptr<CompileUnit> &
CU :
Context->CompileUnits)
1124 UnitHandler(
CU.get());
1182 uint64_t DebugLineStrNextOffset = 0;
1188 DebugStrNextOffset++;
1201 if (StringToEmit->
Offset >= DebugStrNextOffset) {
1202 DebugStrNextOffset =
1217 if (StringToEmit->
Offset >= DebugLineStrNextOffset) {
1218 DebugLineStrNextOffset =
1238 switch (
Info.Type) {
1239 case DwarfUnit::AccelType::None: {
1240 llvm_unreachable(
"Unknown accelerator record");
1243 AppleNamespaces.addName(
1244 *DebugStrStrings.getExistingEntry(Info.String),
1245 CU->getSectionDescriptor(DebugSectionKind::DebugInfo).StartOffset +
1250 *DebugStrStrings.getExistingEntry(Info.String),
1251 CU->getSectionDescriptor(DebugSectionKind::DebugInfo).StartOffset +
1256 *DebugStrStrings.getExistingEntry(Info.String),
1257 CU->getSectionDescriptor(DebugSectionKind::DebugInfo).StartOffset +
1262 *DebugStrStrings.getExistingEntry(Info.String),
1263 CU->getSectionDescriptor(DebugSectionKind::DebugInfo).StartOffset +
1266 Info.ObjcClassImplementation ? dwarf::DW_FLAG_type_implementation
1268 Info.QualifiedNameHash);
1282 if (
Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1299 SectionDescriptor &OutSection =
1303 if (Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1313 OutSection.setSizesForSectionCreatedByAsmPrinter();
1320 SectionDescriptor &OutSection =
1324 if (Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1334 OutSection.setSizesForSectionCreatedByAsmPrinter();
1341 SectionDescriptor &OutSection =
1345 if (Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1355 OutSection.setSizesForSectionCreatedByAsmPrinter();
1360 std::unique_ptr<DWARF5AccelTable>
DebugNames;
1368 bool HasRecords =
false;
1371 DebugNames = std::make_unique<DWARF5AccelTable>();
1374 switch (
Info.Type) {
1375 case DwarfUnit::AccelType::Name:
1376 case DwarfUnit::AccelType::Namespace:
1377 case DwarfUnit::AccelType::Type: {
1378 DebugNames->addName(*DebugStrStrings.getExistingEntry(Info.String),
1379 Info.OutOffset, Info.Tag, CU->getUniqueID());
1388 CompUnits.push_back(
1391 CUidToIdx[
CU->getUniqueID()] = Id++;
1403 if (
Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1424 bool HasAbbreviations =
false;
1431 HasAbbreviations =
true;
1440 if (!HasAbbreviations) {
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Analysis containing CSE Info
dxil DXContainer Global Emitter
static fatal_error_handler_t ErrorHandler
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...
std::optional< T > getRangeThatContains(uint64_t Addr) const
AddressRangesMap class maps values to the address ranges.
void insert(AddressRange Range, int64_t Value)
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
std::optional< DWARFFormValue > find(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE.
virtual bool isLittleEndian() const =0
virtual StringRef getFileName() const
virtual const DWARFSection & getFrameSection() const
virtual uint8_t getAddressSize() const
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void reserve(size_type N)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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",...
iterator find(StringRef Key)
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
StringRef - Represent a constant reference to a string, i.e.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
constexpr bool empty() const
empty - Check if the string is empty.
constexpr size_t size() const
size - Get the string size.
StringRef take_back(size_t N=1) const
Return a StringRef equal to 'this' but with only the last N elements remaining.
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
A ThreadPool for asynchronous parallel execution on a defined number of threads.
void wait()
Blocking wait for all the threads to complete and the queue to be empty.
auto async(Function &&F, Args &&...ArgList)
Asynchronous submission of a task to the pool.
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
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.
@ Cloned
Output DWARF is generated.
@ TypeNamesAssigned
Type names assigned to DIEs.
@ PatchesUpdated
Offsets inside patch records are updated.
@ Cleaned
Resources(Input DWARF, Output DWARF tree) are released.
@ Loaded
Input DWARF is loaded.
@ LivenessAnalysisDone
Input DWARF is analysed(DIEs pointing to the real code section are discovered,...
@ UpdateDependenciesCompleteness
Check if dependencies have incompatible placement.
@ Skipped
Compile Unit should be skipped.
This class represents DWARF information for source file and it's address map.
std::unique_ptr< DWARFContext > Dwarf
Source DWARF information.
StringRef FileName
Object file name.
std::unique_ptr< AddressesMap > Addresses
Helpful address information(list of valid address ranges, relocations).
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.
DWARFLinkerImpl(MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler, TranslatorFuncTy StringsTranslator)
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.
@ DebugNames
.debug_names.
@ Apple
.apple_names, .apple_namespaces, .apple_types, .apple_objc.
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 emits DWARF data to the output stream.
Base class for all Dwarf units(Compile unit/Type table unit).
This class keeps data and services common for the whole linking process.
void setWarningHandler(MessageHandlerTy Handler)
Set warning handler.
StringPool & getStringPool()
Returns global string pool.
DWARFLinkerOptions Options
const DWARFLinkerOptions & getOptions() const
Returns linking options.
void setTranslator(TranslatorFuncTy Translator)
Set translation function.
void setErrorHandler(MessageHandlerTy Handler)
Set error handler.
void error(const Twine &Err, StringRef Context, const DWARFDie *DIE=nullptr)
Report error.
void warn(const Twine &Warning, StringRef Context, const DWARFDie *DIE=nullptr)
Report warning.
This class keeps contents and offsets to the debug sections.
void assignSectionsOffsetAndAccumulateSize(std::array< uint64_t, SectionKindsNum > &SectionSizesAccumulator)
Enumerate all sections, for each section set current offset (kept by SectionSizesAccumulator),...
void forEach(function_ref< void(SectionDescriptor &)> Handler)
Enumerate all sections and call Handler for each.
void setOutputFormat(dwarf::FormParams Format, llvm::endianness Endianness)
Sets output format for all keeping sections.
void applyPatches(SectionDescriptor &Section, StringEntryToDwarfStringPoolEntryMap &DebugStrStrings, StringEntryToDwarfStringPoolEntryMap &DebugLineStrStrings, TypeUnit *TypeUnitPtr)
Enumerate all sections, for each section apply all section patches.
LinkingGlobalData & GlobalData
const SectionDescriptor & getSectionDescriptor(DebugSectionKind SectionKind) const
Returns descriptor for the specified section of SectionKind.
llvm::endianness Endianness
Endiannes for sections.
llvm::endianness getEndianness() const
Endiannes for the sections.
SectionDescriptor & getOrCreateSectionDescriptor(DebugSectionKind SectionKind)
Returns descriptor for the specified section of SectionKind.
dwarf::FormParams Format
Format for sections.
DwarfStringPoolEntryWithExtString * add(const StringEntry *String)
Create DwarfStringPoolEntry for specified StringEntry if necessary.
DwarfStringPoolEntryWithExtString * getExistingEntry(const StringEntry *String) const
Returns already existed DwarfStringPoolEntry for the specified StringEntry.
void clear()
Erase contents of StringsForEmission.
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.
void spawn(std::function< void()> f, bool Sequential=false)
uint64_t tell() const
tell - Return the current offset with the file.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
An abstract base class for streams implementations that also support a pwrite operation.
A raw_ostream that writes to an std::string.
OutputSections CommonSections
Common sections.
std::unique_ptr< DwarfEmitterImpl > TheDwarfEmitter
The emitter of final dwarf file.
uint64_t OverallNumberOfCU
Overall compile units number.
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
void setEstimatedObjfilesAmount(unsigned ObjFilesNum) override
Set estimated objects files amount, for preliminary data allocation.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
std::optional< uint64_t > toUnsigned(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract an unsigned constant.
Error finiteLoop(function_ref< Expected< bool >()> Iteration, size_t MaxCounter=100000)
This function calls Iteration() until it returns false.
bool isODRLanguage(uint16_t Language)
std::vector< std::variant< MCSymbol *, uint64_t > > DebugNamesUnitsOffsets
static std::string remapPath(StringRef Path, const DWARFLinker::ObjectPrefixMapTy &ObjectPrefixMap)
static std::string getPCMFile(const DWARFDie &CUDie, DWARFLinker::ObjectPrefixMapTy *ObjectPrefixMap)
static void resolveRelativeObjectPath(SmallVectorImpl< char > &Buf, DWARFDie CU)
Resolve the relative path to a build artifact referenced by DWARF by applying DW_AT_comp_dir.
static uint64_t getDwoId(const DWARFDie &CUDie)
ThreadPoolStrategy strategy
bool is_relative(const Twine &path, Style style=Style::native)
Is path relative?
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
bool replace_path_prefix(SmallVectorImpl< char > &Path, StringRef OldPrefix, StringRef NewPrefix, Style style=Style::native)
Replace matching path prefix with another path.
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
This is an optimization pass for GlobalISel generic memory operations.
ThreadPoolStrategy hardware_concurrency(unsigned ThreadCount=0)
Returns a default thread strategy where all available hardware resources are to be used,...
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
void sort(IteratorTy Start, IteratorTy End)
ThreadPoolStrategy optimal_concurrency(unsigned TaskCount=0)
Returns an optimal thread strategy to execute specified amount of tasks.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
void parallelForEach(IterTy Begin, IterTy End, FuncTy Fn)
void consumeError(Error Err)
Consume a Error without doing anything.
Implement std::hash so that hash_code can be used in STL containers.
Container for dump options that control which debug information will be dumped.
DIDumpOptions noImplicitRecursion() const
Return the options with RecurseDepth set to 0 unless explicitly required.
unsigned ChildRecurseDepth
DwarfStringPoolEntry with string keeping externally.
Keep information for referenced clang module: already loaded DWARF info of the clang module and a Com...
std::unique_ptr< CompileUnit > Unit
RefModuleUnit(DWARFFile &File, std::unique_ptr< CompileUnit > Unit)
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).
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.
LinkContext(LinkingGlobalData &GlobalData, DWARFFile &File, StringMap< uint64_t > &ClangModules, std::atomic< size_t > &UniqueUnitID, std::optional< Triple > TargetTriple)
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.
Error link(TypeUnit *ArtificialTypeUnit)
Link compile units for this context.
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.
SmallVector< DWARFLinker::AccelTableKind, 1 > AccelTables
The accelerator table kinds.
bool UpdateIndexTablesOnly
Update index tables.
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::ObjectPrefixMapTy * ObjectPrefixMap
A list of remappings to apply to file paths.
bool Statistics
Print statistics.
bool NoOutput
Do not emit output.
This structure is used to update strings offsets into .debug_line_str.
This structure is used to update strings offsets into .debug_str.
const StringEntry * String
This structure keeps fields which would be used for creating accelerator table.
This structure is used to keep data of the concrete section.
void clearSectionContent()
Erase only section output data bits.
void emitInplaceString(StringRef String)
Emit specified inplace string value into the current section contents.
raw_svector_ostream OS
Stream which stores data to the Contents.
DebugSectionKind getKind()
Returns section kind.
const StringLiteral & getName() const
Returns section name.
void setSizesForSectionCreatedByAsmPrinter()
Some sections are emitted using AsmPrinter.
StringRef getContents()
Returns section content.