[llvm] 53a7db4 - [llvm] Refactor BalancedPartitioning for fixing build failure with MSVC

Kamlesh Kumar via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 22 10:57:42 PDT 2023


Author: Kamlesh Kumar
Date: 2023-06-22T23:25:17+05:30
New Revision: 53a7db4fdc6a6fc1bc7a8e134858202b661d7e5e

URL: https://github.com/llvm/llvm-project/commit/53a7db4fdc6a6fc1bc7a8e134858202b661d7e5e
DIFF: https://github.com/llvm/llvm-project/commit/53a7db4fdc6a6fc1bc7a8e134858202b661d7e5e.diff

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

Fix build failure on windows system with msvc toolchain

Reviewed By: ellis

Differential Revision: https://reviews.llvm.org/D153318

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/BalancedPartitioning.h b/llvm/include/llvm/Support/BalancedPartitioning.h
index 1677fb9e427d7..a8464ac0fe60e 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -40,13 +40,17 @@
 #define LLVM_SUPPORT_BALANCED_PARTITIONING_H
 
 #include "raw_ostream.h"
-#include "llvm/Support/ThreadPool.h"
+#include "llvm/ADT/ArrayRef.h"
 
+#include <atomic>
+#include <condition_variable>
+#include <mutex>
 #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 @@ class BalancedPartitioning {
   /// 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 @@ class BalancedPartitioning {
     /// 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

diff  --git a/llvm/lib/Support/BalancedPartitioning.cpp b/llvm/lib/Support/BalancedPartitioning.cpp
index e45852ee8db8f..113e9484f5283 100644
--- a/llvm/lib/Support/BalancedPartitioning.cpp
+++ b/llvm/lib/Support/BalancedPartitioning.cpp
@@ -16,6 +16,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/ThreadPool.h"
 
 using namespace llvm;
 #define DEBUG_TYPE "balanced-partitioning"
@@ -82,8 +83,9 @@ void BalancedPartitioning::run(std::vector<BPFunctionNode> &Nodes) const {
           Nodes.size(), Config.SplitDepth, Config.IterationsPerSplit));
   std::optional<BPThreadPool> TP;
 #if LLVM_ENABLE_THREADS
+  ThreadPool TheThreadPool;
   if (Config.TaskSplitDepth > 1)
-    TP.emplace();
+    TP.emplace(TheThreadPool);
 #endif
 
   // Record the input order


        


More information about the llvm-commits mailing list