[Mlir-commits] [mlir] 6d60d86 - [mlir] Use LLJIT::getMainJITDylib instead of hardcoding '<main>'

River Riddle llvmlistbot at llvm.org
Thu Feb 20 14:19:43 PST 2020


Author: River Riddle
Date: 2020-02-20T14:19:34-08:00
New Revision: 6d60d8695d2066c9ef9360603c88ce938ca65491

URL: https://github.com/llvm/llvm-project/commit/6d60d8695d2066c9ef9360603c88ce938ca65491
DIFF: https://github.com/llvm/llvm-project/commit/6d60d8695d2066c9ef9360603c88ce938ca65491.diff

LOG: [mlir] Use LLJIT::getMainJITDylib instead of hardcoding '<main>'

This fixes test failures caused by a change to the name of the main
dylib, now called 'main'. It also hardens the engine against potential
future changes to the name.

Added: 
    

Modified: 
    mlir/lib/ExecutionEngine/ExecutionEngine.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
index bfe99540e47b..eda4cd187adb 100644
--- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -216,6 +216,7 @@ Expected<std::unique_ptr<ExecutionEngine>> ExecutionEngine::create(
   if (!expectedModule)
     return expectedModule.takeError();
   std::unique_ptr<Module> deserModule = std::move(*expectedModule);
+  auto dataLayout = deserModule->getDataLayout();
 
   // Callback to create the object layer with symbol resolution to current
   // process and dynamically linked libraries.
@@ -231,15 +232,6 @@ Expected<std::unique_ptr<ExecutionEngine>> ExecutionEngine::create(
               reinterpret_cast<uintptr_t>(object.getData().data()));
           engine->gdbListener->notifyObjectLoaded(key, object, objectInfo);
         });
-    auto dataLayout = deserModule->getDataLayout();
-    llvm::orc::JITDylib *mainJD = session.getJITDylibByName("<main>");
-    if (!mainJD)
-      mainJD = &session.createBareJITDylib("<main>");
-
-    // Resolve symbols that are statically linked in the current process.
-    mainJD->addGenerator(
-        cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess(
-            dataLayout.getGlobalPrefix())));
 
     // Resolve symbols from shared libraries.
     for (auto libPath : sharedLibPaths) {
@@ -291,6 +283,12 @@ Expected<std::unique_ptr<ExecutionEngine>> ExecutionEngine::create(
   cantFail(jit->addIRModule(std::move(tsm)));
   engine->jit = std::move(jit);
 
+  // Resolve symbols that are statically linked in the current process.
+  llvm::orc::JITDylib &mainJD = engine->jit->getMainJITDylib();
+  mainJD.addGenerator(
+      cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess(
+          dataLayout.getGlobalPrefix())));
+
   return std::move(engine);
 }
 


        


More information about the Mlir-commits mailing list