[Orc] Refactor the CompileOnDemandLayer to make its addModuleSet method
[oota-llvm.git] / tools / lli / OrcLazyJIT.h
index 3f89f6a5168d06e963e2af1e2191f907aa444641..2b2db6e668cc60de448a19c79b787424d050b8e6 100644 (file)
@@ -92,25 +92,28 @@ public:
     //   1) Search the JIT symbols.
     //   2) Check for C++ runtime overrides.
     //   3) Search the host process (LLI)'s symbol table.
     //   1) Search the JIT symbols.
     //   2) Check for C++ runtime overrides.
     //   3) Search the host process (LLI)'s symbol table.
-    auto FallbackLookup =
-      [this](const std::string &Name) {
+    auto Resolver =
+      orc::createLambdaResolver(
+        [this](const std::string &Name) {
 
 
-        if (auto Sym = CODLayer.findSymbol(Name, true))
-          return RuntimeDyld::SymbolInfo(Sym.getAddress(), Sym.getFlags());
+          if (auto Sym = CODLayer.findSymbol(Name, true))
+            return RuntimeDyld::SymbolInfo(Sym.getAddress(), Sym.getFlags());
 
 
-        if (auto Sym = CXXRuntimeOverrides.searchOverrides(Name))
-          return Sym;
+          if (auto Sym = CXXRuntimeOverrides.searchOverrides(Name))
+            return Sym;
 
 
-        if (auto Addr = RTDyldMemoryManager::getSymbolAddressInProcess(Name))
-          return RuntimeDyld::SymbolInfo(Addr, JITSymbolFlags::Exported);
+          if (auto Addr = RTDyldMemoryManager::getSymbolAddressInProcess(Name))
+            return RuntimeDyld::SymbolInfo(Addr, JITSymbolFlags::Exported);
 
 
-        return RuntimeDyld::SymbolInfo(nullptr);
-      };
+          return RuntimeDyld::SymbolInfo(nullptr);
+        },
+        [](const std::string &Name) { return RuntimeDyld::SymbolInfo(nullptr); }
+      );
 
     // Add the module to the JIT.
     std::vector<std::unique_ptr<Module>> S;
     S.push_back(std::move(M));
 
     // Add the module to the JIT.
     std::vector<std::unique_ptr<Module>> S;
     S.push_back(std::move(M));
-    auto H = CODLayer.addModuleSet(std::move(S), std::move(FallbackLookup));
+    auto H = CODLayer.addModuleSet(std::move(S), nullptr, std::move(Resolver));
 
     // Run the static constructors, and save the static destructor runner for
     // execution when the JIT is torn down.
 
     // Run the static constructors, and save the static destructor runner for
     // execution when the JIT is torn down.