Some minor improvements on the symtab parsing code

* Remove an unneccessary re-computaion on arch spec from the ELF file
* Use a local cache to optimize name based section lookups in symtab
  parsing
* Optimize C++ method basename validation with replacing a regex with
  hand written code

These modifications reduce the time required to parse the symtab from
large applications by ~25% (tested with LLDB as inferior)

Differential revision: http://reviews.llvm.org/D14088

llvm-svn: 251402
This commit is contained in:
Tamas Berghammer
2015-10-27 10:43:27 +00:00
parent 458e79b814
commit 9fa1147052
2 changed files with 60 additions and 31 deletions

View File

@@ -11,6 +11,7 @@
#include <cassert>
#include <algorithm>
#include <unordered_map>
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/DataBuffer.h"
@@ -1943,6 +1944,13 @@ ObjectFileELF::ParseSymbols (Symtab *symtab,
// makes it highly unlikely that this will collide with anything else.
bool skip_oatdata_oatexec = m_file.GetFilename() == ConstString("system@framework@boot.oat");
ArchSpec arch;
GetArchitecture(arch);
// Local cache to avoid doing a FindSectionByName for each symbol. The "const char*" key must
// came from a ConstString object so they can be compared by pointer
std::unordered_map<const char*, lldb::SectionSP> section_name_to_section;
unsigned i;
for (i = 0; i < num_symbols; ++i)
{
@@ -2048,8 +2056,7 @@ ObjectFileELF::ParseSymbols (Symtab *symtab,
int64_t symbol_value_offset = 0;
uint32_t additional_flags = 0;
ArchSpec arch;
if (GetArchitecture(arch))
if (arch.IsValid())
{
if (arch.GetMachine() == llvm::Triple::arm)
{
@@ -2175,11 +2182,13 @@ ObjectFileELF::ParseSymbols (Symtab *symtab,
if (module_section_list && module_section_list != section_list)
{
const ConstString &sect_name = symbol_section_sp->GetName();
lldb::SectionSP section_sp (module_section_list->FindSectionByName (sect_name));
if (section_sp && section_sp->GetFileSize())
{
symbol_section_sp = section_sp;
}
auto section_it = section_name_to_section.find(sect_name.GetCString());
if (section_it == section_name_to_section.end())
section_it = section_name_to_section.emplace(
sect_name.GetCString(),
module_section_list->FindSectionByName (sect_name)).first;
if (section_it->second && section_it->second->GetFileSize())
symbol_section_sp = section_it->second;
}
}
}