39 if (!File.Dwarf->compile_units().empty())
40 CompileUnits.reserve(File.Dwarf->getNumCompileUnits());
43 Format.Version = File.Dwarf->getMaxVersion();
44 Format.AddrSize = File.Dwarf->getCUAddrSize();
45 Endianness = File.Dwarf->isLittleEndian() ? llvm::endianness::little
46 : llvm::endianness::big;
57 for (
const std::unique_ptr<DWARFUnit> &
CU :
67 if (!
GlobalData.getOptions().UpdateIndexTablesOnly)
91 if (std::optional<std::reference_wrapper<const Triple>> CurTriple =
93 GlobalEndianness = (*CurTriple).get().isLittleEndian()
97 std::optional<uint16_t> Language;
100 if (Context->InputDWARFFile.Dwarf ==
nullptr) {
101 Context->setOutputFormat(Context->getFormParams(), GlobalEndianness);
106 outs() <<
"DEBUG MAP OBJECT: " << Context->InputDWARFFile.FileName
109 for (
const std::unique_ptr<DWARFUnit> &OrigCU :
110 Context->InputDWARFFile.Dwarf->compile_units()) {
111 outs() <<
"Input compilation unit:";
115 OrigCU->getUnitDIE().dump(
outs(), 0, DumpOpts);
124 GlobalEndianness = Context->getEndianness();
126 std::max(GlobalFormat.
AddrSize, Context->getFormParams().AddrSize);
128 Context->setOutputFormat(Context->getFormParams(), GlobalEndianness);
133 for (
const std::unique_ptr<DWARFUnit> &OrigCU :
134 Context->InputDWARFFile.Dwarf->compile_units()) {
135 DWARFDie UnitDie = OrigCU->getUnitDIE();
138 if (std::optional<uint64_t> LangVal = UnitDie.
getLanguage())
140 Language =
static_cast<uint16_t
>(*LangVal);
148 for (
const std::unique_ptr<CompileUnit> &
Module :
149 Context->ModulesCompileUnits) {
151 if (std::optional<uint16_t> LangVal =
Module->getLanguage())
159 if (std::optional<std::reference_wrapper<const Triple>> TargetTriple =
161 GlobalFormat.
AddrSize = (*TargetTriple).get().isArch32Bit() ? 4 : 8;
168 if (!
GlobalData.Options.NoODR && Language.has_value()) {
192 GlobalData.error(std::move(Err), Context->InputDWARFFile.FileName);
193 if (
Error Err = Context->unloadInput())
194 GlobalData.error(std::move(Err), Context->InputDWARFFile.FileName);
203 GlobalData.error(std::move(Err), Context->InputDWARFFile.FileName);
204 if (
Error Err = Context->unloadInput())
205 GlobalData.error(std::move(Err), Context->InputDWARFFile.FileName);
213 GlobalData.Options.ParseableSwiftInterfaces) {
215 for (std::unique_ptr<CompileUnit> &ModuleUnit :
216 Context->ModulesCompileUnits)
217 ModuleUnit->mergeSwiftInterfaces(*SwiftInterfaces);
218 for (std::unique_ptr<CompileUnit> &
CU : Context->CompileUnits)
219 CU->mergeSwiftInterfaces(*SwiftInterfaces);
225 if (!
GlobalData.getOptions().UpdateIndexTablesOnly) {
228 if (Context->FrameScan)
229 Context->registerCIEs(CIEs);
233 if (!Context->FrameScan)
236 if (
Error Err = Context->emitDebugFrame(CIEs))
237 GlobalData.error(std::move(Err), Context->InputDWARFFile.FileName);
246 ->Children.empty()) {
268 if (
GlobalData.getOptions().InputVerificationHandler)
269 GlobalData.getOptions().InputVerificationHandler(File, OS.
str());
274 if (
GlobalData.getOptions().TargetDWARFVersion == 0)
276 "target DWARF version is not set");
281 "set number of threads to 1 to make --verbose to work properly.",
"");
285 if (
GlobalData.getOptions().UpdateIndexTablesOnly &&
302 CUDie.
find({dwarf::DW_AT_dwo_id, dwarf::DW_AT_GNU_dwo_id}));
311 if (ObjectPrefixMap.empty())
315 for (
const auto &Entry : ObjectPrefixMap)
318 return p.str().str();
325 CUDie.
find({dwarf::DW_AT_dwo_name, dwarf::DW_AT_GNU_dwo_name}),
"");
331 PCMFile =
remapPath(PCMFile, *ObjectPrefixMap);
333 return File.remapPath(PCMFile);
337 const DWARFDie &CUDie, std::string &PCMFile,
unsigned Indent,
bool Quiet) {
339 return std::make_pair(
false,
false);
347 GlobalData.warn(
"anonymous module skeleton CU for " + PCMFile +
".",
349 return std::make_pair(
true,
true);
354 outs() <<
"Found clang module reference " << PCMFile;
362 if (!
Quiet &&
GlobalData.getOptions().Verbose && (Cached->second != DwoId))
364 Twine(
"hash mismatch: this object file was built against a "
365 "different version of the module ") +
369 outs() <<
" [cached].\n";
370 return std::make_pair(
true,
true);
373 return std::make_pair(
true,
false);
387 std::pair<bool, bool> IsClangModuleRef =
390 if (!IsClangModuleRef.first)
393 if (IsClangModuleRef.second)
426 if (Loader ==
nullptr) {
427 GlobalData.error(
"cann't load clang module: loader is not specified.",
438 if (!ErrOrObj->PrefixMap)
441 std::unique_ptr<CompileUnit> Unit;
442 for (
const auto &
CU : ErrOrObj->Dwarf->compile_units()) {
445 auto ChildCUDie =
CU->getUnitDIE();
452 ": Clang modules are expected to have exactly 1 compile unit.\n");
459 uint64_t PCMDwoId =
getDwoId(ChildCUDie);
460 if (PCMDwoId != DwoId) {
463 Twine(
"hash mismatch: this object file was built against a "
464 "different version of the module ") +
472 if (!ChildCUDie.hasChildren())
476 Unit = std::make_unique<CompileUnit>(
511 assert(!
Mod->isInterconnectedCU() &&
"module unit is inter-connected");
517 if (!
GlobalData.getOptions().UpdateIndexTablesOnly &&
520 outs() <<
"No valid relocations found. Skipping.\n";
528 uint64_t LocalCUIdx = 0;
529 for (
const auto &OrigCU :
InputDWARFFile.Dwarf->compile_units()) {
531 auto CUDie = OrigCU->getUnitDIE();
537 if (!CUDie ||
GlobalData.getOptions().UpdateIndexTablesOnly ||
539 CompileUnits.emplace_back(std::make_unique<CompileUnit>(
568 if (
CU->isInterconnectedCU()) {
569 CU->maybeResetToLoadedStage();
597 if (
CU->isInterconnectedCU() &&
631 CU->saveRelocations();
633 if (
GlobalData.getOptions().UpdateIndexTablesOnly) {
650 if (
CU.getStage() >= DoUntilStage)
653 switch (
CU.getStage()) {
657 if (!
CU.loadInputDIEs()) {
662 CU.analyzeDWARFStructure();
673 if (!
GlobalData.getOptions().UpdateIndexTablesOnly &&
675 CU.getOrigUnit().getUnitDIE(),
nullptr,
684 CU.collectLiveRoots();
694 "Flag indicating new inter-connections is not set");
703 if (
CU.updateDependenciesCompleteness())
708 return CU.updateDependenciesCompleteness();
710 return std::move(Err);
718 CU.verifyDependencies();
724 return std::move(Err);
731 if (
CU.isClangModule() ||
732 GlobalData.getOptions().UpdateIndexTablesOnly ||
733 CU.getContainingFile().Addresses->hasValidRelocs()) {
736 return std::move(Err);
744 CU.updateDieRefPatchesWithClonedOffsets();
749 if (
CU.isClangModule())
750 CU.noteModuleAnchors();
757 CU.cleanupDataAfterClonning();
772 CU.error(std::move(Err));
773 CU.cleanupDataAfterClonning();
779 if (!
GlobalData.getTargetTriple().has_value())
801 if (
GlobalData.getOptions().UpdateIndexTablesOnly)
803 if (!
GlobalData.getTargetTriple().has_value())
814 if (OrigFrameData.
empty())
817 auto Scan = std::make_unique<FrameScanResult>();
818 Scan->FrameData = OrigFrameData;
822 for (std::unique_ptr<CompileUnit> &Unit :
CompileUnits) {
823 for (
auto CurRange : Unit->getFunctionRanges())
824 AllUnitsRanges.
insert(CurRange.Range, CurRange.Value);
829 uint64_t InputOffset = 0;
830 const unsigned SrcAddrSize = Scan->AddressSize;
833 constexpr unsigned CIEPointerSize = 4;
839 while (
Data.isValidOffset(InputOffset)) {
840 uint64_t EntryOffset = InputOffset;
842 if (InitialLength == 0xFFFFFFFF)
845 "Dwarf64 bits not supported"));
850 if (InitialLength > FrameBytes.
size() - InputOffset)
854 "Truncated .debug_frame entry."));
857 if (CIEId == 0xFFFFFFFF) {
860 LocalCIEs[EntryOffset] = CIEData;
862 InputOffset += InitialLength - 4;
866 uint64_t
Loc =
Data.getUnsigned(&InputOffset, SrcAddrSize);
872 std::optional<AddressRangeValuePair>
Range =
876 InputOffset = EntryOffset + InitialLength + 4;
886 "Inconsistent debug_frame content. Dropping."));
891 if (InitialLength < CIEPointerSize + SrcAddrSize)
894 "Truncated .debug_frame FDE."));
898 if (AddedCIEs.
insert(CIEId).second)
899 Scan->CIEs.push_back(CIEData);
901 unsigned FDERemainingBytes = InitialLength - (CIEPointerSize + SrcAddrSize);
902 Scan->FDEs.push_back({CIEData,
Loc +
Range->Value,
903 FrameBytes.
substr(InputOffset, FDERemainingBytes)});
904 InputOffset += FDERemainingBytes;
918 auto [It, Inserted] =
921 FrameScan->OwnedCIEs.push_back(CIEBytes);
922 NextLocalOffset +=
static_cast<uint32_t>(CIEBytes.
size());
934 OutSection.
OS << CIEBytes;
937 const unsigned SrcAddrSize =
FrameScan->AddressSize;
941 assert(It != CIEs.
end() &&
"CIE missing from registry");
943 const uint32_t CIELocalOffset = It->second.LocalOffset;
945 const uint64_t FDEPos = OutSection.
OS.
tell();
952 if (FDEPos >
FP.getDwarfMaxOffset())
987 Section.emitIntVal(FDEBytes.
size() + 4 + AddrSize, 4);
988 Section.emitIntVal(CIEOffset, 4);
989 Section.emitIntVal(
Address, AddrSize);
990 Section.OS.write(FDEBytes.
data(), FDEBytes.
size());
994 if (!
GlobalData.getTargetTriple().has_value())
1029 for (
const std::unique_ptr<LinkContext> &Context :
ObjectContexts) {
1030 uint64_t AllDebugInfoSectionsSize = 0;
1032 for (std::unique_ptr<CompileUnit> &
CU : Context->CompileUnits)
1033 if (std::optional<SectionDescriptor *>
DebugInfo =
1035 AllDebugInfoSectionsSize += (*DebugInfo)->getContents().size();
1037 auto &
Size = SizeByObject[Context->InputDWARFFile.FileName];
1038 Size.Input = Context->OriginalDebugInfoSize;
1039 Size.Output = AllDebugInfoSectionsSize;
1043 std::vector<std::pair<StringRef, DebugInfoSize>> Sorted;
1044 for (
auto &E : SizeByObject)
1045 Sorted.emplace_back(E.first(), E.second);
1046 llvm::sort(Sorted, [](
auto &LHS,
auto &RHS) {
1047 return LHS.second.Output > RHS.second.Output;
1050 auto ComputePercentange = [](int64_t
Input, int64_t Output) ->
float {
1051 const float Difference = Output -
Input;
1052 const float Sum =
Input + Output;
1055 return (Difference / (Sum / 2));
1058 int64_t InputTotal = 0;
1059 int64_t OutputTotal = 0;
1060 const char *FormatStr =
"{0,-45} {1,10}b {2,10}b {3,8:P}\n";
1063 outs() <<
".debug_info section size (in bytes)\n";
1064 outs() <<
"----------------------------------------------------------------"
1065 "---------------\n";
1066 outs() <<
"Filename Object "
1068 outs() <<
"----------------------------------------------------------------"
1069 "---------------\n";
1072 for (
auto &E : Sorted) {
1073 InputTotal += E.second.Input;
1074 OutputTotal += E.second.Output;
1077 E.second.Output, ComputePercentange(E.second.Input, E.second.Output));
1080 outs() <<
"----------------------------------------------------------------"
1081 "---------------\n";
1083 ComputePercentange(InputTotal, OutputTotal));
1084 outs() <<
"----------------------------------------------------------------"
1085 "---------------\n\n";
1095 size_t CurDebugStrIndex = 1;
1096 uint64_t CurDebugStrOffset =
1098 size_t CurDebugLineStrIndex = 0;
1099 uint64_t CurDebugLineStrOffset = 0;
1108 assert(Entry !=
nullptr);
1110 if (!Entry->isIndexed()) {
1111 Entry->Offset = CurDebugStrOffset;
1112 CurDebugStrOffset += Entry->String.size() + 1;
1113 Entry->Index = CurDebugStrIndex++;
1119 assert(Entry !=
nullptr);
1121 if (!Entry->isIndexed()) {
1122 Entry->Offset = CurDebugLineStrOffset;
1123 CurDebugLineStrOffset += Entry->String.size() + 1;
1124 Entry->Index = CurDebugLineStrIndex++;
1132 std::array<uint64_t, SectionKindsNum> SectionSizesAccumulator = {0};
1149 OutSection.ListDebugStrPatch.forEach([&](
DebugStrPatch &Patch) {
1159 StringHandler(
DebugStr, Info.String);
1165 OutSection.ListDebugStrPatch.forEach([&](
DebugStrPatch &Patch) {
1174 if (Patch.Die ==
nullptr)
1178 if (&
TypeEntry->getFinalDie() != Patch.Die)
1184 OutSection.ListDebugTypeLineStrPatch.forEach(
1186 if (Patch.Die ==
nullptr)
1190 if (&
TypeEntry->getFinalDie() != Patch.Die)
1206 for (
const std::unique_ptr<LinkContext> &Context :
ObjectContexts)
1207 for (std::unique_ptr<CompileUnit> &ModuleUnit :
1208 Context->ModulesCompileUnits)
1210 SectionsSetHandler(*ModuleUnit);
1213 for (
const std::unique_ptr<LinkContext> &Context :
ObjectContexts) {
1215 SectionsSetHandler(*Context);
1218 for (std::unique_ptr<CompileUnit> &
CU : Context->CompileUnits)
1220 SectionsSetHandler(*
CU);
1230 for (
const std::unique_ptr<LinkContext> &Context :
ObjectContexts)
1231 for (std::unique_ptr<CompileUnit> &ModuleUnit :
1232 Context->ModulesCompileUnits)
1234 UnitHandler(ModuleUnit.get());
1237 for (
const std::unique_ptr<LinkContext> &Context :
ObjectContexts)
1238 for (std::unique_ptr<CompileUnit> &
CU : Context->CompileUnits)
1240 UnitHandler(
CU.get());
1246 for (
const std::unique_ptr<LinkContext> &Context :
ObjectContexts)
1247 for (std::unique_ptr<CompileUnit> &ModuleUnit :
1248 Context->ModulesCompileUnits)
1250 UnitHandler(ModuleUnit.get());
1253 for (
const std::unique_ptr<LinkContext> &Context :
ObjectContexts)
1254 for (std::unique_ptr<CompileUnit> &
CU : Context->CompileUnits)
1256 UnitHandler(
CU.get());
1315 uint64_t DebugStrNextOffset = 0;
1316 uint64_t DebugLineStrNextOffset = 0;
1321 .emitInplaceString(
"");
1322 DebugStrNextOffset++;
1335 if (StringToEmit->
Offset >= DebugStrNextOffset) {
1336 DebugStrNextOffset =
1340 .emitInplaceString(StringToEmit->
String);
1351 if (StringToEmit->
Offset >= DebugLineStrNextOffset) {
1352 DebugLineStrNextOffset =
1356 .emitInplaceString(StringToEmit->
String);
1371 uint64_t OutOffset = Info.OutOffset;
1372 switch (Info.Type) {
1402 Info.QualifiedNameHash);
1416 if (
Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1437 if (
Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1458 if (
Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1479 if (
Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1494 std::unique_ptr<DWARF5AccelTable>
DebugNames;
1502 bool HasRecords =
false;
1505 DebugNames = std::make_unique<DWARF5AccelTable>();
1508 switch (Info.Type) {
1513 Info.OutOffset, Info.ParentOffset, Info.Tag,
1515 CU->getTag() == dwarf::DW_TAG_type_unit);
1524 CompUnits.push_back(
1527 CUidToIdx[
CU->getUniqueID()] = Id++;
1539 if (
Error Err =
Emitter.init(TargetTriple,
"__DWARF")) {
1562 Sections.
forEach([&](std::shared_ptr<SectionDescriptor> OutSection) {
1570 CommonSections.forEach([&](std::shared_ptr<SectionDescriptor> OutSection) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
dxil container DXContainer Global Emitter
static fatal_error_handler_t ErrorHandler
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...
std::optional< T > getRangeThatContains(uint64_t Addr) const
void insert(AddressRange Range, int64_t Value)
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
LLVM_ABI std::optional< DWARFFormValue > find(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE.
LLVM_ABI std::optional< uint64_t > getLanguage() const
Returns the DW_LANG_ code for this DIE's DWARF unit, if it exists.
virtual bool isLittleEndian() const =0
virtual const DWARFSection & getFrameSection() const
virtual uint8_t getAddressSize() const
ValueT lookup(const_arg_type_t< KeyT > Val) const
Return the entry for the specified key, or a default constructed value if no such entry exists.
Implements a dense probed hash-table based set.
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 Module instance is used to store all the information related to an LLVM module.
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...
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
iterator find(StringRef Key)
std::pair< iterator, bool > try_emplace(StringRef Key, ArgsTy &&...Args)
Emplace a new element for the specified key into the map if the key isn't already in the map.
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
Check if the string is empty.
constexpr size_t size() const
Get the string size.
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
A group of tasks to be run on a thread pool.
auto async(Function &&F, Args &&...ArgList)
Calls ThreadPool::async() for this group.
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static Twine utohexstr(uint64_t Val)
std::pair< iterator, bool > insert(const ValueT &V)
This class represents DWARF information for source file and it's address map.
std::map< std::string, std::string > ObjectPrefixMapTy
function_ref< void(const DWARFUnit &Unit)> CompileUnitHandlerTy
std::function< void( const Twine &Warning, StringRef Context, const DWARFDie *DIE)> MessageHandlerTy
@ DebugNames
.debug_names.
@ Apple
.apple_names, .apple_namespaces, .apple_types, .apple_objc.
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.
@ Cloned
Output DWARF is generated.
@ TypeNamesAssigned
Type names assigned to DIEs.
@ LiveRootsCollected
DIEs with a live address are found.
@ CreatedNotLoaded
Created, linked with input DWARF file.
@ 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 and theDIEs they depend on are marked)...
@ 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.
static constexpr uint64_t ModuleUnitObjFileIdx
The object file index given to every clang module unit.
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.
static constexpr uint64_t FirstObjFileIdx
Object file indices follow the module units'.
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.
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.
OutputSections(LinkingGlobalData &GlobalData)
LinkingGlobalData & GlobalData
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.
Keeps cloned data for the type DIE.
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.
LLVM_ABI void spawn(std::function< void()> f)
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.
std::string & str()
Returns the string's reference.
ThreadPoolInterface * ThreadPool
Thread pool that links the object files, or null to use a private pool.
LinkingGlobalData GlobalData
std::atomic< size_t > UniqueUnitID
Unique ID for compile unit.
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.
uint64_t ModuleUnitIdx
Numbers the clang module units of the whole link, so that they form one priority sequence regardless ...
OutputSections CommonSections
Common sections.
StringMap< uint64_t > ClangModules
Mapping the PCM filename to the DwoId.
LLVM_ABI StringRef FormatString(DwarfFormat Format)
void setEstimatedObjfilesAmount(unsigned ObjFilesNum) override
Set estimated objects files amount, for preliminary data allocation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isODRLanguage(uint16_t Language)
std::vector< std::variant< MCSymbol *, uint64_t > > DebugNamesUnitsOffsets
DenseMap< unsigned, unsigned > CompUnitIDToIdx
StringMapEntry< std::atomic< TypeEntryBody * > > TypeEntry
StringMapEntry< EmptyStringSetTag > StringEntry
StringEntry keeps data of the string: the length, external offset and a string body which is placed r...
Error finiteLoop(function_ref< Expected< bool >()> Iteration, size_t MaxCounter=100000)
This function calls Iteration() until it returns false.
AddressRangesMap RangesTy
Mapped value in the address map is the offset to apply to the linked address.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
StringRef toStringRef(const std::optional< DWARFFormValue > &V, StringRef Default={})
Take an optional DWARFFormValue and try to extract a string value from it.
@ DW_FLAG_type_implementation
std::optional< uint64_t > toUnsigned(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract an unsigned constant.
LLVM_ABI ThreadPoolStrategy strategy
LLVM_ABI bool is_relative(const Twine &path, Style style=Style::native)
Is path relative?
LLVM_ABI StringRef filename(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get filename.
LLVM_ABI bool replace_path_prefix(SmallVectorImpl< char > &Path, StringRef OldPrefix, StringRef NewPrefix, Style style=Style::native)
Replace matching path prefix with another path.
LLVM_ABI 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.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
LLVM_ABI raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
static std::string getPCMFile(const DWARFDie &CUDie, const DWARFLinkerBase::ObjectPrefixMapTy *ObjectPrefixMap, const DWARFFile &File)
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.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
void sort(IteratorTy Start, IteratorTy End)
static uint64_t getDwoId(const DWARFDie &CUDie)
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
@ Mod
The access may modify the value stored in memory.
void call_once(once_flag &flag, Function &&F, Args &&... ArgList)
Execute the function specified as a parameter once.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
static void resolveRelativeObjectPath(SmallVectorImpl< char > &Buf, DWARFDie CU, const DWARFFile &File)
Resolve the relative path to a build artifact referenced by DWARF of File by applying DW_AT_comp_dir.
void parallelForEach(IterTy Begin, IterTy End, FuncTy Fn)
void consumeError(Error Err)
Consume a Error without doing anything.
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.
Section + local offset of a .debug_frame CIE that has been (or will be) emitted by some LinkContext.
FDEs retained for emission.
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 ...
LinkContext(LinkingGlobalData &GlobalData, DWARFFile &File, uint64_t ObjFileIdx, StringMap< uint64_t > &ClangModules, uint64_t &ModuleUnitIdx, std::atomic< size_t > &UniqueUnitID)
DWARFFile & InputDWARFFile
Object file descriptor.
std::unique_ptr< FrameScanResult > FrameScan
Error scanFrameData()
Parse this context's input .debug_frame into FrameScan.
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 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.
UnitListTy ModulesCompileUnits
Set of Compile Units for modules.
void registerCIEs(CIERegistry &CIEs)
Register this context's CIEs with the linker-wide registry.
std::atomic< bool > HasNewInterconnectedCUs
Flag indicating that new inter-connected compilation units were discovered.
Error emitDebugFrame(const CIERegistry &CIEs)
Emit this context's .debug_frame section.
StringMap< uint64_t > & ClangModules
std::atomic< size_t > & UniqueUnitID
Counter for compile units ID.
Error link(TypeUnit *ArtificialTypeUnit)
Link compile units for this context.
StringMap< CIELocation > CIERegistry
Linker-wide registry for .debug_frame CIEs.
Error unloadInput()
Unload the input DWARFContext after scanning the input .debug_frame into FrameScan.
uint64_t ObjectFileIdx
Index of this object file in the link order (used for deterministic type DIE allocation).
std::atomic< bool > HasNewGlobalDependency
std::function< CompileUnit *(uint64_t)> getUnitForOffset
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.
dwarf::FormParams getFormParams() const
Returns FormParams used by section.
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.
The llvm::once_flag structure.