xiaobai created this revision.
Herald added a subscriber: emaste.

I recently ran into a shared object that had a reasonably large number
of absolute symbols. Parsing all the symbols in the shared object took an
unusually long amount of time, so I looked into it and found that when we
created fake sections for these symbols, we would add them to the module's
section list without inserting it into the cache (`section_name_to_section`).
While this works, in some cases we perform a lookup of the section in that cache
almost right after we create it and put in the module section list.
Given I had a large amount of symbols that triggered this code path, performance
was abysmal. This change greatly improved performance there.


https://reviews.llvm.org/D40869

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp


Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -294,7 +294,7 @@
   uint32_t arch_variant = ArchSpec::eMIPSSubType_unknown;
   uint32_t fileclass = header.e_ident[EI_CLASS];
 
-  // If there aren't any elf flags available (e.g core elf file) then return 
default 
+  // If there aren't any elf flags available (e.g core elf file) then return 
default
   // 32 or 64 bit arch (without any architecture revision) based on object 
file's class.
   if (header.e_type == ET_CORE) {
     switch (fileclass) {
@@ -1446,7 +1446,7 @@
           // In case of MIPSR6, the LLDB_NT_OWNER_GNU note is missing
           // for some cases (e.g. compile with -nostdlib)
           // Hence set OS to Linux
-          arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux); 
+          arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
       }
     }
 
@@ -1550,7 +1550,7 @@
     const uint32_t sub_type = subTypeFromElfHeader(header);
     arch_spec.SetArchitecture(eArchTypeELF, header.e_machine, sub_type,
                               header.e_ident[EI_OSABI]);
-    
+
     // Validate if it is ok to remove GetOsFromOSABI.
     // Note, that now the OS is determined based on EI_OSABI flag and
     // the info extracted from ELF notes (see RefineModuleDetailsFromNote).
@@ -2361,6 +2361,8 @@
 
       module_section_list->AddSection(symbol_section_sp);
       section_list->AddSection(symbol_section_sp);
+      section_name_to_section.emplace(fake_section_name.GetCString(),
+                                      symbol_section_sp);
     }
 
     if (symbol_section_sp &&


Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -294,7 +294,7 @@
   uint32_t arch_variant = ArchSpec::eMIPSSubType_unknown;
   uint32_t fileclass = header.e_ident[EI_CLASS];
 
-  // If there aren't any elf flags available (e.g core elf file) then return default 
+  // If there aren't any elf flags available (e.g core elf file) then return default
   // 32 or 64 bit arch (without any architecture revision) based on object file's class.
   if (header.e_type == ET_CORE) {
     switch (fileclass) {
@@ -1446,7 +1446,7 @@
           // In case of MIPSR6, the LLDB_NT_OWNER_GNU note is missing
           // for some cases (e.g. compile with -nostdlib)
           // Hence set OS to Linux
-          arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux); 
+          arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
       }
     }
 
@@ -1550,7 +1550,7 @@
     const uint32_t sub_type = subTypeFromElfHeader(header);
     arch_spec.SetArchitecture(eArchTypeELF, header.e_machine, sub_type,
                               header.e_ident[EI_OSABI]);
-    
+
     // Validate if it is ok to remove GetOsFromOSABI.
     // Note, that now the OS is determined based on EI_OSABI flag and
     // the info extracted from ELF notes (see RefineModuleDetailsFromNote).
@@ -2361,6 +2361,8 @@
 
       module_section_list->AddSection(symbol_section_sp);
       section_list->AddSection(symbol_section_sp);
+      section_name_to_section.emplace(fake_section_name.GetCString(),
+                                      symbol_section_sp);
     }
 
     if (symbol_section_sp &&
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to