15using namespace dwarf_linker;
16using namespace dwarf_linker::parallel;
21 :
DwarfUnit(GlobalData,
ID,
""), Language(Language),
22 AcceleratorRecords(&GlobalData.getAllocator()) {
43 prepareDataForTreeCreation();
58 DIE *UnitDIE = DIETreeGenerator.
createDIE(dwarf::DW_TAG_compile_unit, 0);
63 ProducerString +=
"llvm DWARFLinkerParallel library version ";
69 OutOffset += DIETreeGenerator
75 OutOffset += DIETreeGenerator
77 dwarf::DW_FORM_data2, *Language)
85 OutOffset += DIETreeGenerator
94 OutOffset += DIETreeGenerator
96 dwarf::DW_FORM_sec_offset, 0xbaddef)
103 OutOffset += DIETreeGenerator
112 OutOffset += DIETreeGenerator
114 dwarf::DW_FORM_sec_offset,
124 for (
uint64_t *OffsetPtr : PatchesOffsets)
131void TypeUnit::prepareDataForTreeCreation() {
150 std::function<bool(const DebugTypeDeclFilePatch &LHS,
151 const DebugTypeDeclFilePatch &RHS)>
152 PatchesComparator = [&](const DebugTypeDeclFilePatch &LHS,
153 const DebugTypeDeclFilePatch &RHS) {
154 return LHS.Directory->first() < RHS.Directory->first() ||
155 (!(RHS.Directory->first() < LHS.Directory->first()) &&
156 LHS.FilePath->first() < RHS.FilePath->first());
159 DebugInfoSection.ListDebugTypeDeclFilePatch.sort(PatchesComparator);
164 getScalarFormForValue(
165 DebugInfoSection.ListDebugTypeDeclFilePatch.size())
168 DebugInfoSection.ListDebugTypeDeclFilePatch.forEach(
186 .addScalarAttribute(dwarf::DW_AT_decl_file,
187 DeclFileForm, FileIdx)
193 if (!GlobalData.getOptions().AllowNonDeterministicOutput) {
198 StrPatchesComparator =
200 return LHS.String->getKey() <
RHS.String->getKey();
202 OutSection.ListDebugStrPatch.sort(StrPatchesComparator);
208 return LHS.String->getKey() <
RHS.String->getKey();
210 OutSection.ListDebugTypeStrPatch.sort(TypeStrPatchesComparator);
215 if (!GlobalData.getOptions().AllowNonDeterministicOutput) {
223 return LHS.String->getKey() <
RHS.String->getKey();
225 OutSection.ListDebugLineStrPatch.sort(LineStrPatchesComparator);
229 TypeLineStrPatchesComparator =
232 return LHS.String->getKey() <
RHS.String->getKey();
234 OutSection.ListDebugTypeLineStrPatch.sort(TypeLineStrPatchesComparator);
242 bool HasChildren = !
Entry->getValue().load()->Children.empty();
244 OutOffset += DIEGen.finalizeAbbreviations(HasChildren,
nullptr);
245 OutOffset += OutDIE->
getSize() - 1;
248 Entry->getValue().load()->Children.forEach([&](
TypeEntry *ChildEntry) {
250 DIEGen.addChild(ChildDIE);
254 OutOffset = finalizeTypeEntryRec(OutOffset, ChildDIE, ChildEntry);
258 OutOffset +=
sizeof(int8_t);
269 if (Dir->
first() ==
"") {
272 DirectoriesMapTy::iterator DirEntry = DirectoriesMap.find(Dir);
273 if (DirEntry == DirectoriesMap.end()) {
277 DirectoriesMap.insert({Dir, DirIdx});
282 DirIdx = DirEntry->second;
289 auto [FileEntry,
Inserted] = FileNamesMap.try_emplace(
296 dwarf::DW_FORM_string, FileName->
getKeyData());
300 uint32_t FileIdx = FileEntry->second;
301 return getVersion() < 5 ? FileIdx + 1 : FileIdx;
304std::pair<dwarf::Form, uint8_t>
306 if (
Value > 0xFFFFFFFF)
307 return std::make_pair(dwarf::DW_FORM_data8, 8);
310 return std::make_pair(dwarf::DW_FORM_data4, 4);
313 return std::make_pair(dwarf::DW_FORM_data2, 2);
315 return std::make_pair(dwarf::DW_FORM_data1, 1);
319 if (Form == dwarf::DW_FORM_data1)
322 if (Form == dwarf::DW_FORM_data2)
325 if (Form == dwarf::DW_FORM_data4)
328 if (Form == dwarf::DW_FORM_data8)
331 if (Form == dwarf::DW_FORM_data16)
370 Tasks.push_back([&]() ->
Error {
383 Tasks, [&](std::function<
Error(
void)>
F) {
return F(); }))
AMDGPU Mark last scratch load
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Allocate memory in an ever growing pool, as if by bump-pointer.
A structured debug information entry.
unsigned getAbbrevNumber() const
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
void setOffset(unsigned O)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef str() const
Explicit conversion to StringRef.
const ValueTy & getValue() const
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
const char * getKeyData() const
getKeyData - Return the start of the string data that is the key for this value.
Triple - Helper class for working with autoconf configuration names.
LLVM Value Representation.
@ Pub
.debug_pubnames, .debug_pubtypes
This class is a helper to create output DIE tree.
std::pair< DIEValue &, size_t > addStringPlaceholderAttribute(dwarf::Attribute Attr, dwarf::Form AttrForm)
Adds string attribute with dummy offset to the current DIE.
DIE * createDIE(dwarf::Tag DieTag, uint32_t OutOffset)
Creates a DIE of specified tag DieTag and OutOffset.
std::pair< DIEValue &, size_t > addScalarAttribute(dwarf::Attribute Attr, dwarf::Form AttrForm, uint64_t Value)
Adds specified scalar attribute to the current DIE.
Base class for all Dwarf units(Compile unit/Type table unit).
std::string UnitName
The name of this unit.
IndexedValuesMap< const StringEntry * > DebugStringIndexMap
Maps a string into the index inside .debug_str_offsets section.
StringRef getUnitName() const
Returns this unit name.
void setOutUnitDIE(DIE *UnitDie)
Set output unit DIE.
DIE * getOutUnitDIE()
Returns output unit DIE.
This class keeps data and services common for the whole linking process.
const DWARFLinkerOptions & getOptions() const
Returns linking options.
StringPool & getStringPool()
Returns global string pool.
uint16_t getDebugStrOffsetsHeaderSize() const
Return size of header of debug_str_offsets table.
LinkingGlobalData & GlobalData
dwarf::FormParams Format
Format for sections.
const dwarf::FormParams & getFormParams() const
Return size of address.
void setOutputFormat(dwarf::FormParams Format, llvm::endianness Endianness)
Sets output format for all keeping sections.
uint16_t getVersion() const
Return DWARF version.
uint16_t getDebugInfoHeaderSize() const
Return size of header of debug_info table.
SectionDescriptor & getOrCreateSectionDescriptor(DebugSectionKind SectionKind)
Returns descriptor for the specified section of SectionKind.
Keeps cloned data for the type DIE.
BumpPtrAllocator & getThreadLocalAllocator()
Return thread local allocator used by pool.
TypeEntry * getRoot() const
Return root for all type entries.
void sortTypes()
Sort children for each kept type entry.
Error finishCloningAndEmit(const Triple &TargetTriple)
Emits resulting dwarf based on information from DIE tree.
void createDIETree(BumpPtrAllocator &Allocator)
Generates DIE tree based on information from TypesMap.
TypeUnit(LinkingGlobalData &GlobalData, unsigned ID, std::optional< uint16_t > Language, dwarf::FormParams Format, llvm::endianness Endianess)
void spawn(std::function< void()> f)
Error emitDebugInfo(const Triple &TargetTriple)
Emit .debug_info section for unit DIEs.
Error emitDebugStringOffsetSection()
Emit the .debug_str_offsets section for current unit.
void emitPubAccelerators()
Emit .debug_pubnames and .debug_pubtypes for Unit.
Error emitAbbreviations()
Error emitDebugLine(const Triple &TargetTriple, const DWARFDebugLine::LineTable &OutLineTable)
Emit .debug_line section.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Error parallelForEachError(RangeTy &&R, FuncTy Fn)
uint8_t MaxOpsPerInst
The maximum number of individual operations that may be encoded in an instruction.
uint8_t MinInstLength
The size in bytes of the smallest target machine instruction.
int8_t LineBase
This parameter affects the meaning of the special opcodes. See below.
uint8_t LineRange
This parameter affects the meaning of the special opcodes. See below.
std::vector< DWARFFormValue > IncludeDirectories
uint8_t OpcodeBase
The number assigned to the first special opcode.
std::vector< uint8_t > StandardOpcodeLengths
uint8_t DefaultIsStmt
The initial value of theis_stmtregister.
dwarf::FormParams FormParams
Version, address size (starting in v5), and DWARF32/64 format; these parameters affect interpretation...
std::vector< FileNameEntry > FileNames
SmallVector< DWARFLinkerBase::AccelTableKind, 1 > AccelTables
The accelerator table kinds.
bool AllowNonDeterministicOutput
Allow to generate valid, but non deterministic output.
This structure is used to update strings offsets into .debug_line_str.
This structure is used to update strings offsets into .debug_str.
This structure is used to keep data of the concrete section.
void notePatchWithOffsetUpdate(const T &Patch, OffsetsPtrVector &PatchesOffsetsList)
While creating patches, offsets to attributes may be partially unknown(because size of abbreviation n...