diff --git a/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp b/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp index c12dcd50dcacd1..4de4897053c1b6 100644 --- a/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp +++ b/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp @@ -112,12 +112,15 @@ class SpeculativeJIT { 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/llvm/examples/ThinLtoJIT/ThinLtoJIT.cpp b/llvm/examples/ThinLtoJIT/ThinLtoJIT.cpp index 6bd8f6144db163..f5c2b0696f55cf 100644 --- a/llvm/examples/ThinLtoJIT/ThinLtoJIT.cpp +++ b/llvm/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)); + }); } });