diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h b/llvm/include/llvm/Support/BalancedPartitioning.h --- 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 +#include +#include #include #include 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 diff --git a/llvm/lib/Support/BalancedPartitioning.cpp b/llvm/lib/Support/BalancedPartitioning.cpp --- 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 @@ Nodes.size(), Config.SplitDepth, Config.IterationsPerSplit)); std::optional TP; #if LLVM_ENABLE_THREADS + ThreadPool TheThreadPool; if (Config.TaskSplitDepth > 1) - TP.emplace(); + TP.emplace(TheThreadPool); #endif // Record the input order