13namespace dwarflinker_parallel {
36 Data.isLittleEndian());
47 for (
const auto &AttrSpec : Abbrev->attributes()) {
60 switch (AttrSpec.Form) {
61 case dwarf::DW_FORM_strp:
62 case dwarf::DW_FORM_line_strp:
63 case dwarf::DW_FORM_string:
64 case dwarf::DW_FORM_strx:
65 case dwarf::DW_FORM_strx1:
66 case dwarf::DW_FORM_strx2:
67 case dwarf::DW_FORM_strx3:
68 case dwarf::DW_FORM_strx4:
71 case dwarf::DW_FORM_ref_addr:
72 case dwarf::DW_FORM_ref1:
73 case dwarf::DW_FORM_ref2:
74 case dwarf::DW_FORM_ref4:
75 case dwarf::DW_FORM_ref8:
76 case dwarf::DW_FORM_ref_udata:
79 case dwarf::DW_FORM_data1:
80 case dwarf::DW_FORM_data2:
81 case dwarf::DW_FORM_data4:
82 case dwarf::DW_FORM_data8:
83 case dwarf::DW_FORM_udata:
84 case dwarf::DW_FORM_sdata:
85 case dwarf::DW_FORM_sec_offset:
86 case dwarf::DW_FORM_flag:
87 case dwarf::DW_FORM_flag_present:
88 case dwarf::DW_FORM_rnglistx:
89 case dwarf::DW_FORM_loclistx:
90 case dwarf::DW_FORM_implicit_const:
93 case dwarf::DW_FORM_block:
94 case dwarf::DW_FORM_block1:
95 case dwarf::DW_FORM_block2:
96 case dwarf::DW_FORM_block4:
97 case dwarf::DW_FORM_exprloc:
100 case dwarf::DW_FORM_addr:
101 case dwarf::DW_FORM_addrx:
102 case dwarf::DW_FORM_addrx1:
103 case dwarf::DW_FORM_addrx2:
104 case dwarf::DW_FORM_addrx3:
105 case dwarf::DW_FORM_addrx4:
111 " in DieAttributeCloner::clone(). Dropping.",
131 dwarf::DW_FORM_sec_offset,
139 switch (AttrSpec.
Attr) {
142 case dwarf::DW_AT_low_pc:
143 case dwarf::DW_AT_high_pc:
144 case dwarf::DW_AT_ranges:
152 case dwarf::DW_AT_rnglists_base:
158 case dwarf::DW_AT_loclists_base:
164 case dwarf::DW_AT_location:
165 case dwarf::DW_AT_frame_base:
194 if (AttrSpec.
Attr == dwarf::DW_AT_name)
196 else if (AttrSpec.
Attr == dwarf::DW_AT_MIPS_linkage_name ||
197 AttrSpec.
Attr == dwarf::DW_AT_linkage_name)
200 if (AttrSpec.
Form == dwarf::DW_FORM_line_strp) {
238 if (AttrSpec.
Attr == dwarf::DW_AT_sibling)
241 std::optional<UnitEntryPairTy> RefDiePair =
243 if (!RefDiePair || !RefDiePair->DieEntry) {
251 RefDiePair->CU->getDIEInfo(RefDiePair->DieEntry);
253 RefTypeName = RefDiePair->CU->getDieTypeEntry(RefDiePair->DieEntry);
256 assert(RefTypeName &&
"Type name for referenced DIE is not set");
258 "Type name for DIE is not set");
279 uint64_t OutDieOffset = RefDiePair->CU->getDieOutOffset(RefDiePair->DieEntry);
285 dwarf::Form NewForm = IsLocal ? dwarf::DW_FORM_ref4 : dwarf::DW_FORM_ref_addr;
289 if (IsLocal && (OutDieOffset != 0))
298 RefDiePair->CU->
getDIEIndex(RefDiePair->DieEntry)},
310 switch (AttrSpec.
Attr) {
311 case dwarf::DW_AT_macro_info: {
325 case dwarf::DW_AT_macros: {
339 case dwarf::DW_AT_stmt_list: {
345 case dwarf::DW_AT_str_offsets_base: {
361 case dwarf::DW_AT_decl_file: {
368 if (std::optional<std::pair<StringRef, StringRef>> DirAndFilename =
375 .
insert(DirAndFilename->first)
379 .
insert(DirAndFilename->second)
390 if (AttrSpec.
Attr == dwarf::DW_AT_const_value &&
397 Value = *OptionalValue;
399 Value = *OptionalValue;
401 Value = *OptionalValue;
403 InUnit.
warn(
"unsupported scalar attribute form. Dropping attribute.",
408 if (AttrSpec.
Attr == dwarf::DW_AT_declaration &&
Value)
411 if (AttrSpec.
Form == dwarf::DW_FORM_loclistx)
420 if (AttrSpec.
Form == dwarf::DW_FORM_rnglistx) {
429 std::optional<uint64_t>
Offset =
437 ResultingForm = dwarf::DW_FORM_sec_offset;
438 }
else if (AttrSpec.
Form == dwarf::DW_FORM_loclistx) {
447 std::optional<uint64_t>
Offset =
455 ResultingForm = dwarf::DW_FORM_sec_offset;
456 }
else if (AttrSpec.
Attr == dwarf::DW_AT_high_pc &&
466 }
else if (AttrSpec.
Form == dwarf::DW_FORM_sec_offset)
468 else if (AttrSpec.
Form == dwarf::DW_FORM_sdata)
471 Value = *OptionalValue;
473 InUnit.
warn(
"unsupported scalar attribute form. Dropping attribute.",
478 if (AttrSpec.
Attr == dwarf::DW_AT_ranges ||
479 AttrSpec.
Attr == dwarf::DW_AT_start_scope) {
490 int64_t AddrAdjustmentValue = 0;
499 }
else if (AttrSpec.
Attr == dwarf::DW_AT_addr_base) {
513 }
else if (AttrSpec.
Attr == dwarf::DW_AT_declaration &&
Value)
550 if ((ResultForm == dwarf::DW_FORM_block1 && Bytes.
size() > UINT8_MAX) ||
551 (ResultForm == dwarf::DW_FORM_block2 && Bytes.
size() > UINT16_MAX) ||
552 (ResultForm == dwarf::DW_FORM_block4 && Bytes.
size() > UINT32_MAX))
553 ResultForm = dwarf::DW_FORM_block;
555 size_t FinalAttributeSize;
556 if (AttrSpec.
Form == dwarf::DW_FORM_exprloc)
576 return FinalAttributeSize;
582 if (AttrSpec.
Attr == dwarf::DW_AT_low_pc)
605 std::optional<DWARFFormValue> AddrAttribute =
610 std::optional<uint64_t>
Addr = AddrAttribute->getAsAddress();
612 InUnit.
warn(
"cann't read address attribute value.");
617 AttrSpec.
Attr == dwarf::DW_AT_low_pc) {
623 AttrSpec.
Attr == dwarf::DW_AT_high_pc) {
635 if (AttrSpec.
Form == dwarf::DW_FORM_addr) {
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
std::pair< KeyDataTy *, bool > insert(const KeyTy &NewValue)
Insert new value NewValue or return already existing entry.
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
dwarf::Tag getTag() const
uint64_t getOffset() const
const DWARFAbbreviationDeclaration * getAbbreviationDeclarationPtr() const
uint64_t getOffset() const
Get the absolute offset into the debug info or types section.
unsigned getNumDIEs()
Returns the number of DIEs in the unit.
DWARFDataExtractor getDebugInfoExtractor() const
std::optional< uint64_t > getRnglistOffset(uint32_t Index)
Return a rangelist's offset based on an index.
uint8_t getAddressByteSize() const
std::optional< uint64_t > getLoclistOffset(uint32_t Index)
uint16_t getVersion() const
bool isLittleEndian() const
uint64_t getNextUnitOffset() const
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
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.
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
CompileUnit * getAsCompileUnit()
Returns CompileUnit if applicable.
void cloneDieAttrExpression(const DWARFExpression &InputExpression, SmallVectorImpl< uint8_t > &OutputExpression, SectionDescriptor &Section, std::optional< int64_t > VarAddressAdjustment, OffsetsPtrVector &PatchesOffsets)
Clone attribute location axpression.
uint64_t getHighPc() const
Returns value of DW_AT_high_pc attribute.
std::optional< uint64_t > getLowPc() const
Returns value of DW_AT_low_pc attribute.
uint64_t getDebugAddrIndex(uint64_t Addr)
Returns index(inside .debug_addr) of an address.
const DWARFFile & getContaingFile() const
Returns DWARFFile containing this compile unit.
std::optional< std::pair< StringRef, StringRef > > getDirAndFilenameFromLineTable(const DWARFFormValue &FileIdxValue)
Returns directory and file from the line table by index.
std::optional< UnitEntryPairTy > resolveDIEReference(const DWARFFormValue &RefValue, ResolveInterCUReferencesMode CanResolveInterCUReferences)
Resolve the DIE attribute reference that has been extracted in RefValue.
CompileUnit & InUnit
Input compilation unit.
void clone()
Clone attributes of input DIE.
bool shouldSkipAttribute(DWARFAbbreviationDeclaration::AttributeSpec AttrSpec)
Returns true if attribute should be skipped.
bool HasLocationExpressionAddress
Indicates whether InputDieEntry has an location attribute containg address expression.
size_t cloneScalarAttr(const DWARFFormValue &Val, const DWARFAbbreviationDeclaration::AttributeSpec &AttrSpec)
Clone scalar attribute.
size_t cloneStringAttr(const DWARFFormValue &Val, const DWARFAbbreviationDeclaration::AttributeSpec &AttrSpec)
Clone string attribute.
size_t cloneAddressAttr(const DWARFFormValue &Val, const DWARFAbbreviationDeclaration::AttributeSpec &AttrSpec)
Clone address attribute.
unsigned finalizeAbbreviations(bool HasChildrenToClone)
Create abbreviations for the output DIE after all attributes are cloned.
OffsetsPtrVector PatchesOffsets
Patches for the cloned attributes.
uint32_t InputDIEIdx
Input DIE index.
std::optional< int64_t > VarAddressAdjustment
Relocation adjustment for the variable locations.
bool Use_DW_FORM_strp
This flag forces using DW_FORM_strp for string attributes.
size_t cloneBlockAttr(const DWARFFormValue &Val, const DWARFAbbreviationDeclaration::AttributeSpec &AttrSpec)
Clone block or exprloc attribute.
size_t cloneDieRefAttr(const DWARFFormValue &Val, const DWARFAbbreviationDeclaration::AttributeSpec &AttrSpec)
Clone attribute referencing another DIE.
CompileUnit::OutputUnitVariantPtr OutUnit
Output unit(either "plain" compilation unit, either artificial type unit).
AttributesInfo AttrInfo
Cannot be used concurrently.
const DWARFDebugInfoEntry * InputDieEntry
Input DIE entry.
DIEGenerator & Generator
Output DIE generator.
SectionDescriptor & DebugInfoOutputSection
.debug_info section descriptor.
std::optional< int64_t > FuncAddressAdjustment
Relocation adjustment for the function address ranges.
unsigned AttrOutOffset
Output offset after all attributes.
std::pair< DIEValue &, size_t > addBlockAttribute(dwarf::Attribute Attr, dwarf::Form AttrForm, ArrayRef< uint8_t > Bytes)
Adds specified block or exprloc attribute to the current DIE.
std::pair< DIEValue &, size_t > addLocationAttribute(dwarf::Attribute Attr, dwarf::Form AttrForm, ArrayRef< uint8_t > Bytes)
Adds specified location attribute to the current DIE.
size_t finalizeAbbreviations(bool CHILDREN_yes, OffsetsPtrVector *OffsetsList)
Creates appreviations for the current DIE.
std::pair< DIEValue &, size_t > addStringPlaceholderAttribute(dwarf::Attribute Attr, dwarf::Form AttrForm)
Adds string attribute with dummy offset to the current DIE.
std::pair< DIEValue &, size_t > addScalarAttribute(dwarf::Attribute Attr, dwarf::Form AttrForm, uint64_t Value)
Adds specified scalar attribute to the current DIE.
std::pair< DIEValue &, size_t > addIndexedStringAttribute(dwarf::Attribute Attr, dwarf::Form AttrForm, uint64_t Idx)
Adds indexed string attribute.
std::pair< DIEValue &, size_t > addLocListAttribute(dwarf::Attribute Attr, dwarf::Form AttrForm, uint64_t Value)
Adds specified location list attribute to the current DIE.
std::unique_ptr< DWARFContext > Dwarf
Source DWARF information.
std::unique_ptr< AddressesMap > Addresses
Helpful address information(list of valid address ranges, relocations).
unsigned getUniqueID() const
Unique id of the unit.
virtual uint64_t getDebugStrIndex(const StringEntry *String)
Returns index(inside .debug_str_offsets) of specified string.
LinkingGlobalData & getGlobalData()
Return global data.
StringPool & getStringPool()
Returns global string pool.
const DWARFLinkerOptions & getOptions() const
Returns linking options.
uint16_t getVersion() const
Return DWARF version.
uint16_t getDebugStrOffsetsHeaderSize() const
Return size of header of debug_str_offsets table.
uint16_t getDebugAddrHeaderSize() const
Return size of header of debug_ table.
const dwarf::FormParams & getFormParams() const
Return size of address.
SectionDescriptor & getOrCreateSectionDescriptor(DebugSectionKind SectionKind)
Returns descriptor for the specified section of SectionKind.
StringRef FormEncodingString(unsigned Encoding)
DIEInfo & getDIEInfo(unsigned Idx)
Idx index of the DIE.
TypeEntry * getDieTypeEntry(uint32_t Idx)
Idx index of the DIE.
DWARFDie getDIEAtIndex(unsigned Index)
uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) const
std::optional< DWARFFormValue > find(uint32_t DieIdx, ArrayRef< dwarf::Attribute > Attrs) const
DWARFUnit & getOrigUnit() const
Returns paired compile unit from input DWARF.
void warn(const Twine &Warning, const DWARFDie *DIE=nullptr)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
bool doesFormBelongToClass(dwarf::Form Form, DWARFFormValue::FormClass FC, uint16_t DwarfVersion)
Check whether specified Form belongs to the FC class.
This is an optimization pass for GlobalISel generic memory operations.
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
static bool mayHaveLocationList(dwarf::Attribute Attr)
Identify DWARF attributes that may contain a pointer to a location list.
static bool mayHaveLocationExpr(dwarf::Attribute Attr)
Identifies DWARF attributes that may contain a reference to a DWARF expression.
bool HasLiveAddress
Does the DIE have an address pointing to live code section?
bool IsDeclaration
Is this DIE only a declaration?
StringEntry * Name
Short Name.
bool HasStringOffsetBaseAttr
Does the DIE have a string offset attribute?
StringEntry * MangledName
Mangled Name.
bool HasRanges
Does the DIE have a ranges attribute?
Information gathered about source DIEs.
bool needToPlaceInTypeTable() const
bool UpdateIndexTablesOnly
Update index tables.
This structure is used to update reference to the DIE.
This structure is used to update reference to the type DIE.
This structure is used to update strings offsets into .debug_line_str.
This structure is used to update location list offset into .debug_loc/.debug_loclists.
This structure is used to update range list offset into .debug_ranges/.debug_rnglists.
This structure is used to update strings offsets into .debug_str.
This structure is used to update reference to the type DIE.
void notePatchWithOffsetUpdate(const T &Patch, OffsetsPtrVector &PatchesOffsetsList)
While creating patches, offsets to attributes may be partially unknown(because size of abbreviation n...