Commit a705cf1a authored by Levon Ter-Grigoryan's avatar Levon Ter-Grigoryan Committed by Pavel Labath
Browse files

Expression eval lookup speedup by not returning methods in ManualDWARFIndex::GetFunctions

Summary:
This change is connected with
https://reviews.llvm.org/D69843

In large codebases, we sometimes see Module::FindFunctions (when called from
ClangExpressionDeclMap::FindExternalVisibleDecls) returning huge amounts of
functions.

In current fix I trying to return only function_fullnames from ManualDWARFIndex::GetFunctions when eFunctionNameTypeFull is passed as argument.

Reviewers: labath, jarin, aprantl

Reviewed By: labath

Subscribers: shafik, clayborg, teemperor, arphaman, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70846
parent 77cc690b
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
from lldbsuite.test import lldbinline
from lldbsuite.test import lldbinline, lldbplatformutil
from lldbsuite.test import decorators

lldbinline.MakeInlineTest(
    __file__, globals(), [
        decorators.expectedFailureAll(
            bugnumber="llvm.org/PR36715")])
            bugnumber="llvm.org/PR36715",
            oslist=lldbplatformutil.getDarwinOSTriples()+['windows'])])
+3 −3
Original line number Diff line number Diff line
@@ -1254,9 +1254,9 @@ void ClangExpressionDeclMap::LookupFunction(NameSearchContext &context,
    // TODO Fix FindFunctions so that it doesn't return
    //   instance methods for eFunctionNameTypeBase.

    target->GetImages().FindFunctions(name, eFunctionNameTypeFull,
                                      include_symbols, include_inlines,
                                      sc_list);
    target->GetImages().FindFunctions(
        name, eFunctionNameTypeFull | eFunctionNameTypeBase, include_symbols,
        include_inlines, sc_list);
  }

  // If we found more than one function, see if we can use the frame's decl
+0 −2
Original line number Diff line number Diff line
@@ -401,8 +401,6 @@ void ManualDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf,

  if (name_type_mask & eFunctionNameTypeFull) {
    DIEArray offsets;
    m_set.function_basenames.Find(name, offsets);
    m_set.function_methods.Find(name, offsets);
    m_set.function_fullnames.Find(name, offsets);
    for (const DIERef &die_ref: offsets) {
      DWARFDIE die = dwarf.GetDIE(die_ref);
+11 −9
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
// RUN:   FileCheck --check-prefix=METHOD %s
// RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \
// RUN:   FileCheck --check-prefix=FULL %s
// RUN:   FileCheck --check-prefix=FULL-APPLE %s
// RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \
// RUN:   FileCheck --check-prefix=FULL-MANGLED %s
// RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \
@@ -55,14 +55,16 @@
// METHOD-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
// METHOD-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv"

// FULL: Found 7 functions:
// FULL-DAG: name = "foo()", mangled = "_Z3foov"
// FULL-DAG: name = "foo(int)", mangled = "_Z3fooi"
// FULL-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
// FULL-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv"
// FULL-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv"
// FULL-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
// FULL-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv"
// FULL-APPLE: Found 7 functions:
// FULL-APPLE-DAG: name = "foo()", mangled = "_Z3foov"
// FULL-APPLE-DAG: name = "foo(int)", mangled = "_Z3fooi"
// FULL-APPLE-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
// FULL-APPLE-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv"
// FULL-APPLE-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv"
// FULL-APPLE-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
// FULL-APPLE-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv"

// FULL: Found 0 functions:

// FULL-MANGLED: Found 1 functions:
// FULL-MANGLED-DAG: name = "foo(int)", mangled = "_Z3fooi"