[PATCH] D80672: [MLIR] Add support for resolving symbols to in-process functions for ExecutionEngine.

Tim Shen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 27 16:23:24 PDT 2020


timshen created this revision.
timshen added a reviewer: ftynse.
Herald added subscribers: llvm-commits, jurahul, Kayjukh, frgossen, grosul1, Joonsoo, stephenneuendorffer, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, jpienaar, rriddle, mehdi_amini, sanjoy.google, bixia.
Herald added a project: LLVM.

This comes in handy for calling into C/C++ implementations defined by the caller of the jit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80672

Files:
  mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
  mlir/lib/ExecutionEngine/ExecutionEngine.cpp


Index: mlir/lib/ExecutionEngine/ExecutionEngine.cpp
===================================================================
--- mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -335,6 +335,12 @@
   return fptr;
 }
 
+llvm::Error ExecutionEngine::addInProcessSymbol(StringRef name, void *address) {
+  return jit->getMainJITDylib().define(llvm::orc::absoluteSymbols(
+      {{jit->getExecutionSession().intern(name),
+        llvm::JITEvaluatedSymbol::fromPointer(address)}}));
+}
+
 Error ExecutionEngine::invoke(StringRef name, MutableArrayRef<void *> args) {
   auto expectedFPtr = lookup(name);
   if (!expectedFPtr)
Index: mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
===================================================================
--- mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
+++ mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
@@ -94,6 +94,9 @@
   /// pointer to it.  Propagates errors in case of failure.
   llvm::Expected<void (*)(void **)> lookup(StringRef name) const;
 
+  /// Maps a symbol to an in-process address.
+  llvm::Error addInProcessSymbol(StringRef name, void *address);
+
   /// Invokes the function with the given name passing it the list of arguments
   /// as a list of opaque pointers.
   llvm::Error invoke(StringRef name, MutableArrayRef<void *> args = llvm::None);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80672.266690.patch
Type: text/x-patch
Size: 1366 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200527/c45c860f/attachment.bin>


More information about the llvm-commits mailing list