[PATCH] D153318: [llvm] Refactor BalancedPartitioning for fixing build failure with MSVC

kamlesh kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 22:44:14 PDT 2023


kamleshbhalui created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
kamleshbhalui requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Fix build failure on windows system with msvc toolchain


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153318

Files:
  llvm/include/llvm/Support/BalancedPartitioning.h
  llvm/lib/Support/BalancedPartitioning.cpp


Index: llvm/lib/Support/BalancedPartitioning.cpp
===================================================================
--- llvm/lib/Support/BalancedPartitioning.cpp
+++ llvm/lib/Support/BalancedPartitioning.cpp
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Support/BalancedPartitioning.h"
+#include "llvm/Support/ThreadPool.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Format.h"
@@ -80,10 +81,11 @@
       dbgs() << format(
           "Partitioning %d nodes using depth %d and %d iterations per split\n",
           Nodes.size(), Config.SplitDepth, Config.IterationsPerSplit));
+  ThreadPool TheThreadPool;
   std::optional<BPThreadPool> TP;
 #if LLVM_ENABLE_THREADS
   if (Config.TaskSplitDepth > 1)
-    TP.emplace();
+    TP.emplace(TheThreadPool);
 #endif
 
   // Record the input order
Index: llvm/include/llvm/Support/BalancedPartitioning.h
===================================================================
--- llvm/include/llvm/Support/BalancedPartitioning.h
+++ llvm/include/llvm/Support/BalancedPartitioning.h
@@ -39,14 +39,18 @@
 #ifndef LLVM_SUPPORT_BALANCED_PARTITIONING_H
 #define LLVM_SUPPORT_BALANCED_PARTITIONING_H
 
+#include "llvm/ADT/ArrayRef.h"
 #include "raw_ostream.h"
-#include "llvm/Support/ThreadPool.h"
 
+#include <mutex>
+#include <condition_variable>
+#include <atomic>
 #include <random>
 #include <vector>
 
 namespace llvm {
 
+class ThreadPool;
 /// A function with a set of utility nodes where it is beneficial to order two
 /// functions close together if they have similar utility nodes
 class BPFunctionNode {
@@ -111,7 +115,7 @@
   /// threads, so we need to track how many active threads that could spawn more
   /// threads.
   struct BPThreadPool {
-    ThreadPool TheThreadPool;
+    ThreadPool &TheThreadPool;
     std::mutex mtx;
     std::condition_variable cv;
     /// The number of threads that could spawn more threads
@@ -124,6 +128,7 @@
     /// acceptable for other threads to add more tasks while blocking on this
     /// call.
     void wait();
+    BPThreadPool(ThreadPool &TheThreadPool) : TheThreadPool(TheThreadPool) {}
   };
 
   /// Run a recursive bisection of a given list of FunctionNodes


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153318.532792.patch
Type: text/x-patch
Size: 2273 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230620/c58fe0b0/attachment.bin>


More information about the llvm-commits mailing list