[llvm] 689486d - [examples] Fix the SpeculativeJIT and ThinLtoJIT examples for 41379f1ec46.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sun May 10 17:34:54 PDT 2020


Author: Lang Hames
Date: 2020-05-10T17:34:31-07:00
New Revision: 689486dc2a8acb8fdcdf1b8396162c104cdca307

URL: https://github.com/llvm/llvm-project/commit/689486dc2a8acb8fdcdf1b8396162c104cdca307
DIFF: https://github.com/llvm/llvm-project/commit/689486dc2a8acb8fdcdf1b8396162c104cdca307.diff

LOG: [examples] Fix the SpeculativeJIT and ThinLtoJIT examples for 41379f1ec46.

Added: 
    

Modified: 
    llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp
    llvm/examples/ThinLtoJIT/ThinLtoJIT.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp b/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp
index c12dcd50dcac..4de4897053c1 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<MaterializationUnit> MU) {
+        [this](std::unique_ptr<MaterializationUnit> MU,
+               MaterializationResponsibility MR) {
           // 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));
+          auto SharedMR =
+            std::make_shared<MaterializationResponsibility>(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 6bd8f6144db1..f5c2b0696f55 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<ThreadPool>(
       llvm::hardware_concurrency(NumCompileThreads));
   ES.setDispatchMaterialization(
-      [this](JITDylib &JD, std::unique_ptr<MaterializationUnit> MU) {
+      [this](std::unique_ptr<MaterializationUnit> 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<MaterializationUnit>(std::move(MU));
+          auto SharedMR =
+            std::make_shared<MaterializationResponsibility>(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));
+              });
         }
       });
 


        


More information about the llvm-commits mailing list