Skip to content

Commit

Permalink
[lldb][SymbolFileDWARF][NFC] Remove unnecessary calls to GetDWARFDecl…
Browse files Browse the repository at this point in the history
…Context (llvm#74523)

The function FindDefinitionTypeForDWARFDeclContext loops over all DIEs
corresponding to types with a certain name and compares the context of
each found DIE with the context of a target DIE. However, the target DIE
never changes throughout this search, and yet we recompute its
DeclContext on every iteration of the search. This is wasteful because
the method is not exactly free (see
DWARFDebugInfoEntry::GetDWARFDeclContextStatic).
  • Loading branch information
felipepiovezan authored Dec 6, 2023
1 parent 45e7b41 commit 9982f8e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3120,7 +3120,8 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) {
template_params = dwarf_ast->GetDIEClassTemplateParams(die);
}

m_index->GetTypes(GetDWARFDeclContext(die), [&](DWARFDIE type_die) {
const DWARFDeclContext die_dwarf_decl_ctx = GetDWARFDeclContext(die);
m_index->GetTypes(die_dwarf_decl_ctx, [&](DWARFDIE type_die) {
// Make sure type_die's language matches the type system we are
// looking for. We don't want to find a "Foo" type from Java if we
// are looking for a "Foo" type for C, C++, ObjC, or ObjC++.
Expand Down Expand Up @@ -3184,7 +3185,7 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) {
}

// Make sure the decl contexts match all the way up
if (GetDWARFDeclContext(die) != type_dwarf_decl_ctx)
if (die_dwarf_decl_ctx != type_dwarf_decl_ctx)
return true;

Type *resolved_type = ResolveType(type_die, false);
Expand Down

0 comments on commit 9982f8e

Please sign in to comment.