19using namespace dwarf_linker;
20using namespace dwarf_linker::parallel;
24 : UniqueUnitID(0), DebugStrStrings(GlobalData),
25 DebugLineStrStrings(GlobalData), CommonSections(GlobalData) {
33 std::atomic<size_t> &UniqueUnitID)
35 ClangModules(ClangModules), UniqueUnitID(UniqueUnitID) {
38 if (!File.Dwarf->compile_units().empty())
50 DWARFFile &File, std::unique_ptr<CompileUnit> Unit)
51 : File(File), Unit(
std::
move(Unit)) {}
68 for (
const std::unique_ptr<DWARFUnit> &
CU :
101 if (std::optional<std::reference_wrapper<const Triple>> CurTriple =
103 GlobalEndianness = (*CurTriple).get().isLittleEndian()
107 std::optional<uint16_t> Language;
110 if (Context->InputDWARFFile.Dwarf ==
nullptr) {
111 Context->setOutputFormat(Context->getFormParams(), GlobalEndianness);
116 outs() <<
"DEBUG MAP OBJECT: " << Context->InputDWARFFile.FileName
119 for (
const std::unique_ptr<DWARFUnit> &OrigCU :
120 Context->InputDWARFFile.Dwarf->compile_units()) {
121 outs() <<
"Input compilation unit:";
125 OrigCU->getUnitDIE().dump(
outs(), 0, DumpOpts);
134 GlobalEndianness = Context->getEndianness();
136 std::max(GlobalFormat.
AddrSize, Context->getFormParams().AddrSize);
138 Context->setOutputFormat(Context->getFormParams(), GlobalEndianness);
143 for (
const std::unique_ptr<DWARFUnit> &OrigCU :
144 Context->InputDWARFFile.Dwarf->compile_units()) {
145 DWARFDie UnitDie = OrigCU->getUnitDIE();
148 if (std::optional<DWARFFormValue> Val =
149 UnitDie.
find(dwarf::DW_AT_language)) {
159 if (std::optional<std::reference_wrapper<const Triple>> TargetTriple =
161 GlobalFormat.
AddrSize = (*TargetTriple).get().isArch32Bit() ? 4 : 8;
190 Context->InputDWARFFile.unload();
200 Context->InputDWARFFile.unload();
210 ->Children.empty()) {
240 "target DWARF version is not set");
245 "set number of threads to 1 to make --verbose to work properly.",
"");
264 CUDie.
find({dwarf::DW_AT_dwo_id, dwarf::DW_AT_GNU_dwo_id}));
273 if (ObjectPrefixMap.empty())
277 for (
const auto &Entry : ObjectPrefixMap)
280 return p.str().str();
286 CUDie.
find({dwarf::DW_AT_dwo_name, dwarf::DW_AT_GNU_dwo_name}),
"");
292 PCMFile =
remapPath(PCMFile, *ObjectPrefixMap);
298 const DWARFDie &CUDie, std::string &PCMFile,
unsigned Indent,
bool Quiet) {
300 return std::make_pair(
false,
false);
308 GlobalData.
warn(
"anonymous module skeleton CU for " + PCMFile +
".",
310 return std::make_pair(
true,
true);
315 outs() <<
"Found clang module reference " << PCMFile;
325 Twine(
"hash mismatch: this object file was built against a "
326 "different version of the module ") +
330 outs() <<
" [cached].\n";
331 return std::make_pair(
true,
true);
334 return std::make_pair(
true,
false);
346 std::string PCMFile =
348 std::pair<bool, bool> IsClangModuleRef =
351 if (!IsClangModuleRef.first)
354 if (IsClangModuleRef.second)
387 if (Loader ==
nullptr) {
397 std::unique_ptr<CompileUnit> Unit;
398 for (
const auto &
CU : ErrOrObj->Dwarf->compile_units()) {
401 auto ChildCUDie =
CU->getUnitDIE();
408 ": Clang modules are expected to have exactly 1 compile unit.\n");
416 if (PCMDwoId != DwoId) {
419 Twine(
"hash mismatch: this object file was built against a "
420 "different version of the module ") +
428 if (!ChildCUDie.hasChildren())
432 Unit = std::make_unique<CompileUnit>(
466 outs() <<
"No valid relocations found. Skipping.\n";
476 auto CUDie = OrigCU->getUnitDIE();
477 std::string PCMFile =
510 if (
CU->isInterconnectedCU()) {
511 CU->maybeResetToLoadedStage();
512 linkSingleCompileUnit(*CU, ArtificialTypeUnit,
513 CompileUnit::Stage::Loaded);
539 if (
CU->isInterconnectedCU() &&
583 ResultErr = std::move(Err);
598 if (
CU.getStage() >= DoUntilStage)
601 switch (
CU.getStage()) {
602 case CompileUnit::Stage::CreatedNotLoaded: {
605 if (!CU.loadInputDIEs()) {
608 CU.setStage(CompileUnit::Stage::Skipped);
610 CU.analyzeDWARFStructure();
617 if (registerModuleReference(
618 CU.getOrigUnit().getUnitDIE(), nullptr,
619 [](const DWARFUnit &) {}, 0))
620 CU.setStage(CompileUnit::Stage::PatchesUpdated);
622 CU.setStage(CompileUnit::Stage::Loaded);
629 if (!CU.resolveDependenciesAndMarkLiveness(InterCUProcessingStarted,
630 HasNewInterconnectedCUs)) {
631 assert(HasNewInterconnectedCUs &&
632 "Flag indicating new inter-connections is not set");
641 if (
CU.updateDependenciesCompleteness())
646 return CU.updateDependenciesCompleteness();
648 return std::move(Err);
656 CU.verifyDependencies();
662 return std::move(Err);
669 if (
CU.isClangModule() ||
671 CU.getContaingFile().Addresses->hasValidRelocs()) {
672 if (Error Err = CU.cloneAndEmit(GlobalData.getTargetTriple(),
674 return std::move(Err);
682 CU.updateDieRefPatchesWithClonedOffsets();
688 CU.cleanupDataAfterClonning();
703 CU.error(std::move(Err));
704 CU.cleanupDataAfterClonning();
741 if (OrigFrameData.
empty())
745 for (std::unique_ptr<CompileUnit> &Unit :
CompileUnits) {
746 for (
auto CurRange : Unit->getFunctionRanges())
747 AllUnitsRanges.
insert(CurRange.Range, CurRange.Value);
766 while (
Data.isValidOffset(InputOffset)) {
769 if (InitialLength == 0xFFFFFFFF)
772 "Dwarf64 bits no supported"));
775 if (CIEId == 0xFFFFFFFF) {
777 StringRef CIEData = OrigFrameData.
substr(EntryOffset, InitialLength + 4);
778 LocalCIES[EntryOffset] = CIEData;
780 InputOffset += InitialLength - 4;
784 uint64_t Loc =
Data.getUnsigned(&InputOffset, SrcAddrSize);
790 std::optional<AddressRangeValuePair>
Range =
794 InputOffset = EntryOffset + InitialLength + 4;
805 "Inconsistent debug_frame content. Dropping."));
811 auto IteratorInserted =
812 EmittedCIEs.
insert(std::make_pair(CIEData, OffsetToCIERecord));
813 OffsetToCIERecord = IteratorInserted.first->getValue();
816 if (IteratorInserted.second)
817 OutSection.
OS << CIEData;
824 OutSection.notePatch(
830 unsigned FDERemainingBytes = InitialLength - (4 + SrcAddrSize);
831 emitFDE(OffsetToCIERecord, SrcAddrSize, Loc +
Range->Value,
832 OrigFrameData.
substr(InputOffset, FDERemainingBytes), OutSection);
833 InputOffset += FDERemainingBytes;
846 Section.emitIntVal(FDEBytes.
size() + 4 + AddrSize, 4);
847 Section.emitIntVal(CIEOffset, 4);
848 Section.emitIntVal(
Address, AddrSize);
849 Section.OS.write(FDEBytes.
data(), FDEBytes.
size());
886 for (
const std::unique_ptr<LinkContext> &Context :
ObjectContexts) {
887 uint64_t AllDebugInfoSectionsSize = 0;
889 for (std::unique_ptr<CompileUnit> &
CU : Context->CompileUnits)
890 if (std::optional<SectionDescriptor *>
DebugInfo =
892 AllDebugInfoSectionsSize += (*DebugInfo)->getContents().size();
894 SizeByObject[Context->InputDWARFFile.FileName].Input =
895 Context->OriginalDebugInfoSize;
896 SizeByObject[Context->InputDWARFFile.FileName].Output =
897 AllDebugInfoSectionsSize;
901 std::vector<std::pair<StringRef, DebugInfoSize>> Sorted;
902 for (
auto &E : SizeByObject)
903 Sorted.emplace_back(E.first(), E.second);
905 return LHS.second.Output >
RHS.second.Output;
908 auto ComputePercentange = [](int64_t Input, int64_t Output) ->
float {
909 const float Difference = Output - Input;
910 const float Sum = Input + Output;
913 return (Difference / (Sum / 2));
916 int64_t InputTotal = 0;
917 int64_t OutputTotal = 0;
918 const char *FormatStr =
"{0,-45} {1,10}b {2,10}b {3,8:P}\n";
921 outs() <<
".debug_info section size (in bytes)\n";
922 outs() <<
"----------------------------------------------------------------"
924 outs() <<
"Filename Object "
926 outs() <<
"----------------------------------------------------------------"
930 for (
auto &E : Sorted) {
931 InputTotal += E.second.Input;
932 OutputTotal += E.second.Output;
935 E.second.Output, ComputePercentange(E.second.Input, E.second.Output));
938 outs() <<
"----------------------------------------------------------------"
941 ComputePercentange(InputTotal, OutputTotal));
942 outs() <<
"----------------------------------------------------------------"
943 "---------------\n\n";
953 size_t CurDebugStrIndex = 1;
956 size_t CurDebugLineStrIndex = 0;
968 if (!Entry->isIndexed()) {
969 Entry->Offset = CurDebugStrOffset;
970 CurDebugStrOffset += Entry->String.size() + 1;
971 Entry->Index = CurDebugStrIndex++;
979 if (!Entry->isIndexed()) {
980 Entry->Offset = CurDebugLineStrOffset;
981 CurDebugLineStrOffset += Entry->String.size() + 1;
982 Entry->Index = CurDebugLineStrIndex++;
990 std::array<uint64_t, SectionKindsNum> SectionSizesAccumulator = {0};
1007 OutSection.ListDebugStrPatch.forEach([&](
DebugStrPatch &Patch) {
1023 OutSection.ListDebugStrPatch.forEach([&](
DebugStrPatch &Patch) {
1032 if (Patch.Die ==
nullptr)
1038 OutSection.ListDebugTypeLineStrPatch.forEach(
1040 if (Patch.Die ==
nullptr)
1056 for (
const std::unique_ptr<LinkContext> &Context :
ObjectContexts)
1059 SectionsSetHandler(*ModuleUnit.
Unit);
1062 for (
const std::unique_ptr<LinkContext> &Context :
ObjectContexts) {
1064 SectionsSetHandler(*Context);
1067 for (std::unique_ptr<CompileUnit> &
CU : Context->CompileUnits)
1069 SectionsSetHandler(*
CU);
1079 for (
const std::unique_ptr<LinkContext> &Context :
ObjectContexts)
1082 UnitHandler(ModuleUnit.
Unit.get());
1085 for (
const std::unique_ptr<LinkContext> &Context :
ObjectContexts)
1086 for (std::unique_ptr<CompileUnit> &
CU : Context->CompileUnits)
1088 UnitHandler(
CU.get());
1094 for (
const std::unique_ptr<LinkContext> &Context :
ObjectContexts)
1097 UnitHandler(ModuleUnit.
Unit.get());
1100 for (
const std::unique_ptr<LinkContext> &Context :
ObjectContexts)
1101 for (std::unique_ptr<CompileUnit> &
CU : Context->CompileUnits)
1103 UnitHandler(
CU.get());
1163 uint64_t DebugLineStrNextOffset = 0;
1169 DebugStrNextOffset++;
1182 if (StringToEmit->
Offset >= DebugStrNextOffset) {
1183 DebugStrNextOffset =
1198 if (StringToEmit->
Offset >= DebugLineStrNextOffset) {
1199 DebugLineStrNextOffset =
1219 switch (
Info.Type) {
1220 case DwarfUnit::AccelType::None: {
1221 llvm_unreachable(
"Unknown accelerator record");
1224 AppleNamespaces.addName(
1225 *DebugStrStrings.getExistingEntry(Info.String),
1226 CU->getSectionDescriptor(DebugSectionKind::DebugInfo).StartOffset +
1231 *DebugStrStrings.getExistingEntry(Info.String),
1232 CU->getSectionDescriptor(DebugSectionKind::DebugInfo).StartOffset +
1237 *DebugStrStrings.getExistingEntry(Info.String),
1238 CU->getSectionDescriptor(DebugSectionKind::DebugInfo).StartOffset +
1243 *DebugStrStrings.getExistingEntry(Info.String),
1244 CU->getSectionDescriptor(DebugSectionKind::DebugInfo).StartOffset +
1247 Info.ObjcClassImplementation ? dwarf::DW_FLAG_type_implementation
1249 Info.QualifiedNameHash);
1263 if (
Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1284 if (
Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1305 if (
Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1326 if (
Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1341 std::unique_ptr<DWARF5AccelTable>
DebugNames;
1349 bool HasRecords =
false;
1352 DebugNames = std::make_unique<DWARF5AccelTable>();
1355 switch (
Info.Type) {
1356 case DwarfUnit::AccelType::Name:
1357 case DwarfUnit::AccelType::Namespace:
1358 case DwarfUnit::AccelType::Type: {
1359 DebugNames->addName(*DebugStrStrings.getExistingEntry(Info.String),
1360 Info.OutOffset, std::nullopt ,
1361 Info.Tag, CU->getUniqueID(),
1362 CU->getTag() == dwarf::DW_TAG_type_unit);
1371 CompUnits.push_back(
1374 CUidToIdx[
CU->getUniqueID()] = Id++;
1386 if (
Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1409 Sections.
forEach([&](std::shared_ptr<SectionDescriptor> OutSection) {
Analysis containing CSE Info
dxil DXContainer Global Emitter
static fatal_error_handler_t ErrorHandler
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
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.
A non-threaded implementation.
void wait() override
Blocking wait for all the tasks to execute first.
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)
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.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
StringRef take_back(size_t N=1) const
Return a StringRef equal to 'this' but with only the last N elements remaining.
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...
This class represents DWARF information for source file and it's address map.
std::unique_ptr< AddressesMap > Addresses
Helpful address information(list of valid address ranges, relocations).
StringRef FileName
Object file name.
std::unique_ptr< DWARFContext > Dwarf
Source DWARF information.
std::map< std::string, std::string > ObjectPrefixMapTy
@ DebugNames
.debug_names.
@ Apple
.apple_names, .apple_namespaces, .apple_types, .apple_objc.
std::function< void(const Twine &Warning, StringRef Context, const DWARFDie *DIE)> MessageHandlerTy
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.
@ 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.
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.
DWARFLinkerImpl(MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler)
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 emitCommonSectionsAndWriteCompileUnitsToTheOutput()
Emit debug sections common for all input files.
void patchOffsetsAndSizes()
Enumerates all patches and update them with the correct values.
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.
DWARFLinkerOptions Options
void warn(const Twine &Warning, StringRef Context, const DWARFDie *DIE=nullptr)
Report warning.
const DWARFLinkerOptions & getOptions() const
Returns linking options.
void setErrorHandler(MessageHandlerTy Handler)
Set error handler.
void error(const Twine &Err, StringRef Context, const DWARFDie *DIE=nullptr)
Report error.
void setWarningHandler(MessageHandlerTy Handler)
Set warning handler.
StringPool & getStringPool()
Returns global string pool.
std::optional< std::reference_wrapper< const Triple > > getTargetTriple()
Optionally return target triple.
This class keeps contents and offsets to the debug sections.
void applyPatches(SectionDescriptor &Section, StringEntryToDwarfStringPoolEntryMap &DebugStrStrings, StringEntryToDwarfStringPoolEntryMap &DebugLineStrStrings, TypeUnit *TypeUnitPtr)
Enumerate all sections, for each section apply all section patches.
LinkingGlobalData & GlobalData
llvm::endianness Endianness
Endiannes for sections.
dwarf::FormParams Format
Format for sections.
void setOutputFormat(dwarf::FormParams Format, llvm::endianness Endianness)
Sets output format for all keeping sections.
void forEach(function_ref< void(SectionDescriptor &)> Handler)
Enumerate all sections and call Handler for each.
llvm::endianness getEndianness() const
Endiannes for the sections.
SectionDescriptor & getOrCreateSectionDescriptor(DebugSectionKind SectionKind)
Returns descriptor for the specified section of SectionKind.
void assignSectionsOffsetAndAccumulateSize(std::array< uint64_t, SectionKindsNum > &SectionSizesAccumulator)
Enumerate all sections, for each section set current offset (kept by SectionSizesAccumulator),...
const SectionDescriptor & getSectionDescriptor(DebugSectionKind SectionKind) const
Returns descriptor for the specified section of SectionKind.
void clear()
Erase contents of StringsForEmission.
DwarfStringPoolEntryWithExtString * getExistingEntry(const StringEntry *String) const
Returns already existed DwarfStringPoolEntry for the specified StringEntry.
DwarfStringPoolEntryWithExtString * add(const StringEntry *String)
Create DwarfStringPoolEntry for specified StringEntry if necessary.
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.
A raw_ostream that writes to an std::string.
LinkingGlobalData GlobalData
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.
OutputSections CommonSections
Common sections.
void setEstimatedObjfilesAmount(unsigned ObjFilesNum) override
Set estimated objects files amount, for preliminary data allocation.
bool isODRLanguage(uint16_t Language)
std::vector< std::variant< MCSymbol *, uint64_t > > DebugNamesUnitsOffsets
Error finiteLoop(function_ref< Expected< bool >()> Iteration, size_t MaxCounter=100000)
This function calls Iteration() until it returns false.
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.
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,...
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.
auto formatv(const char *Fmt, Ts &&...Vals) -> formatv_object< decltype(std::make_tuple(support::detail::build_format_adapter(std::forward< Ts >(Vals))...))>
static std::string remapPath(StringRef Path, const DWARFLinkerBase::ObjectPrefixMapTy &ObjectPrefixMap)
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
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 std::string getPCMFile(const DWARFDie &CUDie, const DWARFLinkerBase::ObjectPrefixMapTy *ObjectPrefixMap)
void sort(IteratorTy Start, IteratorTy End)
ThreadPoolStrategy optimal_concurrency(unsigned TaskCount=0)
Returns an optimal thread strategy to execute specified amount of tasks.
static uint64_t getDwoId(const DWARFDie &CUDie)
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...
RefModuleUnit(DWARFFile &File, std::unique_ptr< CompileUnit > Unit)
std::unique_ptr< CompileUnit > Unit
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.
LinkContext(LinkingGlobalData &GlobalData, DWARFFile &File, StringMap< uint64_t > &ClangModules, std::atomic< size_t > &UniqueUnitID)
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.
Error link(TypeUnit *ArtificialTypeUnit)
Link compile units for this context.
std::atomic< bool > HasNewGlobalDependency
std::function< CompileUnit *(uint64_t)> getUnitForOffset
ModuleUnitListTy ModulesCompileUnits
Set of Compile Units for modules.
DWARFLinkerBase::ObjectPrefixMapTy * ObjectPrefixMap
A list of remappings to apply to file paths.
bool Verbose
Generate processing log to the standard output.
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.
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 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.
raw_svector_ostream OS
Stream which stores data to the Contents.
void setSizesForSectionCreatedByAsmPrinter()
Some sections are emitted using AsmPrinter.
void emitInplaceString(StringRef String)
Emit specified inplace string value into the current section contents.