[PATCH] D102484: Avoid calculating the string hash twice in GsymCreator::insertString.
Simon Giesecke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 19 03:33:03 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf29c4c60978c: Avoid calculating the string hash twice in GsymCreator::insertString. (authored by simon.giesecke).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102484/new/
https://reviews.llvm.org/D102484
Files:
llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
Index: llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
===================================================================
--- llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
+++ llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
@@ -293,6 +293,9 @@
uint32_t GsymCreator::insertString(StringRef S, bool Copy) {
if (S.empty())
return 0;
+
+ // The hash can be calculated outside the lock.
+ CachedHashStringRef CHStr(S);
std::lock_guard<std::recursive_mutex> Guard(Mutex);
if (Copy) {
// We need to provide backing storage for the string if requested
@@ -301,11 +304,11 @@
// copied, but any string created by code will need to be copied.
// This allows GsymCreator to be really fast when parsing DWARF and
// other object files as most strings don't need to be copied.
- CachedHashStringRef CHStr(S);
if (!StrTab.contains(CHStr))
- S = StringStorage.insert(S).first->getKey();
+ CHStr = CachedHashStringRef{StringStorage.insert(S).first->getKey(),
+ CHStr.hash()};
}
- return StrTab.add(S);
+ return StrTab.add(CHStr);
}
void GsymCreator::addFunctionInfo(FunctionInfo &&FI) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102484.346384.patch
Type: text/x-patch
Size: 1146 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210519/a469e06b/attachment.bin>
More information about the llvm-commits
mailing list