summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2017-09-04 20:54:46 +0000
committerLang Hames <lhames@gmail.com>2017-09-04 20:54:46 +0000
commit30e9aa60fea44210ac8d843d2f6a4b3bd2578bf4 (patch)
tree2117579d8840b2c316d604667b83a722eb651727 /examples
parent8bafe87c16ed8adea36bbd348243ad82112c6f9c (diff)
[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
Diffstat (limited to 'examples')
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h18
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp2
2 files changed, 4 insertions, 16 deletions
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
index d3183140d23..8990a67feb7 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
@@ -72,7 +72,7 @@ namespace llvm {
namespace orc {
// Typedef the remote-client API.
-using MyRemote = remote::OrcRemoteTargetClient<FDRPCChannel>;
+using MyRemote = remote::OrcRemoteTargetClient;
class KaleidoscopeJIT {
private:
@@ -98,13 +98,7 @@ public:
"", SmallVector<std::string, 0>())),
DL(TM->createDataLayout()),
ObjectLayer([&Remote]() {
- std::unique_ptr<MyRemote::RCMemoryManager> MemMgr;
- if (auto Err = Remote.createRemoteMemoryManager(MemMgr)) {
- logAllUnhandledErrors(std::move(Err), errs(),
- "Error creating remote memory manager:");
- exit(1);
- }
- return MemMgr;
+ return cantFail(Remote.createRemoteMemoryManager());
}),
CompileLayer(ObjectLayer, SimpleCompiler(*TM)),
OptimizeLayer(CompileLayer,
@@ -119,13 +113,7 @@ public:
exit(1);
}
CompileCallbackMgr = &*CCMgrOrErr;
- std::unique_ptr<MyRemote::RCIndirectStubsManager> ISM;
- if (auto Err = Remote.createIndirectStubsManager(ISM)) {
- logAllUnhandledErrors(std::move(Err), errs(),
- "Error creating indirect stubs manager:");
- exit(1);
- }
- IndirectStubsMgr = std::move(ISM);
+ IndirectStubsMgr = cantFail(Remote.createIndirectStubsManager());
llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);
}
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp b/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp
index 7bbc06a0958..10b60bd12d1 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp
@@ -1277,7 +1277,7 @@ int main(int argc, char *argv[]) {
BinopPrecedence['*'] = 40; // highest.
auto TCPChannel = connect();
- auto Remote = ExitOnErr(MyRemote::Create(*TCPChannel));
+ auto Remote = ExitOnErr(MyRemote::Create(*TCPChannel, ExitOnErr));
TheJIT = llvm::make_unique<KaleidoscopeJIT>(*Remote);
// Automatically inject a definition for 'printExprResult'.