From: Benjamin Kramer Date: Fri, 13 Sep 2019 11:59:51 +0000 (+0000) Subject: [Orc] Roll back ThreadPool to std::function X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e8e4b1ed555179b68603656c3ae46e098d55e13b;p=llvm [Orc] Roll back ThreadPool to std::function MSVC doesn't allow move-only types in std::packaged_task. Boo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371844 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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)); }); }