diff --git a/examples/SpeculativeJIT/SpeculativeJIT.cpp b/examples/SpeculativeJIT/SpeculativeJIT.cpp index c12dcd50dca..4de4897053c 100644 --- a/examples/SpeculativeJIT/SpeculativeJIT.cpp +++ b/examples/SpeculativeJIT/SpeculativeJIT.cpp @@ -112,12 +112,15 @@ private: MainJD.addGenerator(std::move(ProcessSymbolsGenerator)); this->CODLayer.setImplMap(&Imps); this->ES->setDispatchMaterialization( - - [this](JITDylib &JD, std::unique_ptr MU) { + [this](std::unique_ptr MU, + MaterializationResponsibility MR) { // 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)); + auto SharedMR = + std::make_shared(std::move(MR)); + CompileThreads.async([SharedMU, SharedMR]() { + SharedMU->materialize(std::move(*SharedMR)); + }); }); ExitOnErr(S.addSpeculationRuntime(MainJD, Mangle)); LocalCXXRuntimeOverrides CXXRuntimeoverrides; diff --git a/examples/ThinLtoJIT/ThinLtoJIT.cpp b/examples/ThinLtoJIT/ThinLtoJIT.cpp index 6bd8f6144db..f5c2b0696f5 100644 --- a/examples/ThinLtoJIT/ThinLtoJIT.cpp +++ b/examples/ThinLtoJIT/ThinLtoJIT.cpp @@ -266,16 +266,21 @@ void ThinLtoJIT::setupLayers(JITTargetMachineBuilder JTMB, CompileThreads = std::make_unique( llvm::hardware_concurrency(NumCompileThreads)); ES.setDispatchMaterialization( - [this](JITDylib &JD, std::unique_ptr MU) { + [this](std::unique_ptr MU, + MaterializationResponsibility MR) { if (IsTrivialModule(MU.get())) { // This should be quick and we may save a few session locks. - MU->doMaterialize(JD); + MU->materialize(std::move(MR)); } else { // FIXME: Drop the std::shared_ptr workaround once ThreadPool::async() // accepts llvm::unique_function to define jobs. auto SharedMU = std::shared_ptr(std::move(MU)); + auto SharedMR = + std::make_shared(std::move(MR)); CompileThreads->async( - [MU = std::move(SharedMU), &JD]() { MU->doMaterialize(JD); }); + [MU = std::move(SharedMU), MR = std::move(SharedMR)]() { + MU->materialize(std::move(*MR)); + }); } });