Skip to content

Commit 689486d

Browse files
committed
[examples] Fix the SpeculativeJIT and ThinLtoJIT examples for 41379f1.
1 parent c564799 commit 689486d

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,15 @@ class SpeculativeJIT {
112112
MainJD.addGenerator(std::move(ProcessSymbolsGenerator));
113113
this->CODLayer.setImplMap(&Imps);
114114
this->ES->setDispatchMaterialization(
115-
116-
[this](JITDylib &JD, std::unique_ptr<MaterializationUnit> MU) {
115+
[this](std::unique_ptr<MaterializationUnit> MU,
116+
MaterializationResponsibility MR) {
117117
// FIXME: Switch to move capture once we have C++14.
118118
auto SharedMU = std::shared_ptr<MaterializationUnit>(std::move(MU));
119-
auto Work = [SharedMU, &JD]() { SharedMU->doMaterialize(JD); };
120-
CompileThreads.async(std::move(Work));
119+
auto SharedMR =
120+
std::make_shared<MaterializationResponsibility>(std::move(MR));
121+
CompileThreads.async([SharedMU, SharedMR]() {
122+
SharedMU->materialize(std::move(*SharedMR));
123+
});
121124
});
122125
ExitOnErr(S.addSpeculationRuntime(MainJD, Mangle));
123126
LocalCXXRuntimeOverrides CXXRuntimeoverrides;

llvm/examples/ThinLtoJIT/ThinLtoJIT.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,21 @@ void ThinLtoJIT::setupLayers(JITTargetMachineBuilder JTMB,
266266
CompileThreads = std::make_unique<ThreadPool>(
267267
llvm::hardware_concurrency(NumCompileThreads));
268268
ES.setDispatchMaterialization(
269-
[this](JITDylib &JD, std::unique_ptr<MaterializationUnit> MU) {
269+
[this](std::unique_ptr<MaterializationUnit> MU,
270+
MaterializationResponsibility MR) {
270271
if (IsTrivialModule(MU.get())) {
271272
// This should be quick and we may save a few session locks.
272-
MU->doMaterialize(JD);
273+
MU->materialize(std::move(MR));
273274
} else {
274275
// FIXME: Drop the std::shared_ptr workaround once ThreadPool::async()
275276
// accepts llvm::unique_function to define jobs.
276277
auto SharedMU = std::shared_ptr<MaterializationUnit>(std::move(MU));
278+
auto SharedMR =
279+
std::make_shared<MaterializationResponsibility>(std::move(MR));
277280
CompileThreads->async(
278-
[MU = std::move(SharedMU), &JD]() { MU->doMaterialize(JD); });
281+
[MU = std::move(SharedMU), MR = std::move(SharedMR)]() {
282+
MU->materialize(std::move(*MR));
283+
});
279284
}
280285
});
281286

0 commit comments

Comments
 (0)