LLVM: lib/DWARFLinker/Parallel/AcceleratorRecordsSaver.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

13

14using namespace llvm;

17

19 int ChildRecurseDepth = 0) {

20 const char *Name = nullptr;

22 std::optional RefVal;

23

26 Name = CurrentName;

27

28 if (!(RefVal = InputDIE.find(dwarf::DW_AT_specification)) &&

29 !(RefVal = InputDIE.find(dwarf::DW_AT_abstract_origin)))

30 return false;

31

33 return false;

34

35 std::optional RefDie = CU->resolveDIEReference(

36 *RefVal, ResolveInterCUReferencesMode::Resolve);

37 if (!RefDie)

38 return false;

39

40 if (!RefDie->DieEntry)

41 return false;

42

43 CU = RefDie->CU;

44 InputDIE = RefDie->CU->getDIE(RefDie->DieEntry);

45 return true;

46 })) {

48 }

49

50 if (!Name && InputDIE.getTag() == dwarf::DW_TAG_namespace)

51 Name = "(anonymous namespace)";

52

54 if (!ParentDie.isValid() || ParentDie.getTag() == dwarf::DW_TAG_compile_unit)

55 return djbHash(Name ? Name : "", djbHash(ChildRecurseDepth ? "" : "::"));

56

58 (Name ? Name : ""),

59 djbHash((Name ? "::" : ""),

61}

62

66 if (GlobalData.getOptions().AccelTables.empty())

67 return;

68

70

71

72 if (AttrInfo.Name == nullptr)

75

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: {

107

110 .value_or(0);

111

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))

117 .value_or(0);

118

120 ObjCClassIsImplementation, TypeEntry);

121 }

122 } break;

123 case dwarf::DW_TAG_namespace: {

124 if (AttrInfo.Name == nullptr)

125 AttrInfo.Name =

126 GlobalData.getStringPool().insert("(anonymous namespace)").first;

127

130 } break;

131 case dwarf::DW_TAG_imported_declaration: {

132 if (AttrInfo.Name != nullptr)

135 } break;

136 case dwarf::DW_TAG_compile_unit:

137 case dwarf::DW_TAG_lexical_block: {

138

139 } break;

140 default:

142

143 return;

144

146 if (AttrInfo.Name)

148 InputDieEntry->getTag() ==

149 dwarf::DW_TAG_inlined_subroutine);

150

151

156

159 InputDieEntry->getTag() ==

160 dwarf::DW_TAG_inlined_subroutine);

161

162

164 (InputDieEntry->getTag() != dwarf::DW_TAG_inlined_subroutine)) {

165 if (std::optional Name =

168 GlobalData.getStringPool().insert(*Name).first;

169

171 InputDieEntry->getTag(), true);

172 }

173 }

174

175 if (AttrInfo.Name)

176 saveObjC(InputDieEntry, OutDIE, AttrInfo);

177 }

178 break;

179 }

180}

181

184 std::optional Names =

186 if (!Names)

187 return;

188

190 GlobalData.getStringPool().insert(Names->Selector).first;

193 GlobalData.getStringPool().insert(Names->ClassName).first;

195 if (Names->ClassNameNoCategory) {

197 GlobalData.getStringPool().insert(*Names->ClassNameNoCategory).first;

199 }

200 if (Names->MethodNameNoCategory) {

202 GlobalData.getStringPool().insert(*Names->MethodNameNoCategory).first;

204 }

205}

206

209 bool AvoidForPubSections) {

211

213 Info.String = Name;

214 Info.OutOffset = OutDIE->getOffset();

215 Info.Tag = Tag;

216 Info.AvoidForPubSections = AvoidForPubSections;

217

218 OutUnit.getAsCompileUnit()->saveAcceleratorInfo(Info);

219}

223 if (OutUnit.isCompileUnit()) {

226

228 Info.String = Name;

229 Info.OutOffset = OutDIE->getOffset();

230 Info.Tag = Tag;

231

232 OutUnit.getAsCompileUnit()->saveAcceleratorInfo(Info);

233 return;

234 }

235

239 Info.String = Name;

240 Info.OutOffset = 0xbaddef;

241 Info.Tag = Tag;

242 Info.OutDIE = OutDIE;

243 Info.TypeEntryBodyPtr = TypeEntry->getValue().load();

244

245 OutUnit.getAsTypeUnit()->saveAcceleratorInfo(Info);

246}

247

251

253 Info.String = Name;

254 Info.OutOffset = OutDIE->getOffset();

255 Info.Tag = Tag;

256 Info.AvoidForPubSections = true;

257

258 OutUnit.getAsCompileUnit()->saveAcceleratorInfo(Info);

259}

260

264 bool ObjcClassImplementation,

266 if (OutUnit.isCompileUnit()) {

269

271 Info.String = Name;

272 Info.OutOffset = OutDIE->getOffset();

273 Info.Tag = Tag;

274 Info.QualifiedNameHash = QualifiedNameHash;

275 Info.ObjcClassImplementation = ObjcClassImplementation;

276

277 OutUnit.getAsCompileUnit()->saveAcceleratorInfo(Info);

278 return;

279 }

280

283

285 Info.String = Name;

286 Info.OutOffset = 0xbaddef;

287 Info.Tag = Tag;

288 Info.QualifiedNameHash = QualifiedNameHash;

289 Info.ObjcClassImplementation = ObjcClassImplementation;

290 Info.OutDIE = OutDIE;

291 Info.TypeEntryBodyPtr = TypeEntry->getValue().load();

292 OutUnit.getAsTypeUnit()->saveAcceleratorInfo(Info);

293}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static uint32_t hashFullyQualifiedName(CompileUnit &InputCU, DWARFDie &InputDIE, int ChildRecurseDepth=0)

Definition AcceleratorRecordsSaver.cpp:18

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.

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

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)

Definition AcceleratorRecordsSaver.cpp:261

void saveObjC(const DWARFDebugInfoEntry *InputDieEntry, DIE *OutDIE, AttributesInfo &AttrInfo)

Definition AcceleratorRecordsSaver.cpp:182

void saveNamespaceRecord(StringEntry *Name, DIE *OutDIE, dwarf::Tag Tag, TypeEntry *TypeEntry)

Definition AcceleratorRecordsSaver.cpp:220

void saveObjCNameRecord(StringEntry *Name, DIE *OutDIE, dwarf::Tag Tag)

Definition AcceleratorRecordsSaver.cpp:248

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.

Definition AcceleratorRecordsSaver.cpp:63

void saveNameRecord(StringEntry *Name, DIE *OutDIE, dwarf::Tag Tag, bool AvoidForPubSections)

Definition AcceleratorRecordsSaver.cpp:207

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 fileds.