summaryrefslogtreecommitdiffstats
path: root/llvm/examples/Kaleidoscope
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
commit9e68b734d6d0a98c672aebbe64956476cc140008 (patch)
tree01d390bb328b5d38d058d71d15f96f19ea871285 /llvm/examples/Kaleidoscope
parent783d433f169c5c5a0136c26d951796657f67d971 (diff)
downloadbcm5719-llvm-9e68b734d6d0a98c672aebbe64956476cc140008.tar.gz
bcm5719-llvm-9e68b734d6d0a98c672aebbe64956476cc140008.zip
[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. llvm-svn: 312500
Diffstat (limited to 'llvm/examples/Kaleidoscope')
-rw-r--r--llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h18
-rw-r--r--llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp2
2 files changed, 4 insertions, 16 deletions
diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
index d3183140d23..8990a67feb7 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
+++ b/llvm/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/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp
index 7bbc06a0958..10b60bd12d1 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp
+++ b/llvm/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'.
OpenPOWER on IntegriCloud