[Lldb-commits] [PATCH] D87441: Speedup collecting DWARF attribute values

Dmitry Antipov via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 10 01:51:13 PDT 2020


dmantipov created this revision.
dmantipov added reviewers: labath, jankratochvil.
dmantipov added a project: LLDB.
Herald added subscribers: lldb-commits, JDevlieghere, aprantl.
dmantipov requested review of this revision.

Try to speedup collecting DWARF attribute values by using emplace_back() to avoid extra calls to copy and/or move constructors.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87441

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
@@ -53,7 +53,9 @@
   ~DWARFAttributes();
 
   void Append(const DWARFUnit *cu, dw_offset_t attr_die_offset,
-              dw_attr_t attr, dw_form_t form);
+              dw_attr_t attr, dw_form_t form) {
+    m_infos.emplace_back(cu, attr_die_offset, attr, form);
+  }
   const DWARFUnit *CompileUnitAtIndex(uint32_t i) const {
     return m_infos[i].cu;
   }
@@ -77,6 +79,12 @@
                                 // case we have DW_FORM_ref_addr values
     dw_offset_t die_offset;
     DWARFAttribute attr;
+
+    AttributeValue(const DWARFUnit *_cu, dw_offset_t _die_offset,
+                   dw_attr_t _attr, dw_form_t _form)
+      : cu(_cu), die_offset(_die_offset),
+        attr(_attr, _form, DWARFFormValue::ValueType()) {
+    }
   };
   typedef llvm::SmallVector<AttributeValue, 8> collection;
   collection m_infos;
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
@@ -25,13 +25,6 @@
   return UINT32_MAX;
 }
 
-void DWARFAttributes::Append(const DWARFUnit *cu, dw_offset_t attr_die_offset,
-                             dw_attr_t attr, dw_form_t form) {
-  AttributeValue attr_value = {
-      cu, attr_die_offset, {attr, form, DWARFFormValue::ValueType()}};
-  m_infos.push_back(attr_value);
-}
-
 bool DWARFAttributes::ExtractFormValueAtIndex(
     uint32_t i, DWARFFormValue &form_value) const {
   const DWARFUnit *cu = CompileUnitAtIndex(i);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87441.290906.patch
Type: text/x-patch
Size: 1808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200910/39a297be/attachment.bin>


More information about the lldb-commits mailing list