Skip to content

Commit e4cf944

Browse files
committed
Remove incorrect and superfluous caching in Mangled.
There was a global cache for Swift display names, however, it didn't take the symbol context into account, which means the demangling result is non-deterministic depending on whether the symbol context had the necessary debug info to resolve the names of archetypes or not. In addition to that Display names are not supposed to be on a hot path (unlike names, which are used to resolve breakpoints).
1 parent 8173e79 commit e4cf944

File tree

1 file changed

+6
-47
lines changed

1 file changed

+6
-47
lines changed

lldb/source/Core/Mangled.cpp

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,6 @@ static inline bool cstring_is_mangled(llvm::StringRef s) {
4545
return Mangled::GetManglingScheme(s) != Mangled::eManglingSchemeNone;
4646
}
4747

48-
#ifdef LLDB_ENABLE_SWIFT
49-
#pragma mark DisplayDemangledNamesCache
50-
51-
// make the key type be a const char* because that gives us usable
52-
// DenseMapInfo for free making DenseMap work for ConstString requires
53-
// us to provide two "invalid" values: the empty key and the tombstone
54-
// key; but for ConstString, we really don't have any well-known
55-
// invalid value other than ConstString(nullptr) so, just use const
56-
// char* as the key as LLVM knows how to do proper DenseMapInfo for
57-
// pointers
58-
static ThreadSafeDenseMap<const char *, ConstString>&
59-
GetDisplayDemangledNamesCache() {
60-
static ThreadSafeDenseMap<const char *, ConstString> g_cache;
61-
return g_cache;
62-
}
63-
#endif // LLDB_ENABLE_SWIFT
64-
6548
#pragma mark Mangled
6649

6750
Mangled::ManglingScheme Mangled::GetManglingScheme(llvm::StringRef const name) {
@@ -346,39 +329,15 @@ ConstString Mangled::GetDemangledName(// BEGIN SWIFT
346329

347330
ConstString Mangled::GetDisplayDemangledName(
348331
// BEGIN SWIFT
349-
const SymbolContext *sc
350-
) const {
351-
ConstString demangled;
332+
const SymbolContext *sc) const {
352333
#ifdef LLDB_ENABLE_SWIFT
353-
if (m_mangled) {
354-
do {
355-
const char *mangled = m_mangled.GetCString();
356-
357-
if (mangled) {
358-
if (SwiftLanguageRuntime::IsSwiftMangledName(m_mangled.GetStringRef())) {
359-
auto& display_cache = ::GetDisplayDemangledNamesCache();
360-
if (display_cache.Lookup(mangled, demangled) &&
361-
demangled)
362-
break;
363-
364-
std::string demangled_std =
365-
SwiftLanguageRuntime::DemangleSymbolAsString(
366-
m_mangled.GetStringRef(), SwiftLanguageRuntime::eSimplified,
367-
sc);
368-
if (!demangled_std.empty()) {
369-
demangled.SetCString(demangled_std.c_str());
370-
display_cache.Insert(mangled, demangled);
371-
break;
372-
}
373-
}
374-
}
375-
} while (0);
376-
}
334+
if (m_mangled &&
335+
SwiftLanguageRuntime::IsSwiftMangledName(m_mangled.GetStringRef()))
336+
return ConstString(SwiftLanguageRuntime::DemangleSymbolAsString(
337+
m_mangled.GetStringRef(), SwiftLanguageRuntime::eSimplified, sc));
377338
#endif // LLDB_ENABLE_SWIFT
378-
if (!demangled)
379-
demangled = GetDemangledName();
380-
return demangled ? demangled : m_mangled;
381339
// END SWIFT
340+
return GetDemangledName();
382341
}
383342

384343
bool Mangled::NameMatches(const RegularExpression &regex) const {

0 commit comments

Comments
 (0)