[PATCH] D131313: [Support] move llvm::llvm_is_multithread to header, NFC
Jun Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 7 17:50:35 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG98339ac7af30: [Support] move llvm::llvm_is_multithread to header, NFC (authored by junaire).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131313/new/
https://reviews.llvm.org/D131313
Files:
llvm/include/llvm/Support/Mutex.h
llvm/include/llvm/Support/Threading.h
llvm/lib/Support/Threading.cpp
Index: llvm/lib/Support/Threading.cpp
===================================================================
--- llvm/lib/Support/Threading.cpp
+++ llvm/lib/Support/Threading.cpp
@@ -28,14 +28,6 @@
//=== independent code.
//===----------------------------------------------------------------------===//
-bool llvm::llvm_is_multithreaded() {
-#if LLVM_ENABLE_THREADS != 0
- return true;
-#else
- return false;
-#endif
-}
-
#if LLVM_ENABLE_THREADS == 0 || \
(!defined(_WIN32) && !defined(HAVE_PTHREAD_H))
uint64_t llvm::get_threadid() { return 0; }
Index: llvm/include/llvm/Support/Threading.h
===================================================================
--- llvm/include/llvm/Support/Threading.h
+++ llvm/include/llvm/Support/Threading.h
@@ -50,7 +50,7 @@
/// Returns true if LLVM is compiled with support for multi-threading, and
/// false otherwise.
-bool llvm_is_multithreaded();
+constexpr bool llvm_is_multithreaded() { return LLVM_ENABLE_THREADS; }
#if LLVM_THREADING_USE_STD_CALL_ONCE
Index: llvm/include/llvm/Support/Mutex.h
===================================================================
--- llvm/include/llvm/Support/Mutex.h
+++ llvm/include/llvm/Support/Mutex.h
@@ -34,33 +34,31 @@
if (!mt_only || llvm_is_multithreaded()) {
impl.lock();
return true;
- } else {
- // Single-threaded debugging code. This would be racy in
- // multithreaded mode, but provides not basic checks in single
- // threaded mode.
- ++acquired;
- return true;
}
+ // Single-threaded debugging code. This would be racy in
+ // multithreaded mode, but provides not basic checks in single
+ // threaded mode.
+ ++acquired;
+ return true;
}
bool unlock() {
if (!mt_only || llvm_is_multithreaded()) {
impl.unlock();
return true;
- } else {
- // Single-threaded debugging code. This would be racy in
- // multithreaded mode, but provides not basic checks in single
- // threaded mode.
- assert(acquired && "Lock not acquired before release!");
- --acquired;
- return true;
}
+ // Single-threaded debugging code. This would be racy in
+ // multithreaded mode, but provides not basic checks in single
+ // threaded mode.
+ assert(acquired && "Lock not acquired before release!");
+ --acquired;
+ return true;
}
bool try_lock() {
if (!mt_only || llvm_is_multithreaded())
return impl.try_lock();
- else return true;
+ return true;
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131313.450679.patch
Type: text/x-patch
Size: 2751 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220808/c808b8ae/attachment.bin>
More information about the llvm-commits
mailing list