[ORC] Generalize the ORC RPC utils to support RPC function return values and
asynchronous call/handle. Also updates the ORC remote JIT API to use the new
scheme.
The previous version of the RPC tools only supported void functions, and
required the user to manually call a paired function to return results. This
patch replaces the Procedure typedef (which only supported void functions) with
the Function typedef which supports return values, e.g.:
Function<FooId, int32_t(std::string)> Foo;
The RPC primitives and channel operations are also expanded. RPC channels must
support four new operations: startSendMessage, endSendMessage,
startRecieveMessage and endRecieveMessage, to handle channel locking. In
addition, serialization support for tuples to RPCChannels is added to enable
multiple return values.
The RPC primitives are expanded from callAppend, call, expect and handle, to:
appendCallAsync - Make an asynchronous call to the given function.
callAsync - The same as appendCallAsync, but calls send on the channel when
done.
callSTHandling - Blocking call for single-threaded code. Wraps a call to
callAsync then waits on the result, using a user-supplied
handler to handle any callbacks from the remote.
callST - The same as callSTHandling, except that it doesn't handle
callbacks - it expects the result to be the first return.
expect and handle - as before.
handleResponse - Handle a response from the remote.
waitForResult - Wait for the response with the given sequence number to arrive.
llvm-svn: 266581
diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index 0f30a4a..ce99b6a 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -582,7 +582,7 @@
// Reset errno to zero on entry to main.
errno = 0;
- int Result;
+ int Result = -1;
// Sanity check use of remote-jit: LLI currently only supports use of the
// remote JIT on Unix platforms.
@@ -681,12 +681,13 @@
static_cast<ForwardingMemoryManager*>(RTDyldMM)->setResolver(
orc::createLambdaResolver(
[&](const std::string &Name) {
- orc::TargetAddress Addr = 0;
- if (auto EC = R->getSymbolAddress(Addr, Name)) {
- errs() << "Failure during symbol lookup: " << EC.message() << "\n";
- exit(1);
- }
- return RuntimeDyld::SymbolInfo(Addr, JITSymbolFlags::Exported);
+ if (auto AddrOrErr = R->getSymbolAddress(Name))
+ return RuntimeDyld::SymbolInfo(*AddrOrErr, JITSymbolFlags::Exported);
+ else {
+ errs() << "Failure during symbol lookup: "
+ << AddrOrErr.getError().message() << "\n";
+ exit(1);
+ }
},
[](const std::string &Name) { return nullptr; }
));
@@ -698,8 +699,10 @@
EE->finalizeObject();
DEBUG(dbgs() << "Executing '" << EntryFn->getName() << "' at 0x"
<< format("%llx", Entry) << "\n");
- if (auto EC = R->callIntVoid(Result, Entry))
- errs() << "ERROR: " << EC.message() << "\n";
+ if (auto ResultOrErr = R->callIntVoid(Entry))
+ Result = *ResultOrErr;
+ else
+ errs() << "ERROR: " << ResultOrErr.getError().message() << "\n";
// Like static constructors, the remote target MCJIT support doesn't handle
// this yet. It could. FIXME.