[llvm] 8f0aa9d - Revert "Threading: Convert Optional to std::optional"

Daniel Thornburgh via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 1 15:43:48 PST 2022


Author: Daniel Thornburgh
Date: 2022-12-01T15:42:25-08:00
New Revision: 8f0aa9df11195ef435717b24401fe76be06cd69f

URL: https://github.com/llvm/llvm-project/commit/8f0aa9df11195ef435717b24401fe76be06cd69f
DIFF: https://github.com/llvm/llvm-project/commit/8f0aa9df11195ef435717b24401fe76be06cd69f.diff

LOG: Revert "Threading: Convert Optional to std::optional"

This reverts commit 5e50b8089aee249d77542ea858d956568ec6581f.

This commit breaks the build for BOLT:
  bolt/lib/Profile/DataAggregator.cpp:264:66: error: no viable
  conversion from 'Optional<StringRef>[3]' to
  'ArrayRef<std::optional<StringRef>>'

Added: 
    

Modified: 
    llvm/include/llvm/Support/Threading.h
    llvm/lib/Support/Threading.cpp
    llvm/lib/Support/Windows/Threading.inc

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/Threading.h b/llvm/include/llvm/Support/Threading.h
index ce8dbff510e8..f3f7c44bd439 100644
--- a/llvm/include/llvm/Support/Threading.h
+++ b/llvm/include/llvm/Support/Threading.h
@@ -19,7 +19,6 @@
 #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
 #include "llvm/Support/Compiler.h"
 #include <ciso646> // So we can check the C++ standard lib macros.
-#include <optional>
 
 #if defined(_MSC_VER)
 // MSVC's call_once implementation worked since VS 2015, which is the minimum
@@ -141,7 +140,7 @@ constexpr bool llvm_is_multithreaded() { return LLVM_ENABLE_THREADS; }
 
     /// Finds the CPU socket where a thread should go. Returns 'None' if the
     /// thread shall remain on the actual CPU socket.
-    std::optional<unsigned> compute_cpu_socket(unsigned ThreadPoolNum) const;
+    Optional<unsigned> compute_cpu_socket(unsigned ThreadPoolNum) const;
   };
 
   /// Build a strategy from a number of threads as a string provided in \p Num.
@@ -149,7 +148,7 @@ constexpr bool llvm_is_multithreaded() { return LLVM_ENABLE_THREADS; }
   /// strategy, we attempt to equally allocate the threads on all CPU sockets.
   /// "0" or an empty string will return the \p Default strategy.
   /// "all" for using all hardware threads.
-  std::optional<ThreadPoolStrategy>
+  Optional<ThreadPoolStrategy>
   get_threadpool_strategy(StringRef Num, ThreadPoolStrategy Default = {});
 
   /// Returns a thread strategy for tasks requiring significant memory or other
@@ -171,7 +170,7 @@ constexpr bool llvm_is_multithreaded() { return LLVM_ENABLE_THREADS; }
   /// If \p Num is invalid, returns a default strategy where one thread per
   /// hardware core is used.
   inline ThreadPoolStrategy heavyweight_hardware_concurrency(StringRef Num) {
-    std::optional<ThreadPoolStrategy> S =
+    Optional<ThreadPoolStrategy> S =
         get_threadpool_strategy(Num, heavyweight_hardware_concurrency());
     if (S)
       return *S;

diff  --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp
index 24962ae20919..910437cfb70a 100644
--- a/llvm/lib/Support/Threading.cpp
+++ b/llvm/lib/Support/Threading.cpp
@@ -90,7 +90,7 @@ const llvm::Optional<unsigned> llvm::thread::DefaultStackSize;
 
 #endif
 
-std::optional<ThreadPoolStrategy>
+Optional<ThreadPoolStrategy>
 llvm::get_threadpool_strategy(StringRef Num, ThreadPoolStrategy Default) {
   if (Num == "all")
     return llvm::hardware_concurrency();
@@ -98,7 +98,7 @@ llvm::get_threadpool_strategy(StringRef Num, ThreadPoolStrategy Default) {
     return Default;
   unsigned V;
   if (Num.getAsInteger(10, V))
-    return std::nullopt; // malformed 'Num' value
+    return None; // malformed 'Num' value
   if (V == 0)
     return Default;
 

diff  --git a/llvm/lib/Support/Windows/Threading.inc b/llvm/lib/Support/Windows/Threading.inc
index 3c012f12ea6e..03c055545259 100644
--- a/llvm/lib/Support/Windows/Threading.inc
+++ b/llvm/lib/Support/Windows/Threading.inc
@@ -248,7 +248,7 @@ static int computeHostNumHardwareThreads() {
 
 // Finds the proper CPU socket where a thread number should go. Returns 'None'
 // if the thread shall remain on the actual CPU socket.
-std::optional<unsigned>
+Optional<unsigned>
 llvm::ThreadPoolStrategy::compute_cpu_socket(unsigned ThreadPoolNum) const {
   ArrayRef<ProcessorGroup> Groups = getProcessorGroups();
   // Only one CPU socket in the system or process affinity was set, no need to
@@ -273,7 +273,7 @@ llvm::ThreadPoolStrategy::compute_cpu_socket(unsigned ThreadPoolNum) const {
 // Assign the current thread to a more appropriate CPU socket or CPU group
 void llvm::ThreadPoolStrategy::apply_thread_strategy(
     unsigned ThreadPoolNum) const {
-  std::optional<unsigned> Socket = compute_cpu_socket(ThreadPoolNum);
+  Optional<unsigned> Socket = compute_cpu_socket(ThreadPoolNum);
   if (!Socket)
     return;
   ArrayRef<ProcessorGroup> Groups = getProcessorGroups();


        


More information about the llvm-commits mailing list