[llvm] r371844 - [Orc] Roll back ThreadPool to std::function
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 13 04:59:52 PDT 2019
Author: d0k
Date: Fri Sep 13 04:59:51 2019
New Revision: 371844
URL: http://llvm.org/viewvc/llvm-project?rev=371844&view=rev
Log:
[Orc] Roll back ThreadPool to std::function
MSVC doesn't allow move-only types in std::packaged_task. Boo.
Modified:
llvm/trunk/examples/SpeculativeJIT/SpeculativeJIT.cpp
llvm/trunk/include/llvm/Support/ThreadPool.h
llvm/trunk/lib/ExecutionEngine/Orc/LLJIT.cpp
Modified: llvm/trunk/examples/SpeculativeJIT/SpeculativeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/SpeculativeJIT/SpeculativeJIT.cpp?rev=371844&r1=371843&r2=371844&view=diff
==============================================================================
--- llvm/trunk/examples/SpeculativeJIT/SpeculativeJIT.cpp (original)
+++ llvm/trunk/examples/SpeculativeJIT/SpeculativeJIT.cpp Fri Sep 13 04:59:51 2019
@@ -114,7 +114,9 @@ private:
this->ES->setDispatchMaterialization(
[this](JITDylib &JD, std::unique_ptr<MaterializationUnit> 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<MaterializationUnit>(std::move(MU));
+ auto Work = [SharedMU, &JD]() { SharedMU->doMaterialize(JD); };
CompileThreads.async(std::move(Work));
});
ExitOnErr(S.addSpeculationRuntime(this->ES->getMainJITDylib(), Mangle));
Modified: llvm/trunk/include/llvm/Support/ThreadPool.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ThreadPool.h?rev=371844&r1=371843&r2=371844&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ThreadPool.h (original)
+++ llvm/trunk/include/llvm/Support/ThreadPool.h Fri Sep 13 04:59:51 2019
@@ -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<void()>;
+ using TaskTy = std::function<void()>;
using PackagedTaskTy = std::packaged_task<void()>;
/// Construct a pool with the number of threads found by
Modified: llvm/trunk/lib/ExecutionEngine/Orc/LLJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/LLJIT.cpp?rev=371844&r1=371843&r2=371844&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/LLJIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/LLJIT.cpp Fri Sep 13 04:59:51 2019
@@ -132,7 +132,9 @@ LLJIT::LLJIT(LLJITBuilderState &S, Error
CompileThreads = std::make_unique<ThreadPool>(S.NumCompileThreads);
ES->setDispatchMaterialization(
[this](JITDylib &JD, std::unique_ptr<MaterializationUnit> 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<MaterializationUnit>(std::move(MU));
+ auto Work = [SharedMU, &JD]() { SharedMU->doMaterialize(JD); };
CompileThreads->async(std::move(Work));
});
}
More information about the llvm-commits
mailing list