aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/SymbolFile
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-09-24 12:36:54 +0000
committerPavel Labath <pavel@labath.sk>2019-09-24 12:36:54 +0000
commit13a4e8f3ef24dd69e143bb3d3591dccb2c04df9d (patch)
tree2d34679b9811f3d3311e7c8d2def58a72e5e41b8 /lldb/source/Plugins/SymbolFile
parent182d4874fd4d3aa4399c14d497a41909e12fb5ed (diff)
downloadllvm-13a4e8f3ef24dd69e143bb3d3591dccb2c04df9d.tar.gz
llvm-13a4e8f3ef24dd69e143bb3d3591dccb2c04df9d.tar.bz2
llvm-13a4e8f3ef24dd69e143bb3d3591dccb2c04df9d.zip
Enhance SymbolFileDWARF::ParseDeclsForContext performance
This implements DWARFASTParserClang::EnsureAllDIEsInDeclContextHaveBeenParsed so as to provide a faster way to ensure all DIEs linked to a certain declaration context have been parsed. Currently, we rely on SymbolFileDWARF::ParseDeclsForContext calling DWARFASTParserClang::GetDIEForDeclContext, and only then DWARFASTParserClang::GetDeclForUIDFromDWARF. This change shortcuts that logic and removes redundant calls to DWARFASTParserClang:: GetClangDeclForDIE by deleting DIEs from the m_decl_ctx_to_die map once they have been parsed. Differential Revision: https://reviews.llvm.org/D67760 Patch by Guilherme Andrade <guiandrade@google.com>. llvm-svn: 372744
Diffstat (limited to 'lldb/source/Plugins/SymbolFile')
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h4
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp11
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h4
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp13
4 files changed, 13 insertions, 19 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index e7927b31b9c3..4f6885e61107 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -48,8 +48,8 @@ public:
virtual lldb_private::CompilerDeclContext
GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) = 0;
- virtual std::vector<DWARFDIE>
- GetDIEForDeclContext(lldb_private::CompilerDeclContext decl_context) = 0;
+ virtual void EnsureAllDIEsInDeclContextHaveBeenParsed(
+ lldb_private::CompilerDeclContext decl_context) = 0;
static llvm::Optional<lldb_private::SymbolFile::ArrayInfo>
ParseChildArrayInfo(const DWARFDIE &parent_die,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 3c799f920a27..655246b499a0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2183,15 +2183,16 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die,
return false;
}
-std::vector<DWARFDIE> DWARFASTParserClang::GetDIEForDeclContext(
+void DWARFASTParserClang::EnsureAllDIEsInDeclContextHaveBeenParsed(
lldb_private::CompilerDeclContext decl_context) {
- std::vector<DWARFDIE> result;
auto opaque_decl_ctx =
(clang::DeclContext *)decl_context.GetOpaqueDeclContext();
for (auto it = m_decl_ctx_to_die.find(opaque_decl_ctx);
- it != m_decl_ctx_to_die.end() && it->first == opaque_decl_ctx; it++)
- result.push_back(it->second);
- return result;
+ it != m_decl_ctx_to_die.end() && it->first == opaque_decl_ctx;
+ it = m_decl_ctx_to_die.erase(it))
+ for (DWARFDIE decl = it->second.GetFirstChild(); decl;
+ decl = decl.GetSibling())
+ GetClangDeclForDIE(decl);
}
CompilerDecl DWARFASTParserClang::GetDeclForUIDFromDWARF(const DWARFDIE &die) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index 5b5d83d65932..a8daa10596e5 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -51,8 +51,8 @@ public:
lldb_private::CompilerDecl
GetDeclForUIDFromDWARF(const DWARFDIE &die) override;
- std::vector<DWARFDIE>
- GetDIEForDeclContext(lldb_private::CompilerDeclContext decl_context) override;
+ void EnsureAllDIEsInDeclContextHaveBeenParsed(
+ lldb_private::CompilerDeclContext decl_context) override;
lldb_private::CompilerDeclContext
GetDeclContextForUIDFromDWARF(const DWARFDIE &die) override;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 2177cbc89574..504fc2f7410c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1217,16 +1217,9 @@ bool SymbolFileDWARF::ClassOrStructIsVirtual(const DWARFDIE &parent_die) {
void SymbolFileDWARF::ParseDeclsForContext(CompilerDeclContext decl_ctx) {
auto *type_system = decl_ctx.GetTypeSystem();
- if (!type_system)
- return;
- DWARFASTParser *ast_parser = type_system->GetDWARFParser();
- std::vector<DWARFDIE> decl_ctx_die_list =
- ast_parser->GetDIEForDeclContext(decl_ctx);
-
- for (DWARFDIE decl_ctx_die : decl_ctx_die_list)
- for (DWARFDIE decl = decl_ctx_die.GetFirstChild(); decl;
- decl = decl.GetSibling())
- ast_parser->GetDeclForUIDFromDWARF(decl);
+ if (type_system != nullptr)
+ type_system->GetDWARFParser()->EnsureAllDIEsInDeclContextHaveBeenParsed(
+ decl_ctx);
}
user_id_t SymbolFileDWARF::GetUID(DIERef ref) {