[Lldb-commits] [PATCH] D103107: [lldb] Remove cache in get_demangled_name_without_arguments
Raphael Isemann via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue May 25 11:34:52 PDT 2021
teemperor created this revision.
teemperor added a reviewer: LLDB.
teemperor added a project: LLDB.
Herald added a subscriber: JDevlieghere.
teemperor requested review of this revision.
This function has a single-value caching based on function local static variables.
This causes two problems:
- As there is no synchronization, so this function randomly returns the demangled name of other functions that are demangled at the same time.
- The 1-element cache is not very effective (the cache rate is around 0% when running the LLDB test suite).
I would propose just removing it.
To prevent anyone else the git archeology: the static result variables were originally
added as this returned a ConstString reference, but that has since been changed
so that this returns by value.
https://reviews.llvm.org/D103107
Files:
lldb/source/Core/Mangled.cpp
Index: lldb/source/Core/Mangled.cpp
===================================================================
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -35,26 +35,8 @@
return Mangled::GetManglingScheme(s) != Mangled::eManglingSchemeNone;
}
-static ConstString
-get_demangled_name_without_arguments(ConstString mangled,
- ConstString demangled) {
- // This pair is <mangled name, demangled name without function arguments>
- static std::pair<ConstString, ConstString>
- g_most_recent_mangled_to_name_sans_args;
-
- // Need to have the mangled & demangled names we're currently examining as
- // statics so we can return a const ref to them at the end of the func if we
- // don't have anything better.
- static ConstString g_last_mangled;
- static ConstString g_last_demangled;
-
- if (mangled && g_most_recent_mangled_to_name_sans_args.first == mangled) {
- return g_most_recent_mangled_to_name_sans_args.second;
- }
-
- g_last_demangled = demangled;
- g_last_mangled = mangled;
-
+static ConstString GetDemangledNameWithoutArguments(ConstString mangled,
+ ConstString demangled) {
const char *mangled_name_cstr = mangled.GetCString();
if (demangled && mangled_name_cstr && mangled_name_cstr[0]) {
@@ -73,17 +55,13 @@
if (!cxx_method.GetContext().empty())
shortname = cxx_method.GetContext().str() + "::";
shortname += cxx_method.GetBasename().str();
- ConstString result(shortname.c_str());
- g_most_recent_mangled_to_name_sans_args.first = mangled;
- g_most_recent_mangled_to_name_sans_args.second = result;
- return g_most_recent_mangled_to_name_sans_args.second;
+ return ConstString(shortname);
}
}
}
-
if (demangled)
- return g_last_demangled;
- return g_last_mangled;
+ return demangled;
+ return mangled;
}
#pragma mark Mangled
@@ -347,7 +325,7 @@
ConstString demangled = GetDemangledName();
if (preference == ePreferDemangledWithoutArguments) {
- return get_demangled_name_without_arguments(m_mangled, demangled);
+ return GetDemangledNameWithoutArguments(m_mangled, demangled);
}
if (preference == ePreferDemangled) {
// Call the accessor to make sure we get a demangled name in case it hasn't
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103107.347735.patch
Type: text/x-patch
Size: 2365 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210525/7040d394/attachment-0001.bin>
More information about the lldb-commits
mailing list