Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 30e9aa6

Browse files
committed
[ORC] Refactor OrcRemoteTarget code to expose its RPC API, reduce
code duplication in the client, and improve error propagation. This patch moves the OrcRemoteTarget rpc::Function declarations from OrcRemoteTargetRPCAPI into their own namespaces under llvm::orc::remote so that they can be used in new contexts (in particular, a remote-object-file adapter layer that I will commit shortly). Code duplication in OrcRemoteTargetClient (especially in loops processing the code, rw-data and ro-data allocations) is removed by moving the loop bodies into their own functions. Error propagation is (slightly) improved by adding an ErrorReporter functor to the OrcRemoteTargetClient -- Errors that can't be returned (because they occur in destructors, or behind stable APIs that don't provide error returns) can be sent to the ErrorReporter instead. Some methods in the Client API are also changed to make better use of the Expected class: returning Expected<T>s rather than returning Errors and taking T&s to store the results. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312500 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 8bafe87 commit 30e9aa6

File tree

6 files changed

+349
-411
lines changed

6 files changed

+349
-411
lines changed

examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h

+3-15
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace llvm {
7272
namespace orc {
7373

7474
// Typedef the remote-client API.
75-
using MyRemote = remote::OrcRemoteTargetClient<FDRPCChannel>;
75+
using MyRemote = remote::OrcRemoteTargetClient;
7676

7777
class KaleidoscopeJIT {
7878
private:
@@ -98,13 +98,7 @@ class KaleidoscopeJIT {
9898
"", SmallVector<std::string, 0>())),
9999
DL(TM->createDataLayout()),
100100
ObjectLayer([&Remote]() {
101-
std::unique_ptr<MyRemote::RCMemoryManager> MemMgr;
102-
if (auto Err = Remote.createRemoteMemoryManager(MemMgr)) {
103-
logAllUnhandledErrors(std::move(Err), errs(),
104-
"Error creating remote memory manager:");
105-
exit(1);
106-
}
107-
return MemMgr;
101+
return cantFail(Remote.createRemoteMemoryManager());
108102
}),
109103
CompileLayer(ObjectLayer, SimpleCompiler(*TM)),
110104
OptimizeLayer(CompileLayer,
@@ -119,13 +113,7 @@ class KaleidoscopeJIT {
119113
exit(1);
120114
}
121115
CompileCallbackMgr = &*CCMgrOrErr;
122-
std::unique_ptr<MyRemote::RCIndirectStubsManager> ISM;
123-
if (auto Err = Remote.createIndirectStubsManager(ISM)) {
124-
logAllUnhandledErrors(std::move(Err), errs(),
125-
"Error creating indirect stubs manager:");
126-
exit(1);
127-
}
128-
IndirectStubsMgr = std::move(ISM);
116+
IndirectStubsMgr = cantFail(Remote.createIndirectStubsManager());
129117
llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);
130118
}
131119

examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ int main(int argc, char *argv[]) {
12771277
BinopPrecedence['*'] = 40; // highest.
12781278

12791279
auto TCPChannel = connect();
1280-
auto Remote = ExitOnErr(MyRemote::Create(*TCPChannel));
1280+
auto Remote = ExitOnErr(MyRemote::Create(*TCPChannel, ExitOnErr));
12811281
TheJIT = llvm::make_unique<KaleidoscopeJIT>(*Remote);
12821282

12831283
// Automatically inject a definition for 'printExprResult'.

0 commit comments

Comments
 (0)