From 99cfb3923c6d18c0b1046436bff4c8fe6376f343 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 13 Sep 2019 11:59:51 +0000 Subject: [PATCH] [Orc] Roll back ThreadPool to std::function MSVC doesn't allow move-only types in std::packaged_task. Boo. llvm-svn: 371844 --- examples/SpeculativeJIT/SpeculativeJIT.cpp | 4 +++- include/llvm/Support/ThreadPool.h | 3 +-- lib/ExecutionEngine/Orc/LLJIT.cpp | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/SpeculativeJIT/SpeculativeJIT.cpp b/examples/SpeculativeJIT/SpeculativeJIT.cpp index 647413cc9c2..1fd1fc92a73 100644 --- a/examples/SpeculativeJIT/SpeculativeJIT.cpp +++ b/examples/SpeculativeJIT/SpeculativeJIT.cpp @@ -114,7 +114,9 @@ private: this->ES->setDispatchMaterialization( [this](JITDylib &JD, std::unique_ptr MU) { - auto Work = [MU = std::move(MU), &JD] { MU->doMaterialize(JD); }; + // FIXME: Switch to move capture once we have C++14. + auto SharedMU = std::shared_ptr(std::move(MU)); + auto Work = [SharedMU, &JD]() { SharedMU->doMaterialize(JD); }; CompileThreads.async(std::move(Work)); }); ExitOnErr(S.addSpeculationRuntime(this->ES->getMainJITDylib(), Mangle)); diff --git a/include/llvm/Support/ThreadPool.h b/include/llvm/Support/ThreadPool.h index 32f88124ee5..4bcbaa3142f 100644 --- a/include/llvm/Support/ThreadPool.h +++ b/include/llvm/Support/ThreadPool.h @@ -13,7 +13,6 @@ #ifndef LLVM_SUPPORT_THREAD_POOL_H #define LLVM_SUPPORT_THREAD_POOL_H -#include "llvm/ADT/FunctionExtras.h" #include "llvm/Config/llvm-config.h" #include "llvm/Support/thread.h" @@ -36,7 +35,7 @@ namespace llvm { /// for some work to become available. class ThreadPool { public: - using TaskTy = unique_function; + using TaskTy = std::function; using PackagedTaskTy = std::packaged_task; /// Construct a pool with the number of threads found by diff --git a/lib/ExecutionEngine/Orc/LLJIT.cpp b/lib/ExecutionEngine/Orc/LLJIT.cpp index c6532c60fb8..a80f78afe80 100644 --- a/lib/ExecutionEngine/Orc/LLJIT.cpp +++ b/lib/ExecutionEngine/Orc/LLJIT.cpp @@ -132,7 +132,9 @@ LLJIT::LLJIT(LLJITBuilderState &S, Error &Err) CompileThreads = std::make_unique(S.NumCompileThreads); ES->setDispatchMaterialization( [this](JITDylib &JD, std::unique_ptr MU) { - auto Work = [MU = std::move(MU), &JD] { MU->doMaterialize(JD); }; + // FIXME: Switch to move capture once we have c++14. + auto SharedMU = std::shared_ptr(std::move(MU)); + auto Work = [SharedMU, &JD]() { SharedMU->doMaterialize(JD); }; CompileThreads->async(std::move(Work)); }); }