dmantipov updated this revision to Diff 291894.
dmantipov added a comment.

OK let's reduce it to minimum minimorum.

As for the profiling, l can see possible improvement around 
DWARFAttributes::Append() - inlining even at -O2 and eliminating extra 
constructor call makes

  10.61%  intern-state     liblldb.so.12.0.0git   [.] 
DWARFDebugInfoEntry::GetAttributes
  7.28%  intern-state     liblldb.so.12.0.0git   [.] 
DWARFDebugInfoEntry::Extract
  6.88%  intern-state     liblldb.so.12.0.0git   [.] 
lldb_private::ManualDWARFIndex::IndexUnitImpl
  5.76%  intern-state     libpthread-2.31.so     [.] __pthread_rwlock_rdlock
  5.43%  intern-state     liblldb.so.12.0.0git   [.] 
lldb_private::DataExtractor::GetU32
  4.70%  intern-state     liblldb.so.12.0.0git   [.] DWARFUnit::GetDIE
  4.49%  intern-state     liblldb.so.12.0.0git   [.] 
lldb_private::DWARFContext::LoadOrGetSection
  4.37%  intern-state     libLLVM-12git.so       [.] 
llvm::StringMapImpl::FindKey
  3.50%  intern-state     liblldb.so.12.0.0git   [.] 
DWARFFormValue::GetFixedSize
  2.73%  intern-state     liblldb.so.12.0.0git   [.] 
DWARFUnit::ExtractDIEsRWLocked
  2.61%  intern-state     liblldb.so.12.0.0git   [.] 
Pool::GetConstCStringWithStringRef
  2.08%  intern-state     liblldb.so.12.0.0git   [.] 
lldb_private::DataExtractor::GetULEB128
  1.82%  intern-state     ld-2.31.so             [.] __tls_get_addr
  1.77%  intern-state     liblldb.so.12.0.0git   [.] 
std::__introsort_loop<__gnu_cxx::__normal_iterator<lldb_private::UniqueCStringMap<DIERef>::Entry*,
 std::vector<lldb_private::UniqueCStringMap<DIERef>::Entry, 
std::allocator<lldb_private::UniqueCStringMap<DIERef>::Entry> > >, long, 
__gnu_cxx::__ops::_Iter_comp_iter<lldb_private::Uniqu
  eCStringMap<DIERef>::Compare> >
  1.60%  intern-state     liblldb.so.12.0.0git   [.] 
DWARFFormValue::ExtractValue
  1.55%  intern-state     libpthread-2.31.so     [.] __pthread_rwlock_unlock
  1.23%  intern-state     libc-2.31.so           [.] __strlen_avx2
  1.15%  intern-state     libc-2.31.so           [.] _int_free
  1.15%  intern-state     libc-2.31.so           [.] malloc
  1.14%  intern-state     liblldb.so.12.0.0git   [.] 
DWARFAttributes::ExtractFormValueAtIndex

from:

  7.68%  intern-state     liblldb.so.12.0.0git   [.] DWARFAttributes::Append
  7.25%  intern-state     liblldb.so.12.0.0git   [.] 
DWARFDebugInfoEntry::Extract
  6.34%  intern-state     liblldb.so.12.0.0git   [.] 
lldb_private::ManualDWARFIndex::IndexUnitImpl
  6.30%  intern-state     liblldb.so.12.0.0git   [.] 
DWARFDebugInfoEntry::GetAttributes
  5.55%  intern-state     libpthread-2.31.so     [.] __pthread_rwlock_rdlock
  5.51%  intern-state     liblldb.so.12.0.0git   [.] 
lldb_private::DataExtractor::GetU32
  4.50%  intern-state     liblldb.so.12.0.0git   [.] DWARFUnit::GetDIE
  4.34%  intern-state     liblldb.so.12.0.0git   [.] 
lldb_private::DWARFContext::LoadOrGetSection
  4.27%  intern-state     libLLVM-12git.so       [.] 
llvm::StringMapImpl::FindKey
  2.92%  intern-state     liblldb.so.12.0.0git   [.] 
DWARFFormValue::GetFixedSize
  2.65%  intern-state     liblldb.so.12.0.0git   [.] 
DWARFUnit::ExtractDIEsRWLocked
  2.51%  intern-state     liblldb.so.12.0.0git   [.] 
Pool::GetConstCStringWithStringRef
  1.93%  intern-state     liblldb.so.12.0.0git   [.] 
lldb_private::DataExtractor::GetULEB128
  1.79%  intern-state     liblldb.so.12.0.0git   [.] 
std::__introsort_loop<__gnu_cxx::__normal_iterator<lldb_private::UniqueCStringMap<DIERef>::Entry*,
 std::vector<lldb_private::UniqueCStringMap<DIERef>::Entry, 
std::allocator<lldb_private::UniqueCStringMap<DIERef>::Entry> > >, long, 
__gnu_cxx::__ops::_Iter_comp_iter<lldb_private::UniqueCStringMap<DIERef>::Compare>
 >
  1.78%  intern-state     ld-2.31.so             [.] __tls_get_addr
  1.46%  intern-state     libpthread-2.31.so     [.] __pthread_rwlock_unlock
  1.45%  intern-state     liblldb.so.12.0.0git   [.] 
