summaryrefslogtreecommitdiffstats
path: root/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-05-30 01:57:45 +0000
committerLang Hames <lhames@gmail.com>2018-05-30 01:57:45 +0000
commitbd0cb787d05b555791a88640dcf9800bab54d4fa (patch)
tree54462834993763589d348390b6886b1fef1da6fe /llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp
parentb534510cd55dc979bf6eebd66140cda23ba1f163 (diff)
downloadbcm5719-llvm-bd0cb787d05b555791a88640dcf9800bab54d4fa.tar.gz
bcm5719-llvm-bd0cb787d05b555791a88640dcf9800bab54d4fa.zip
[ORC] Update JITCompileCallbackManager to support multi-threaded code.
Previously JITCompileCallbackManager only supported single threaded code. This patch embeds a VSO (see include/llvm/ExecutionEngine/Orc/Core.h) in the callback manager. The VSO ensures that the compile callback is only executed once and that the resulting address cached for use by subsequent re-entries. llvm-svn: 333490
Diffstat (limited to 'llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp')
-rw-r--r--llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp
index 10b60bd12d1..415cc751277 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp
+++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp
@@ -1243,7 +1243,9 @@ std::unique_ptr<FDRPCChannel> connect() {
sockaddr_in servAddr;
memset(&servAddr, 0, sizeof(servAddr));
servAddr.sin_family = PF_INET;
- memcpy(&servAddr.sin_addr.s_addr, server->h_addr, server->h_length);
+ char *src;
+ memcpy(&src, &server->h_addr, sizeof(char *));
+ memcpy(&servAddr.sin_addr.s_addr, src, server->h_length);
servAddr.sin_port = htons(Port);
if (connect(sockfd, reinterpret_cast<sockaddr*>(&servAddr),
sizeof(servAddr)) < 0) {
@@ -1276,9 +1278,10 @@ int main(int argc, char *argv[]) {
BinopPrecedence['-'] = 20;
BinopPrecedence['*'] = 40; // highest.
+ ExecutionSession ES;
auto TCPChannel = connect();
- auto Remote = ExitOnErr(MyRemote::Create(*TCPChannel, ExitOnErr));
- TheJIT = llvm::make_unique<KaleidoscopeJIT>(*Remote);
+ auto Remote = ExitOnErr(MyRemote::Create(*TCPChannel, ES));
+ TheJIT = llvm::make_unique<KaleidoscopeJIT>(ES, *Remote);
// Automatically inject a definition for 'printExprResult'.
FunctionProtos["printExprResult"] =
OpenPOWER on IntegriCloud