@@ -234,8 +234,7 @@ DWARF5AcceleratorTable::addAccelTableEntry(
234
234
addUnit (Unit, DWOID);
235
235
}
236
236
237
- auto addEntry =
238
- [&](DIEValue ValName) -> std::optional<BOLTDWARF5AccelTableData *> {
237
+ auto getName = [&](DIEValue ValName) -> std::optional<std::string> {
239
238
if ((!ValName || ValName.getForm () == dwarf::DW_FORM_string) &&
240
239
NameToUse.empty ())
241
240
return std::nullopt;
@@ -268,7 +267,16 @@ DWARF5AcceleratorTable::addAccelTableEntry(
268
267
// This the same hash function used in DWARF5AccelTableData.
269
268
It.HashValue = caseFoldingDjbHash (Name);
270
269
}
270
+ return Name;
271
+ };
272
+
273
+ auto addEntry =
274
+ [&](DIEValue ValName) -> std::optional<BOLTDWARF5AccelTableData *> {
275
+ std::optional<std::string> Name = getName (ValName);
276
+ if (!Name)
277
+ return std::nullopt;
271
278
279
+ auto &It = Entries[*Name];
272
280
bool IsTU = false ;
273
281
uint32_t DieTag = 0 ;
274
282
uint32_t UnitID = getUnitID (Unit, IsTU, DieTag);
@@ -278,7 +286,7 @@ DWARF5AcceleratorTable::addAccelTableEntry(
278
286
if (Iter == CUOffsetsToPatch.end ())
279
287
BC.errs () << " BOLT-WARNING: [internal-dwarf-warning]: Could not find "
280
288
" DWO ID in CU offsets for second Unit Index "
281
- << Name << " . For DIE at offset: "
289
+ << * Name << " . For DIE at offset: "
282
290
<< Twine::utohexstr (CurrentUnitOffset + Die.getOffset ())
283
291
<< " .\n " ;
284
292
SecondIndex = Iter->second ;
@@ -295,11 +303,33 @@ DWARF5AcceleratorTable::addAccelTableEntry(
295
303
return It.Values .back ();
296
304
};
297
305
298
- std::optional<BOLTDWARF5AccelTableData *> NameEntry =
299
- addEntry (Die.findAttribute (dwarf::Attribute::DW_AT_name));
300
- std::optional<BOLTDWARF5AccelTableData *> LinkageNameEntry =
301
- addEntry (Die.findAttribute (dwarf::Attribute::DW_AT_linkage_name));
302
- return NameEntry ? NameEntry : LinkageNameEntry;
306
+ // Minor optimization not to add entry twice for DW_TAG_namespace if it has no
307
+ // DW_AT_name.
308
+ if (!(Die.getTag () == dwarf::DW_TAG_namespace &&
309
+ !Die.findAttribute (dwarf::Attribute::DW_AT_name)))
310
+ addEntry (Die.findAttribute (dwarf::Attribute::DW_AT_linkage_name));
311
+ // For the purposes of determining whether a debugging information entry has a
312
+ // particular attribute (such as DW_AT_name), if debugging information entry A
313
+ // has a DW_AT_specification or DW_AT_abstract_origin attribute pointing to
314
+ // another debugging information entry B, any attributes of B are considered
315
+ // to be part of A.
316
+ if (DIEValue AbstrOrigin =
317
+ Die.findAttribute (dwarf::Attribute::DW_AT_abstract_origin)) {
318
+ const DIEEntry &DIEENtry = AbstrOrigin.getDIEEntry ();
319
+ DIE &EntryDie = DIEENtry.getEntry ();
320
+ addEntry (EntryDie.findAttribute (dwarf::Attribute::DW_AT_linkage_name));
321
+ return addEntry (EntryDie.findAttribute (dwarf::Attribute::DW_AT_name));
322
+ }
323
+ if (DIEValue AbstrOrigin =
324
+ Die.findAttribute (dwarf::Attribute::DW_AT_specification)) {
325
+ const DIEEntry &DIEENtry = AbstrOrigin.getDIEEntry ();
326
+ DIE &EntryDie = DIEENtry.getEntry ();
327
+ addEntry (EntryDie.findAttribute (dwarf::Attribute::DW_AT_linkage_name));
328
+ return addEntry (EntryDie.findAttribute (dwarf::Attribute::DW_AT_name));
329
+ }
330
+
331
+ return addEntry (Die.findAttribute (dwarf::Attribute::DW_AT_name));
332
+ ;
303
333
}
304
334
305
335
// / Algorithm from llvm implementation.
0 commit comments