DWARFFormValue::ExtractValue
  1.22%  intern-state     libc-2.31.so           [.] __strlen_avx2
  1.16%  intern-state     libc-2.31.so           [.] malloc
  1.11%  intern-state     libc-2.31.so           [.] _int_free
  1.08%  intern-state     liblldb.so.12.0.0git   [.] 
DWARFAttributes::ExtractFormValueAtIndex

when loading symbols from clang + libLLVM.so (release build with '-O2 -g').


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

https://reviews.llvm.org/D87675

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

Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -382,33 +382,33 @@
     parent.GetDeclContext(context);
   switch (tag) {
   case DW_TAG_module:
-    context.push_back({CompilerContextKind::Module, ConstString(GetName())});
+    context.emplace_back(CompilerContextKind::Module, ConstString(GetName()));
     break;
   case DW_TAG_namespace:
-    context.push_back({CompilerContextKind::Namespace, ConstString(GetName())});
+    context.emplace_back(CompilerContextKind::Namespace, ConstString(GetName()));
     break;
   case DW_TAG_structure_type:
-    context.push_back({CompilerContextKind::Struct, ConstString(GetName())});
+    context.emplace_back(CompilerContextKind::Struct, ConstString(GetName()));
     break;
   case DW_TAG_union_type:
-    context.push_back({CompilerContextKind::Union, ConstString(GetName())});
+    context.emplace_back(CompilerContextKind::Union, ConstString(GetName()));
     break;
   case DW_TAG_class_type:
-    context.push_back({CompilerContextKind::Class, ConstString(GetName())});
+    context.emplace_back(CompilerContextKind::Class, ConstString(GetName()));
     break;
   case DW_TAG_enumeration_type:
-    context.push_back({CompilerContextKind::Enum, ConstString(GetName())});
+    context.emplace_back(CompilerContextKind::Enum, ConstString(GetName()));
     break;
   case DW_TAG_subprogram:
-    context.push_back(
-        {CompilerContextKind::Function, ConstString(GetPubname())});
+    context.emplace_back(CompilerContextKind::Function,
+                         ConstString(GetPubname()));
     break;
   case DW_TAG_variable:
-    context.push_back(
-        {CompilerContextKind::Variable, ConstString(GetPubname())});
+    context.emplace_back(CompilerContextKind::Variable,
+                         ConstString(GetPubname()));
     break;
   case DW_TAG_typedef:
-    context.push_back({CompilerContextKind::Typedef, ConstString(GetName())});
+    context.emplace_back(CompilerContextKind::Typedef, ConstString(GetName()));
     break;
   default:
     break;
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
@@ -52,8 +52,10 @@
   DWARFAttributes();
   ~DWARFAttributes();
 
-  void Append(const DWARFUnit *cu, dw_offset_t attr_die_offset,
-              dw_attr_t attr, dw_form_t form);
+  void Append(const DWARFUnit *cu, dw_offset_t attr_die_offset, 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,11 @@
                                 // 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);
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
@@ -60,7 +60,7 @@
     if (form == DW_FORM_implicit_const)
       val.value.sval = data.GetULEB128(offset_ptr);
 
-    m_attributes.push_back(DWARFAttribute(attr, form, val));
+    m_attributes.emplace_back(attr, form, val);
   }
 
   return llvm::make_error<llvm::object::GenericBinaryError>(
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1896,18 +1896,16 @@
           if (!size)
             return false;
           llvm::APInt apint(*size, uval64, is_signed);
-          template_param_infos.args.push_back(
-              clang::TemplateArgument(ast, llvm::APSInt(apint, !is_signed),
-                                      ClangUtil::GetQualType(clang_type)));
-        } else {
-          template_param_infos.args.push_back(
-              clang::TemplateArgument(ClangUtil::GetQualType(clang_type)));
-        }
+          template_param_infos.args.emplace_back(
+              ast, llvm::APSInt(apint, !is_signed),
+              ClangUtil::GetQualType(clang_type));
+        } else
+          template_param_infos.args.emplace_back(
+              ClangUtil::GetQualType(clang_type));
       } else {
         auto *tplt_type = m_ast.CreateTemplateTemplateParmDecl(template_name);
         template_param_infos.names.push_back(name);
-        template_param_infos.args.push_back(
-            clang::TemplateArgument(clang::TemplateName(tplt_type)));
+        template_param_infos.args.emplace_back(clang::TemplateName(tplt_type));
       }
     }
   }
@@ -2743,10 +2741,10 @@
 
       ClangASTMetadata metadata;
       metadata.SetUserID(die.GetID());
-      delayed_properties.push_back(DelayedAddObjCClassProperty(
+      delayed_properties.emplace_back(
           class_clang_type, prop_name, member_type->GetLayoutCompilerType(),
           ivar_decl, prop_setter_name, prop_getter_name, prop_attributes,
-          &metadata));
+          &metadata);
 
       if (ivar_decl)
         m_ast.SetMetadataAsUserID(ivar_decl, die.GetID());
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to