From e3b557809604d036af6e00c60f012c2025b59a5e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 11 Feb 2023 13:38:04 +0100 Subject: Vendor import of llvm-project main llvmorg-16-init-18548-gb0daacf58f41, the last commit before the upstream release/17.x branch was created. --- llvm/lib/Support/Threading.cpp | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'llvm/lib/Support/Threading.cpp') diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp index 04a1a9e19428..923935bbca10 100644 --- a/llvm/lib/Support/Threading.cpp +++ b/llvm/lib/Support/Threading.cpp @@ -12,12 +12,12 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/Threading.h" -#include "llvm/ADT/Optional.h" #include "llvm/Config/config.h" -#include "llvm/Support/Host.h" +#include "llvm/Config/llvm-config.h" #include #include +#include #include #include @@ -28,14 +28,6 @@ using namespace llvm; //=== 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; } @@ -53,13 +45,16 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const { return 1; } +// Unknown if threading turned off +int llvm::get_physical_cores() { return -1; } + #else -int computeHostNumHardwareThreads(); +static int computeHostNumHardwareThreads(); unsigned llvm::ThreadPoolStrategy::compute_thread_count() const { - int MaxThreadCount = UseHyperThreads ? computeHostNumHardwareThreads() - : sys::getHostNumPhysicalCores(); + int MaxThreadCount = + UseHyperThreads ? computeHostNumHardwareThreads() : get_physical_cores(); if (MaxThreadCount <= 0) MaxThreadCount = 1; if (ThreadsRequested == 0) @@ -87,15 +82,15 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const { // which is not enough for some/many normal LLVM compilations. This implements // the same interface as std::thread but requests the same stack size as the // main thread (8MB) before creation. -const llvm::Optional llvm::thread::DefaultStackSize = 8 * 1024 * 1024; +const std::optional llvm::thread::DefaultStackSize = 8 * 1024 * 1024; #else -const llvm::Optional llvm::thread::DefaultStackSize = None; +const std::optional llvm::thread::DefaultStackSize; #endif #endif -Optional +std::optional llvm::get_threadpool_strategy(StringRef Num, ThreadPoolStrategy Default) { if (Num == "all") return llvm::hardware_concurrency(); @@ -103,7 +98,7 @@ llvm::get_threadpool_strategy(StringRef Num, ThreadPoolStrategy Default) { return Default; unsigned V; if (Num.getAsInteger(10, V)) - return None; // malformed 'Num' value + return std::nullopt; // malformed 'Num' value if (V == 0) return Default; -- cgit v1.2.3