jankratochvil created this revision. jankratochvil added reviewers: labath, clayborg. jankratochvil added a project: LLDB. Herald added a subscriber: JDevlieghere. Herald added a reviewer: shafik. jankratochvil requested review of this revision.
Replace `DWARFDIE` by `std::pair<SymbolFileDWARF *, DIERef>`. Currently it has the same size but after D96236 <https://reviews.llvm.org/D96236> it would needlessly increase from 16 bytes to 24 bytes affecting performance. This replacement should have no real performance disadvantage. My question about upstreaming of this patchset. <https://reviews.llvm.org/D96236#3020116> Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D110396 Files: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp Index: lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp =================================================================== --- lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp +++ lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp @@ -26,7 +26,7 @@ std::vector<const clang::DeclContext *> GetDeclContextToDIEMapKeys() { std::vector<const clang::DeclContext *> keys; - for (const auto &it : m_decl_ctx_to_die) + for (const auto &it : m_decl_ctx_to_filedieref) keys.push_back(it.first); return keys; } Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -75,8 +75,9 @@ typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap; - typedef std::multimap<const clang::DeclContext *, const DWARFDIE> - DeclContextToDIEMap; + typedef std::multimap<const clang::DeclContext *, + std::pair<SymbolFileDWARF *, DIERef>> + DeclContextToFileDIERefMap; typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::OptionalClangModuleID> DIEToModuleMap; @@ -86,7 +87,7 @@ lldb_private::TypeSystemClang &m_ast; DIEToDeclMap m_die_to_decl; DIEToDeclContextMap m_die_to_decl_ctx; - DeclContextToDIEMap m_decl_ctx_to_die; + DeclContextToFileDIERefMap m_decl_ctx_to_filedieref; DIEToModuleMap m_die_to_module; std::unique_ptr<lldb_private::ClangASTImporter> m_clang_ast_importer_up; /// @} Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -58,7 +58,7 @@ using namespace lldb; using namespace lldb_private; DWARFASTParserClang::DWARFASTParserClang(TypeSystemClang &ast) - : m_ast(ast), m_die_to_decl_ctx(), m_decl_ctx_to_die() {} + : m_ast(ast), m_die_to_decl_ctx(), m_decl_ctx_to_filedieref() {} DWARFASTParserClang::~DWARFASTParserClang() = default; @@ -2099,11 +2099,17 @@ lldb_private::CompilerDeclContext decl_context) { 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 = m_decl_ctx_to_die.erase(it)) - for (DWARFDIE decl : it->second.children()) + for (auto it = m_decl_ctx_to_filedieref.find(opaque_decl_ctx); + it != m_decl_ctx_to_filedieref.end() && it->first == opaque_decl_ctx; + it = m_decl_ctx_to_filedieref.erase(it)) { + // We need to store also SymbolFileDWARF * as we cannot assume + // m_ast.GetSymbolFile() is actually a SymbolFileDWARF, it can be + // a SymbolFileDWARFDebugMap for Apple binaries. + std::pair<SymbolFileDWARF *, DIERef> declpair = it->second; + DWARFDIE die = declpair.first->GetDIE(declpair.second); + for (DWARFDIE decl : die.children()) GetClangDeclForDIE(decl); + } } CompilerDecl DWARFASTParserClang::GetDeclForUIDFromDWARF(const DWARFDIE &die) { @@ -3447,9 +3453,12 @@ void DWARFASTParserClang::LinkDeclContextToDIE(clang::DeclContext *decl_ctx, const DWARFDIE &die) { m_die_to_decl_ctx[die.GetDIE()] = decl_ctx; + SymbolFileDWARF *sym_file = &die.GetCU()->GetSymbolFileDWARF(); + DIERef ref = *die.GetDIERef(); // There can be many DIEs for a single decl context - // m_decl_ctx_to_die[decl_ctx].insert(die.GetDIE()); - m_decl_ctx_to_die.insert(std::make_pair(decl_ctx, die)); + // m_decl_ctx_to_filedieref[decl_ctx].insert(...); + m_decl_ctx_to_filedieref.insert( + std::make_pair(decl_ctx, std::make_pair(sym_file, ref))); } bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
Index: lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp =================================================================== --- lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp +++ lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp @@ -26,7 +26,7 @@ std::vector<const clang::DeclContext *> GetDeclContextToDIEMapKeys() { std::vector<const clang::DeclContext *> keys; - for (const auto &it : m_decl_ctx_to_die) + for (const auto &it : m_decl_ctx_to_filedieref) keys.push_back(it.first); return keys; } Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -75,8 +75,9 @@ typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap; - typedef std::multimap<const clang::DeclContext *, const DWARFDIE> - DeclContextToDIEMap; + typedef std::multimap<const clang::DeclContext *, + std::pair<SymbolFileDWARF *, DIERef>> + DeclContextToFileDIERefMap; typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::OptionalClangModuleID> DIEToModuleMap; @@ -86,7 +87,7 @@ lldb_private::TypeSystemClang &m_ast; DIEToDeclMap m_die_to_decl; DIEToDeclContextMap m_die_to_decl_ctx; - DeclContextToDIEMap m_decl_ctx_to_die; + DeclContextToFileDIERefMap m_decl_ctx_to_filedieref; DIEToModuleMap m_die_to_module; std::unique_ptr<lldb_private::ClangASTImporter> m_clang_ast_importer_up; /// @} Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -58,7 +58,7 @@ using namespace lldb; using namespace lldb_private; DWARFASTParserClang::DWARFASTParserClang(TypeSystemClang &ast) - : m_ast(ast), m_die_to_decl_ctx(), m_decl_ctx_to_die() {} + : m_ast(ast), m_die_to_decl_ctx(), m_decl_ctx_to_filedieref() {} DWARFASTParserClang::~DWARFASTParserClang() = default; @@ -2099,11 +2099,17 @@ lldb_private::CompilerDeclContext decl_context) { 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 = m_decl_ctx_to_die.erase(it)) - for (DWARFDIE decl : it->second.children()) + for (auto it = m_decl_ctx_to_filedieref.find(opaque_decl_ctx); + it != m_decl_ctx_to_filedieref.end() && it->first == opaque_decl_ctx; + it = m_decl_ctx_to_filedieref.erase(it)) { + // We need to store also SymbolFileDWARF * as we cannot assume + // m_ast.GetSymbolFile() is actually a SymbolFileDWARF, it can be + // a SymbolFileDWARFDebugMap for Apple binaries. + std::pair<SymbolFileDWARF *, DIERef> declpair = it->second; + DWARFDIE die = declpair.first->GetDIE(declpair.second); + for (DWARFDIE decl : die.children()) GetClangDeclForDIE(decl); + } } CompilerDecl DWARFASTParserClang::GetDeclForUIDFromDWARF(const DWARFDIE &die) { @@ -3447,9 +3453,12 @@ void DWARFASTParserClang::LinkDeclContextToDIE(clang::DeclContext *decl_ctx, const DWARFDIE &die) { m_die_to_decl_ctx[die.GetDIE()] = decl_ctx; + SymbolFileDWARF *sym_file = &die.GetCU()->GetSymbolFileDWARF(); + DIERef ref = *die.GetDIERef(); // There can be many DIEs for a single decl context - // m_decl_ctx_to_die[decl_ctx].insert(die.GetDIE()); - m_decl_ctx_to_die.insert(std::make_pair(decl_ctx, die)); + // m_decl_ctx_to_filedieref[decl_ctx].insert(...); + m_decl_ctx_to_filedieref.insert( + std::make_pair(decl_ctx, std::make_pair(sym_file, ref))); } bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits