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.
After D96236 <https://reviews.llvm.org/D96236> using just `DWARFDebugInfoEntry *` is ambiguous as it does not contain MainCU. `DIERef` (after D96239 <https://reviews.llvm.org/D96239>) does contain it and it has the same sizeof as `DWARFDebugInfoEntry *`. 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/D110399 Files: lldb/source/Plugins/SymbolFile/DWARF/DIERef.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -73,8 +73,7 @@ class DelayedAddObjCClassProperty; typedef std::vector<DelayedAddObjCClassProperty> DelayedPropertyList; - typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> - DIEToDeclContextMap; + typedef llvm::DenseMap<DIERef, clang::DeclContext *> DIERefToDeclContextMap; typedef std::multimap<const clang::DeclContext *, std::pair<SymbolFileDWARF *, DIERef>> DeclContextToFileDIERefMap; @@ -86,7 +85,7 @@ lldb_private::TypeSystemClang &m_ast; DIEToDeclMap m_die_to_decl; - DIEToDeclContextMap m_die_to_decl_ctx; + DIERefToDeclContextMap m_dieref_to_decl_ctx; 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_filedieref() {} + : m_ast(ast), m_dieref_to_decl_ctx(), m_decl_ctx_to_filedieref() {} DWARFASTParserClang::~DWARFASTParserClang() = default; @@ -1040,7 +1040,7 @@ if (attrs.specification.IsValid()) { // We have a specification which we are going to base our // function prototype off of, so we need this type to be - // completed so that the m_die_to_decl_ctx for the method in + // completed so that the m_dieref_to_decl_ctx for the method in // the specification has a valid clang decl context. class_type->GetForwardCompilerType(); // If we have a specification, then the function type should @@ -1061,7 +1061,7 @@ } else if (attrs.abstract_origin.IsValid()) { // We have a specification which we are going to base our // function prototype off of, so we need this type to be - // completed so that the m_die_to_decl_ctx for the method in + // completed so that the m_dieref_to_decl_ctx for the method in // the abstract origin has a valid clang decl context. class_type->GetForwardCompilerType(); @@ -3351,8 +3351,8 @@ clang::BlockDecl *DWARFASTParserClang::ResolveBlockDIE(const DWARFDIE &die) { if (die && die.Tag() == DW_TAG_lexical_block) { - clang::BlockDecl *decl = - llvm::cast_or_null<clang::BlockDecl>(m_die_to_decl_ctx[die.GetDIE()]); + clang::BlockDecl *decl = llvm::cast_or_null<clang::BlockDecl>( + m_dieref_to_decl_ctx[*die.GetDIERef()]); if (!decl) { DWARFDIE decl_context_die; @@ -3375,8 +3375,8 @@ if (die && die.Tag() == DW_TAG_namespace) { // See if we already parsed this namespace DIE and associated it with a // uniqued namespace declaration - clang::NamespaceDecl *namespace_decl = - static_cast<clang::NamespaceDecl *>(m_die_to_decl_ctx[die.GetDIE()]); + clang::NamespaceDecl *namespace_decl = static_cast<clang::NamespaceDecl *>( + m_dieref_to_decl_ctx[*die.GetDIERef()]); if (namespace_decl) return namespace_decl; else { @@ -3443,8 +3443,9 @@ clang::DeclContext * DWARFASTParserClang::GetCachedClangDeclContextForDIE(const DWARFDIE &die) { if (die) { - DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die.GetDIE()); - if (pos != m_die_to_decl_ctx.end()) + DIERefToDeclContextMap::iterator pos = + m_dieref_to_decl_ctx.find(*die.GetDIERef()); + if (pos != m_dieref_to_decl_ctx.end()) return pos->second; } return nullptr; @@ -3452,9 +3453,9 @@ 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(); + m_dieref_to_decl_ctx[ref] = decl_ctx; + SymbolFileDWARF *sym_file = &die.GetCU()->GetSymbolFileDWARF(); // There can be many DIEs for a single decl context // m_decl_ctx_to_filedieref[decl_ctx].insert(...); m_decl_ctx_to_filedieref.insert( @@ -3588,7 +3589,7 @@ dst_die = dst_name_to_die.GetValueAtIndexUnchecked(idx); clang::DeclContext *src_decl_ctx = - src_dwarf_ast_parser->m_die_to_decl_ctx[src_die.GetDIE()]; + src_dwarf_ast_parser->m_dieref_to_decl_ctx[*src_die.GetDIERef()]; if (src_decl_ctx) { LLDB_LOGF(log, "uniquing decl context %p from 0x%8.8x for 0x%8.8x", static_cast<void *>(src_decl_ctx), src_die.GetOffset(), @@ -3632,7 +3633,7 @@ if (src_die && (src_die.Tag() == dst_die.Tag())) { clang::DeclContext *src_decl_ctx = - src_dwarf_ast_parser->m_die_to_decl_ctx[src_die.GetDIE()]; + src_dwarf_ast_parser->m_dieref_to_decl_ctx[*src_die.GetDIERef()]; if (src_decl_ctx) { LLDB_LOGF(log, "uniquing decl context %p from 0x%8.8x for 0x%8.8x", static_cast<void *>(src_decl_ctx), src_die.GetOffset(), @@ -3687,7 +3688,7 @@ if (dst_die) { // Both classes have the artificial types, link them clang::DeclContext *src_decl_ctx = - src_dwarf_ast_parser->m_die_to_decl_ctx[src_die.GetDIE()]; + src_dwarf_ast_parser->m_dieref_to_decl_ctx[*src_die.GetDIERef()]; if (src_decl_ctx) { LLDB_LOGF(log, "uniquing decl context %p from 0x%8.8x for 0x%8.8x", static_cast<void *>(src_decl_ctx), src_die.GetOffset(), Index: lldb/source/Plugins/SymbolFile/DWARF/DIERef.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DIERef.h +++ lldb/source/Plugins/SymbolFile/DWARF/DIERef.h @@ -10,6 +10,7 @@ #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DIEREF_H #include "lldb/Core/dwarf.h" +#include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/Optional.h" #include "llvm/Support/FormatProviders.h" #include <cassert> @@ -66,6 +67,10 @@ } private: + friend struct llvm::DenseMapInfo<DIERef>; + DIERef(unsigned unique) : m_u(llvm::None, DebugInfo), m_die_offset(0) { + m_u.s.dwo_num = unique; + } uint32_t get_hash_value() const { return llvm::detail::combineHashValue(m_u.hash_bits, m_die_offset); } @@ -93,6 +98,16 @@ template<> struct format_provider<DIERef> { static void format(const DIERef &ref, raw_ostream &OS, StringRef Style); }; + +/// DenseMapInfo implementation. +/// \{ +template <> struct DenseMapInfo<DIERef> { + static inline DIERef getEmptyKey() { return DIERef(1); } + static inline DIERef getTombstoneKey() { return DIERef(2); } + static unsigned getHashValue(DIERef val) { return val.get_hash_value(); } + static bool isEqual(DIERef LHS, DIERef RHS) { return LHS == RHS; } +}; +/// \} } // namespace llvm #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DIEREF_H
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits