15using namespace dwarf_linker;
16using namespace dwarf_linker::parallel;
19 int ChildRecurseDepth = 0) {
20 const char *
Name =
nullptr;
22 std::optional<DWARFFormValue> RefVal;
25 if (
const char *CurrentName = InputDIE.
getName(DINameKind::ShortName))
28 if (!(RefVal = InputDIE.
find(dwarf::DW_AT_specification)) &&
29 !(RefVal = InputDIE.
find(dwarf::DW_AT_abstract_origin)))
35 std::optional<UnitEntryPairTy> RefDie =
CU->resolveDIEReference(
36 *RefVal, ResolveInterCUReferencesMode::Resolve);
40 if (!RefDie->DieEntry)
44 InputDIE = RefDie->CU->getDIE(RefDie->DieEntry);
50 if (!
Name && InputDIE.
getTag() == dwarf::DW_TAG_namespace)
51 Name =
"(anonymous namespace)";
54 if (!ParentDie.
isValid() || ParentDie.
getTag() == dwarf::DW_TAG_compile_unit)
72 if (AttrInfo.
Name ==
nullptr)
76 switch (InputDieEntry->
getTag()) {
77 case dwarf::DW_TAG_array_type:
78 case dwarf::DW_TAG_class_type:
79 case dwarf::DW_TAG_enumeration_type:
80 case dwarf::DW_TAG_pointer_type:
81 case dwarf::DW_TAG_reference_type:
82 case dwarf::DW_TAG_string_type:
83 case dwarf::DW_TAG_structure_type:
84 case dwarf::DW_TAG_subroutine_type:
85 case dwarf::DW_TAG_typedef:
86 case dwarf::DW_TAG_union_type:
87 case dwarf::DW_TAG_ptr_to_member_type:
88 case dwarf::DW_TAG_set_type:
89 case dwarf::DW_TAG_subrange_type:
90 case dwarf::DW_TAG_base_type:
91 case dwarf::DW_TAG_const_type:
92 case dwarf::DW_TAG_constant:
93 case dwarf::DW_TAG_file_type:
94 case dwarf::DW_TAG_namelist:
95 case dwarf::DW_TAG_packed_type:
96 case dwarf::DW_TAG_volatile_type:
97 case dwarf::DW_TAG_restrict_type:
98 case dwarf::DW_TAG_atomic_type:
99 case dwarf::DW_TAG_interface_type:
100 case dwarf::DW_TAG_unspecified_type:
101 case dwarf::DW_TAG_shared_type:
102 case dwarf::DW_TAG_immutable_type:
103 case dwarf::DW_TAG_rvalue_reference_type: {
112 bool ObjCClassIsImplementation =
113 (RuntimeLang == dwarf::DW_LANG_ObjC ||
114 RuntimeLang == dwarf::DW_LANG_ObjC_plus_plus) &&
116 InputDIE.
find(dwarf::DW_AT_APPLE_objc_complete_type))
123 case dwarf::DW_TAG_namespace: {
124 if (AttrInfo.
Name ==
nullptr)
131 case dwarf::DW_TAG_imported_declaration: {
132 if (AttrInfo.
Name !=
nullptr)
136 case dwarf::DW_TAG_compile_unit:
137 case dwarf::DW_TAG_lexical_block: {
148 InputDieEntry->
getTag() ==
149 dwarf::DW_TAG_inlined_subroutine);
159 InputDieEntry->
getTag() ==
160 dwarf::DW_TAG_inlined_subroutine);
164 (InputDieEntry->
getTag() != dwarf::DW_TAG_inlined_subroutine)) {
165 if (std::optional<StringRef>
Name =
171 InputDieEntry->
getTag(),
true);
176 saveObjC(InputDieEntry, OutDIE, AttrInfo);
184 std::optional<ObjCSelectorNames> Names =
195 if (Names->ClassNameNoCategory) {
200 if (Names->MethodNameNoCategory) {
209 bool AvoidForPubSections) {
216 Info.AvoidForPubSections = AvoidForPubSections;
240 Info.OutOffset = 0xbaddef;
242 Info.OutDIE = OutDIE;
256 Info.AvoidForPubSections =
true;
264 bool ObjcClassImplementation,
274 Info.QualifiedNameHash = QualifiedNameHash;
275 Info.ObjcClassImplementation = ObjcClassImplementation;
286 Info.OutOffset = 0xbaddef;
288 Info.QualifiedNameHash = QualifiedNameHash;
289 Info.ObjcClassImplementation = ObjcClassImplementation;
290 Info.OutDIE = OutDIE;
static uint32_t hashFullyQualifiedName(CompileUnit &InputCU, DWARFDie &InputDIE, int ChildRecurseDepth=0)
Analysis containing CSE Info
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::pair< KeyDataTy *, bool > insert(const KeyTy &NewValue)
Insert new value NewValue or return already existing entry.
A structured debug information entry.
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
DWARFDebugInfoEntry - A DIE with only the minimum required data.
dwarf::Tag getTag() const
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
const char * getShortName() const
Return the DIE short name resolving DW_AT_specification or DW_AT_abstract_origin references if necess...
DWARFDie getParent() const
Get the parent of this DIE object.
std::optional< DWARFFormValue > find(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE.
const char * getName(DINameKind Kind) const
Return the DIE name resolving DW_AT_specification or DW_AT_abstract_origin references if necessary.
dwarf::Tag getTag() const
const char * getLinkageName() const
Return the DIE linkage name resolving DW_AT_specification or DW_AT_abstract_origin references if nece...
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
const ValueTy & getValue() const
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
constexpr bool empty() const
empty - Check if the string is empty.
Stores all information relating to a compile unit, be it in its original instance in the object file ...
CompileUnit & InUnit
Comiple unit corresponding to input DWARF.
void saveTypeRecord(StringEntry *Name, DIE *OutDIE, dwarf::Tag Tag, uint32_t QualifiedNameHash, bool ObjcClassImplementation, TypeEntry *TypeEntry)
void saveObjC(const DWARFDebugInfoEntry *InputDieEntry, DIE *OutDIE, AttributesInfo &AttrInfo)
void saveNamespaceRecord(StringEntry *Name, DIE *OutDIE, dwarf::Tag Tag, TypeEntry *TypeEntry)
void saveObjCNameRecord(StringEntry *Name, DIE *OutDIE, dwarf::Tag Tag)
CompileUnit::OutputUnitVariantPtr OutUnit
Compile unit or Artificial type unit corresponding to the output DWARF.
LinkingGlobalData & GlobalData
Global linking data.
void save(const DWARFDebugInfoEntry *InputDieEntry, DIE *OutDIE, AttributesInfo &AttrInfo, TypeEntry *TypeEntry)
Save accelerator info for the specified OutDIE inside OutUnit.
void saveNameRecord(StringEntry *Name, DIE *OutDIE, dwarf::Tag Tag, bool AvoidForPubSections)
TypeUnit * getAsTypeUnit()
Returns TypeUnit if applicable.
CompileUnit * getAsCompileUnit()
Returns CompileUnit if applicable.
void saveAcceleratorInfo(const DwarfUnit::AccelInfo &Info)
Save specified accelerator info Info.
const DWARFLinkerOptions & getOptions() const
Returns linking options.
StringPool & getStringPool()
Returns global string pool.
void saveAcceleratorInfo(const TypeUnitAccelInfo &Info)
Adds Info to the unit's accelerator records.
DWARFDie getDIE(const DWARFDebugInfoEntry *Die)
Error finiteLoop(function_ref< Expected< bool >()> Iteration, size_t MaxCounter=100000)
This function calls Iteration() until it returns false.
std::optional< uint64_t > toUnsigned(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract an unsigned constant.
This is an optimization pass for GlobalISel generic memory operations.
std::optional< StringRef > StripTemplateParameters(StringRef Name)
If Name is the name of a templated function that includes template parameters, returns a substring of...
uint32_t djbHash(StringRef Buffer, uint32_t H=5381)
The Bernstein hash function used by the DWARF accelerator tables.
std::optional< ObjCSelectorNames > getObjCNamesIfSelector(StringRef Name)
If Name is the AT_name of a DIE which refers to an Objective-C selector, returns an instance of ObjCS...
void consumeError(Error Err)
Consume a Error without doing anything.
Information gathered and exchanged between the various clone*Attr helpers about the attributes of a p...
bool IsDeclaration
Is this DIE only a declaration?
bool HasRanges
Does the DIE have a ranges attribute?
bool HasLiveAddress
Does the DIE have an address pointing to live code section?
StringEntry * MangledName
Mangled Name.
StringEntry * Name
Short Name.
SmallVector< DWARFLinkerBase::AccelTableKind, 1 > AccelTables
The accelerator table kinds.
This structure keeps fields which would be used for creating accelerator table.
TypeUnitAccelInfo extends AccelInfo structure with type specific fileds.