guiandrade created this revision. guiandrade added reviewers: clayborg, labath. guiandrade added a project: LLDB. Herald added subscribers: lldb-commits, JDevlieghere, aprantl. guiandrade added a comment.
Hey guys, This change is more for me to get to know what you guys think. I've noticed that GetDeclForUIDFromDWARF() calls inside SymbolFileDWARF::ParseDeclsForContext (https://github.com/llvm/llvm-project/blob/ef82098a800178a1f973abb8af86eaa690a29734/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp#L1216) often end up having no side effect besides generating a llvm::DenseMap::find invocation (https://github.com/llvm/llvm-project/blob/f07b4aff06d83c6ad25d95f456fbc12b2d2a0a0c/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp#L3322), especially when we evaluate multiple expressions inside the same scope. So I was wondering if there's a way to improve that. Do you guys think we could do something like what this change proposes, or am I missing something important? Thanks! This change creates a map that keeps track of the number of DIEs for each CompilerDeclContext so we can skip the ones we have already seen inside SymbolFileDWARF::ParseDeclsForContext. Repository: rLLDB LLDB https://reviews.llvm.org/D67022 Files: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -489,6 +489,10 @@ llvm::DenseMap<dw_offset_t, lldb_private::FileSpecList> m_type_unit_support_files; std::vector<uint32_t> m_lldb_cu_to_dwarf_unit; + + typedef std::pair<void *, lldb_private::TypeSystem *> DeclContextToOffsetKey; + typedef std::map<DeclContextToOffsetKey, uint32_t> DeclContextToOffsetMap; + DeclContextToOffsetMap m_decl_context_to_offset_map; }; #endif // SymbolFileDWARF_SymbolFileDWARF_h_ Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1209,11 +1209,17 @@ DWARFASTParser *ast_parser = type_system->GetDWARFParser(); std::vector<DWARFDIE> decl_ctx_die_list = ast_parser->GetDIEForDeclContext(decl_ctx); + DeclContextToOffsetKey offset_key = + std::make_pair(decl_ctx.GetOpaqueDeclContext(), type_system); + uint32_t &offset = m_decl_context_to_offset_map[offset_key]; - for (DWARFDIE decl_ctx_die : decl_ctx_die_list) - for (DWARFDIE decl = decl_ctx_die.GetFirstChild(); decl; + for (auto decl_ctx_die_it = decl_ctx_die_list.begin() + offset; + decl_ctx_die_it != decl_ctx_die_list.end(); ++decl_ctx_die_it) + for (DWARFDIE decl = decl_ctx_die_it->GetFirstChild(); decl; decl = decl.GetSibling()) ast_parser->GetDeclForUIDFromDWARF(decl); + + offset = decl_ctx_die_list.size(); } user_id_t SymbolFileDWARF::GetUID(DIERef ref) {
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -489,6 +489,10 @@ llvm::DenseMap<dw_offset_t, lldb_private::FileSpecList> m_type_unit_support_files; std::vector<uint32_t> m_lldb_cu_to_dwarf_unit; + + typedef std::pair<void *, lldb_private::TypeSystem *> DeclContextToOffsetKey; + typedef std::map<DeclContextToOffsetKey, uint32_t> DeclContextToOffsetMap; + DeclContextToOffsetMap m_decl_context_to_offset_map; }; #endif // SymbolFileDWARF_SymbolFileDWARF_h_ Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1209,11 +1209,17 @@ DWARFASTParser *ast_parser = type_system->GetDWARFParser(); std::vector<DWARFDIE> decl_ctx_die_list = ast_parser->GetDIEForDeclContext(decl_ctx); + DeclContextToOffsetKey offset_key = + std::make_pair(decl_ctx.GetOpaqueDeclContext(), type_system); + uint32_t &offset = m_decl_context_to_offset_map[offset_key]; - for (DWARFDIE decl_ctx_die : decl_ctx_die_list) - for (DWARFDIE decl = decl_ctx_die.GetFirstChild(); decl; + for (auto decl_ctx_die_it = decl_ctx_die_list.begin() + offset; + decl_ctx_die_it != decl_ctx_die_list.end(); ++decl_ctx_die_it) + for (DWARFDIE decl = decl_ctx_die_it->GetFirstChild(); decl; decl = decl.GetSibling()) ast_parser->GetDeclForUIDFromDWARF(decl); + + offset = decl_ctx_die_list.size(); } user_id_t SymbolFileDWARF::GetUID(DIERef ref) {
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits