[PATCH] D102634: Calculate indexes of last child of each DWARF entry once during tryExtractDIEsIfNeeded.

Greg Clayton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 17 19:44:29 PDT 2021


clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

You should probably get Phabricator working: https://llvm.org/docs/Phabricator.html

This will ensure your patches have context. If you submitting patches manually, you need to specify more context lines:

git diff -U999999

The DWARFDebugInfoEntry in LLDB contains more data. See inlined comment on improving performance for the LLVM DWARF reader. But if we are going to fix perf issues with DWARFDie navigation, we should improve the DWARFDebugInfoEntry class to contain the information needed to navigate better. FYI: be very careful when trying to port any code from the LLDB DWARF parser as it actually removes the NULL terminator DIEs from its DWARFUnit vector of DWARFDebugInfoEntry objects as this saves a ton of memory and they aren't needed if you create your DWARFDebugInfoEntry with enough info.



================
Comment at: llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp:833-842
+  // We do not want access out of bounds when parsing corrupted debug data.
+  size_t I = getDIEIndex(Die);
+  if (I >= LastChildren.size())
+    return DWARFDie();
+  size_t LastChild = LastChildren[I];
+  if (!LastChild) {
+    // TODO Shouldn't Die->hasChildren() be false in that case?
----------------
This is a side affect of how the DWARFDebugInfoEntry class is created. LLDB has a more efficient way of doing things as each DWARFDebugInfoEntry knows its sibling index. Since all of the DIEs are contained in an std::vector inside of the DWARFUnit, we can just store the parent index, the sibling index. See the file lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h.


```
  uint32_t m_parent_idx; // How many to subtract from "this" to get the parent.
  uint32_t m_sibling_idx; // How many to add to "this" to get the sibling.
```

The current DWARFDebugInfoEntry just contains a offset and a depth and an abbrev pointer. This info doesn't make it easy to navigate the DWARFDie objects sibling, and parent. If the LLVM DWARF parser adopts this parent index and sibling index, then navigation can happen much quicker and this function can simply get the sibling index and subtract 1 as that will always the the NULL tag that terminates the previous DIE child chain.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102634/new/

https://reviews.llvm.org/D102634



More information about the llvm-commits mailing list