diff --git a/llvm/include/llvm/Support/Mutex.h b/llvm/include/llvm/Support/Mutex.h --- a/llvm/include/llvm/Support/Mutex.h +++ b/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; } }; diff --git a/llvm/include/llvm/Support/Threading.h b/llvm/include/llvm/Support/Threading.h --- a/llvm/include/llvm/Support/Threading.h +++ b/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 diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp --- a/llvm/lib/Support/Threading.cpp +++ b/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; }