19 int ChildRecurseDepth = 0) {
20 const char *Name =
nullptr;
22 std::optional<DWARFFormValue> RefVal;
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)
55 return djbHash(Name ? Name :
"",
djbHash(ChildRecurseDepth ?
"" :
"::"));
66 if (
GlobalData.getOptions().AccelTables.empty())
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_template_alias:
86 case dwarf::DW_TAG_typedef:
87 case dwarf::DW_TAG_union_type:
88 case dwarf::DW_TAG_ptr_to_member_type:
89 case dwarf::DW_TAG_set_type:
90 case dwarf::DW_TAG_subrange_type:
91 case dwarf::DW_TAG_base_type:
92 case dwarf::DW_TAG_const_type:
93 case dwarf::DW_TAG_constant:
94 case dwarf::DW_TAG_file_type:
95 case dwarf::DW_TAG_namelist:
96 case dwarf::DW_TAG_packed_type:
97 case dwarf::DW_TAG_volatile_type:
98 case dwarf::DW_TAG_restrict_type:
99 case dwarf::DW_TAG_atomic_type:
100 case dwarf::DW_TAG_interface_type:
101 case dwarf::DW_TAG_unspecified_type:
102 case dwarf::DW_TAG_shared_type:
103 case dwarf::DW_TAG_immutable_type:
104 case dwarf::DW_TAG_rvalue_reference_type: {
113 bool ObjCClassIsImplementation =
114 (RuntimeLang == dwarf::DW_LANG_ObjC ||
115 RuntimeLang == dwarf::DW_LANG_ObjC_plus_plus) &&
117 InputDIE.
find(dwarf::DW_AT_APPLE_objc_complete_type))
121 InputDieEntry->
getTag(), Hash, ObjCClassIsImplementation,
125 case dwarf::DW_TAG_namespace: {
126 if (AttrInfo.
Name ==
nullptr)
128 GlobalData.getStringPool().insert(
"(anonymous namespace)").first;
133 case dwarf::DW_TAG_imported_declaration: {
134 if (AttrInfo.
Name !=
nullptr)
138 case dwarf::DW_TAG_compile_unit:
139 case dwarf::DW_TAG_lexical_block: {
150 InputDieEntry, AttrInfo.
Name, OutDIE, InputDieEntry->
getTag(),
151 InputDieEntry->
getTag() == dwarf::DW_TAG_inlined_subroutine);
162 InputDieEntry->
getTag() ==
163 dwarf::DW_TAG_inlined_subroutine);
167 (InputDieEntry->
getTag() != dwarf::DW_TAG_inlined_subroutine)) {
168 if (std::optional<StringRef> Name =
171 GlobalData.getStringPool().insert(*Name).first;
174 InputDieEntry->
getTag(),
true);
179 saveObjC(InputDieEntry, OutDIE, AttrInfo);
187 std::optional<ObjCSelectorNames> Names =
193 GlobalData.getStringPool().insert(Names->Selector).first;
197 GlobalData.getStringPool().insert(Names->ClassName).first;
199 if (Names->ClassNameNoCategory) {
201 GlobalData.getStringPool().insert(*Names->ClassNameNoCategory).first;
205 if (Names->MethodNameNoCategory) {
207 GlobalData.getStringPool().insert(*Names->MethodNameNoCategory).first;
209 InputDieEntry->
getTag(),
true);
220 constexpr uint64_t NotClonedInPlainDWARF = 0;
222 std::optional<uint32_t> ParentIdx = InputDieEntry->
getParentIdx();
230 if (ParentOutOffset == NotClonedInPlainDWARF)
232 return ParentOutOffset;
245 Info.AvoidForPubSections = AvoidForPubSections;
247 OutUnit.getAsCompileUnit()->saveAcceleratorInfo(Info);
262 OutUnit.getAsCompileUnit()->saveAcceleratorInfo(Info);
274 Info.OutOffset = 0xbaddef;
276 Info.OutDIE = OutDIE;
277 Info.TypeEntryBodyPtr =
TypeEntry->getValue().load();
279 OutUnit.getAsTypeUnit()->saveAcceleratorInfo(Info);
292 Info.AvoidForPubSections =
true;
294 OutUnit.getAsCompileUnit()->saveAcceleratorInfo(Info);
310 Info.QualifiedNameHash = QualifiedNameHash;
311 Info.ObjcClassImplementation = ObjcClassImplementation;
313 OutUnit.getAsCompileUnit()->saveAcceleratorInfo(Info);
325 Info.OutOffset = 0xbaddef;
327 Info.QualifiedNameHash = QualifiedNameHash;
328 Info.ObjcClassImplementation = ObjcClassImplementation;
329 Info.OutDIE = OutDIE;
330 Info.TypeEntryBodyPtr =
TypeEntry->getValue().load();
331 OutUnit.getAsTypeUnit()->saveAcceleratorInfo(Info);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static uint32_t hashFullyQualifiedName(CompileUnit &InputCU, DWARFDie &InputDIE, int ChildRecurseDepth=0)
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
std::optional< uint32_t > getParentIdx() const
Returns index of the parent die.
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
LLVM_ABI const char * getShortName() const
Return the DIE short name resolving DW_AT_specification or DW_AT_abstract_origin references if necess...
LLVM_ABI DWARFDie getParent() const
Get the parent of this DIE object.
LLVM_ABI std::optional< DWARFFormValue > find(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE.
LLVM_ABI 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
LLVM_ABI 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.
constexpr bool empty() const
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 saveNameRecord(const DWARFDebugInfoEntry *InputDieEntry, StringEntry *Name, DIE *OutDIE, dwarf::Tag Tag, bool AvoidForPubSections)
void saveObjC(const DWARFDebugInfoEntry *InputDieEntry, DIE *OutDIE, AttributesInfo &AttrInfo)
void saveObjCNameRecord(const DWARFDebugInfoEntry *InputDieEntry, 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.
std::optional< uint64_t > getDefiningParentOutOffset(const DWARFDebugInfoEntry *InputDieEntry)
Return the output offset of InputDieEntry's immediate non-declaration parent, for use as the DW_IDX_p...
void saveTypeRecord(const DWARFDebugInfoEntry *InputDieEntry, StringEntry *Name, DIE *OutDIE, dwarf::Tag Tag, uint32_t QualifiedNameHash, bool ObjcClassImplementation, TypeEntry *TypeEntry)
void save(const DWARFDebugInfoEntry *InputDieEntry, DIE *OutDIE, AttributesInfo &AttrInfo, TypeEntry *TypeEntry)
Save accelerator info for the specified OutDIE inside OutUnit.
void saveNamespaceRecord(const DWARFDebugInfoEntry *InputDieEntry, StringEntry *Name, DIE *OutDIE, dwarf::Tag Tag, TypeEntry *TypeEntry)
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.
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.
LLVM_ABI 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.
LLVM_ABI 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.
This structure keeps fields which would be used for creating accelerator table.
AccelType Type
Type of this accelerator record.
TypeUnitAccelInfo extends AccelInfo structure with type specific fields.