Skip to content

[lldb][SymbolFileDWARF][NFC] Remove unnecessary calls to GetDWARFDeclContext #74523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2023

Conversation

felipepiovezan
Copy link
Contributor

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).

…Context

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).
@llvmbot
Copy link
Member

llvmbot commented Dec 5, 2023

@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)

Changes

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).


Full diff: https://github.com/llvm/llvm-project/pull/74523.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+3-2)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 142d092e6d2ee..d4cc26a3c329b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -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++.
@@ -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);

@felipepiovezan felipepiovezan merged commit 9982f8e into llvm:main Dec 6, 2023
@felipepiovezan felipepiovezan deleted the cleanup_dwarf_decl_ctx branch December 6, 2023 18:42
felipepiovezan added a commit to felipepiovezan/llvm-project that referenced this pull request Jan 31, 2024
…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).

(cherry picked from commit 9982f8e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants