[PATCH] D102486: Use a non-recursive mutex in GsymCreator.
Simon Giesecke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 14 05:18:42 PDT 2021
simon.giesecke created this revision.
simon.giesecke added a reviewer: clayborg.
simon.giesecke added a project: debug-info.
Herald added a subscriber: hiraditya.
simon.giesecke requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
There doesn't seem to be a need to support recursive locking,
and a recursive mutex is unnecessarily inefficient.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D102486
Files:
llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
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
@@ -35,7 +35,7 @@
const uint32_t Base = insertString(filename);
FileEntry FE(Dir, Base);
- std::lock_guard<std::recursive_mutex> Guard(Mutex);
+ std::lock_guard<std::mutex> Guard(Mutex);
const auto NextIndex = Files.size();
// Find FE in hash map and insert if not present.
auto R = FileEntryToIndex.insert(std::make_pair(FE, NextIndex));
@@ -55,7 +55,7 @@
}
llvm::Error GsymCreator::encode(FileWriter &O) const {
- std::lock_guard<std::recursive_mutex> Guard(Mutex);
+ std::lock_guard<std::mutex> Guard(Mutex);
if (Funcs.empty())
return createStringError(std::errc::invalid_argument,
"no functions to encode");
@@ -188,7 +188,7 @@
}
llvm::Error GsymCreator::finalize(llvm::raw_ostream &OS) {
- std::lock_guard<std::recursive_mutex> Guard(Mutex);
+ std::lock_guard<std::mutex> Guard(Mutex);
if (Finalized)
return createStringError(std::errc::invalid_argument, "already finalized");
Finalized = true;
@@ -293,7 +293,7 @@
uint32_t GsymCreator::insertString(StringRef S, bool Copy) {
if (S.empty())
return 0;
- std::lock_guard<std::recursive_mutex> Guard(Mutex);
+ std::lock_guard<std::mutex> Guard(Mutex);
CachedHashStringRef CHStr(S);
if (Copy) {
// We need to provide backing storage for the string if requested
@@ -310,14 +310,14 @@
}
void GsymCreator::addFunctionInfo(FunctionInfo &&FI) {
- std::lock_guard<std::recursive_mutex> Guard(Mutex);
+ std::lock_guard<std::mutex> Guard(Mutex);
Ranges.insert(FI.Range);
Funcs.emplace_back(std::move(FI));
}
void GsymCreator::forEachFunctionInfo(
std::function<bool(FunctionInfo &)> const &Callback) {
- std::lock_guard<std::recursive_mutex> Guard(Mutex);
+ std::lock_guard<std::mutex> Guard(Mutex);
for (auto &FI : Funcs) {
if (!Callback(FI))
break;
@@ -326,7 +326,7 @@
void GsymCreator::forEachFunctionInfo(
std::function<bool(const FunctionInfo &)> const &Callback) const {
- std::lock_guard<std::recursive_mutex> Guard(Mutex);
+ std::lock_guard<std::mutex> Guard(Mutex);
for (const auto &FI : Funcs) {
if (!Callback(FI))
break;
@@ -334,7 +334,7 @@
}
size_t GsymCreator::getNumFunctionInfos() const {
- std::lock_guard<std::recursive_mutex> Guard(Mutex);
+ std::lock_guard<std::mutex> Guard(Mutex);
return Funcs.size();
}
@@ -345,6 +345,6 @@
}
bool GsymCreator::hasFunctionInfoForAddress(uint64_t Addr) const {
- std::lock_guard<std::recursive_mutex> Guard(Mutex);
+ std::lock_guard<std::mutex> Guard(Mutex);
return Ranges.contains(Addr);
}
Index: llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
===================================================================
--- llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
+++ llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
@@ -133,7 +133,7 @@
/// of FunctionInfo objects, see "llvm/DebugInfo/GSYM/FunctionInfo.h".
class GsymCreator {
// Private member variables require Mutex protections
- mutable std::recursive_mutex Mutex;
+ mutable std::mutex Mutex;
std::vector<FunctionInfo> Funcs;
StringTableBuilder StrTab;
StringSet<> StringStorage;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102486.345406.patch
Type: text/x-patch
Size: 3335 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210514/45399bab/attachment.bin>
More information about the llvm-commits
mailing list