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

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 22 10:57:43 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG53a7db4fdc6a: [llvm] Refactor BalancedPartitioning for fixing build failure with MSVC (authored by kamleshbhalui, committed by Kamlesh Kumar <kamlesh at localhost.localdomain>).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153318/new/

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
@@ -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 @@
           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
Index: llvm/include/llvm/Support/BalancedPartitioning.h
===================================================================
--- llvm/include/llvm/Support/BalancedPartitioning.h
+++ 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 @@
   /// 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.533700.patch
Type: text/x-patch
Size: 2065 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230622/7d1d1650/attachment.bin>


More information about the llvm-commits mailing list