[llvm] [BOLT][DWARF] Add support to debug_names for DW_AT_abstract_origin/DW_AT_specification (PR #85485)

Alexander Yermolovich via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 18 15:05:57 PDT 2024


================
@@ -295,11 +303,37 @@ DWARF5AcceleratorTable::addAccelTableEntry(
     return It.Values.back();
   };
 
-  std::optional<BOLTDWARF5AccelTableData *> NameEntry =
-      addEntry(Die.findAttribute(dwarf::Attribute::DW_AT_name));
-  std::optional<BOLTDWARF5AccelTableData *> LinkageNameEntry =
-      addEntry(Die.findAttribute(dwarf::Attribute::DW_AT_linkage_name));
-  return NameEntry ? NameEntry : LinkageNameEntry;
+  // Minor optimization not to add entry twice for DW_TAG_namespace if it has no
+  // DW_AT_name.
+  if (!(Die.getTag() == dwarf::DW_TAG_namespace &&
+        !Die.findAttribute(dwarf::Attribute::DW_AT_name)))
+    addEntry(Die.findAttribute(dwarf::Attribute::DW_AT_linkage_name));
+  // For the purposes of determining whether a debugging information entry has a
+  // particular attribute (such as DW_AT_name), if debugging information entry A
+  // has a DW_AT_specification or DW_AT_abstract_origin attribute pointing to
+  // another debugging information entry B, any attributes of B are considered
+  // to be part of A.
+  auto processReferencedDie = [&](const dwarf::Attribute &Attr)
+      -> std::optional<BOLTDWARF5AccelTableData *> {
+    const DIEValue Value = Die.findAttribute(Attr);
+    if (!Value)
+      return std::nullopt;
+    ;
----------------
ayermolo wrote:

Why?
Not every DIE will have DW_AT_abstract_origin or DW_AT_specification.
If they don't this will return std::nullopt and rest of the DIE will be processed for DW_AT_name.

https://github.com/llvm/llvm-project/pull/85485


More information about the llvm-commits mailing list