summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2017-07-07 02:59:13 +0000
committerLang Hames <lhames@gmail.com>2017-07-07 02:59:13 +0000
commita81793582b3c47869680d354a97d59c55779c349 (patch)
tree8ed2414162602044dc62e2ec3a92ba70b84e9999 /examples
parentd0585d352f3269c2f8ccbcc44192c3ab3de4dbf5 (diff)
[ORC] Errorize the ORC APIs.
This patch updates the ORC layers and utilities to return and propagate llvm::Errors where appropriate. This is necessary to allow ORC to safely handle error cases in cross-process and remote JITing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307350 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'examples')
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h6
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp2
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h6
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter2/toy.cpp2
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h5
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp2
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h8
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp2
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h8
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp2
-rw-r--r--examples/Kaleidoscope/Chapter4/toy.cpp2
-rw-r--r--examples/Kaleidoscope/Chapter5/toy.cpp2
-rw-r--r--examples/Kaleidoscope/Chapter6/toy.cpp2
-rw-r--r--examples/Kaleidoscope/Chapter7/toy.cpp2
-rw-r--r--examples/Kaleidoscope/include/KaleidoscopeJIT.h6
15 files changed, 28 insertions, 29 deletions
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h
index 5ce8c9f152a..5a2148a14a1 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h
@@ -75,8 +75,8 @@ public:
// Add the set to the JIT with the resolver we created above and a newly
// created SectionMemoryManager.
- return CompileLayer.addModule(std::move(M),
- std::move(Resolver));
+ return cantFail(CompileLayer.addModule(std::move(M),
+ std::move(Resolver)));
}
JITSymbol findSymbol(const std::string Name) {
@@ -87,7 +87,7 @@ public:
}
void removeModule(ModuleHandle H) {
- CompileLayer.removeModule(H);
+ cantFail(CompileLayer.removeModule(H));
}
};
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp b/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp
index 163caa6872d..2471344c6d6 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp
@@ -1150,7 +1150,7 @@ static void HandleTopLevelExpression() {
// Get the symbol's address and cast it to the right type (takes no
// arguments, returns a double) so we can call it as a native function.
- double (*FP)() = (double (*)())(intptr_t)ExprSymbol.getAddress();
+ double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress());
fprintf(stderr, "Evaluated to %f\n", FP());
// Delete the anonymous expression module from the JIT.
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h
index e524c0e69b4..9a295f1566c 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h
@@ -88,8 +88,8 @@ public:
// Add the set to the JIT with the resolver we created above and a newly
// created SectionMemoryManager.
- return OptimizeLayer.addModule(std::move(M),
- std::move(Resolver));
+ return cantFail(OptimizeLayer.addModule(std::move(M),
+ std::move(Resolver)));
}
JITSymbol findSymbol(const std::string Name) {
@@ -100,7 +100,7 @@ public:
}
void removeModule(ModuleHandle H) {
- OptimizeLayer.removeModule(H);
+ cantFail(OptimizeLayer.removeModule(H));
}
private:
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter2/toy.cpp b/examples/Kaleidoscope/BuildingAJIT/Chapter2/toy.cpp
index 163caa6872d..2471344c6d6 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter2/toy.cpp
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter2/toy.cpp
@@ -1150,7 +1150,7 @@ static void HandleTopLevelExpression() {
// Get the symbol's address and cast it to the right type (takes no
// arguments, returns a double) so we can call it as a native function.
- double (*FP)() = (double (*)())(intptr_t)ExprSymbol.getAddress();
+ double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress());
fprintf(stderr, "Evaluated to %f\n", FP());
// Delete the anonymous expression module from the JIT.
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h
index d1a4b0b7248..a03f5ce5e23 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h
@@ -101,8 +101,7 @@ public:
// Add the set to the JIT with the resolver we created above and a newly
// created SectionMemoryManager.
- return CODLayer.addModule(std::move(M),
- std::move(Resolver));
+ return cantFail(CODLayer.addModule(std::move(M), std::move(Resolver)));
}
JITSymbol findSymbol(const std::string Name) {
@@ -113,7 +112,7 @@ public:
}
void removeModule(ModuleHandle H) {
- CODLayer.removeModule(H);
+ cantFail(CODLayer.removeModule(H));
}
private:
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp b/examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp
index 163caa6872d..2471344c6d6 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp
@@ -1150,7 +1150,7 @@ static void HandleTopLevelExpression() {
// Get the symbol's address and cast it to the right type (takes no
// arguments, returns a double) so we can call it as a native function.
- double (*FP)() = (double (*)())(intptr_t)ExprSymbol.getAddress();
+ double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress());
fprintf(stderr, "Evaluated to %f\n", FP());
// Delete the anonymous expression module from the JIT.
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
index c0d1b69ed59..d10e4748f1a 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
@@ -128,8 +128,8 @@ public:
// Add the set to the JIT with the resolver we created above and a newly
// created SectionMemoryManager.
- return OptimizeLayer.addModule(std::move(M),
- std::move(Resolver));
+ return cantFail(OptimizeLayer.addModule(std::move(M),
+ std::move(Resolver)));
}
Error addFunctionAST(std::unique_ptr<FunctionAST> FnAST) {
@@ -175,7 +175,7 @@ public:
addModule(std::move(M));
auto Sym = findSymbol(SharedFnAST->getName() + "$impl");
assert(Sym && "Couldn't find compiled function?");
- JITTargetAddress SymAddr = Sym.getAddress();
+ JITTargetAddress SymAddr = cantFail(Sym.getAddress());
if (auto Err =
IndirectStubsMgr->updatePointer(mangle(SharedFnAST->getName()),
SymAddr)) {
@@ -195,7 +195,7 @@ public:
}
void removeModule(ModuleHandle H) {
- OptimizeLayer.removeModule(H);
+ cantFail(OptimizeLayer.removeModule(H));
}
private:
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp b/examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp
index ff4b5220105..ed8ae31ba0f 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp
@@ -1153,7 +1153,7 @@ static void HandleTopLevelExpression() {
// Get the symbol's address and cast it to the right type (takes no
// arguments, returns a double) so we can call it as a native function.
- double (*FP)() = (double (*)())(intptr_t)ExprSymbol.getAddress();
+ double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress());
fprintf(stderr, "Evaluated to %f\n", FP());
// Delete the anonymous expression module from the JIT.
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
index 94057c2b101..7ea535b3af5 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
@@ -157,8 +157,8 @@ public:
// Add the set to the JIT with the resolver we created above and a newly
// created SectionMemoryManager.
- return OptimizeLayer.addModule(std::move(M),
- std::move(Resolver));
+ return cantFail(OptimizeLayer.addModule(std::move(M),
+ std::move(Resolver)));
}
Error addFunctionAST(std::unique_ptr<FunctionAST> FnAST) {
@@ -204,7 +204,7 @@ public:
addModule(std::move(M));
auto Sym = findSymbol(SharedFnAST->getName() + "$impl");
assert(Sym && "Couldn't find compiled function?");
- JITTargetAddress SymAddr = Sym.getAddress();
+ JITTargetAddress SymAddr = cantFail(Sym.getAddress());
if (auto Err =
IndirectStubsMgr->updatePointer(mangle(SharedFnAST->getName()),
SymAddr)) {
@@ -228,7 +228,7 @@ public:
}
void removeModule(ModuleHandle H) {
- OptimizeLayer.removeModule(H);
+ cantFail(OptimizeLayer.removeModule(H));
}
private:
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp b/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp
index edd050959d6..7bbc06a0958 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp
@@ -1177,7 +1177,7 @@ static void HandleTopLevelExpression() {
// Get the symbol's address and cast it to the right type (takes no
// arguments, returns a double) so we can call it as a native function.
- ExitOnErr(TheJIT->executeRemoteExpr(ExprSymbol.getAddress()));
+ ExitOnErr(TheJIT->executeRemoteExpr(cantFail(ExprSymbol.getAddress())));
// Delete the anonymous expression module from the JIT.
TheJIT->removeModule(H);
diff --git a/examples/Kaleidoscope/Chapter4/toy.cpp b/examples/Kaleidoscope/Chapter4/toy.cpp
index cf7d6c2bee0..921fa890804 100644
--- a/examples/Kaleidoscope/Chapter4/toy.cpp
+++ b/examples/Kaleidoscope/Chapter4/toy.cpp
@@ -611,7 +611,7 @@ static void HandleTopLevelExpression() {
// Get the symbol's address and cast it to the right type (takes no
// arguments, returns a double) so we can call it as a native function.
- double (*FP)() = (double (*)())(intptr_t)ExprSymbol.getAddress();
+ double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress());
fprintf(stderr, "Evaluated to %f\n", FP());
// Delete the anonymous expression module from the JIT.
diff --git a/examples/Kaleidoscope/Chapter5/toy.cpp b/examples/Kaleidoscope/Chapter5/toy.cpp
index 6852973bae4..2d23bdb26c2 100644
--- a/examples/Kaleidoscope/Chapter5/toy.cpp
+++ b/examples/Kaleidoscope/Chapter5/toy.cpp
@@ -885,7 +885,7 @@ static void HandleTopLevelExpression() {
// Get the symbol's address and cast it to the right type (takes no
// arguments, returns a double) so we can call it as a native function.
- double (*FP)() = (double (*)())(intptr_t)ExprSymbol.getAddress();
+ double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress());
fprintf(stderr, "Evaluated to %f\n", FP());
// Delete the anonymous expression module from the JIT.
diff --git a/examples/Kaleidoscope/Chapter6/toy.cpp b/examples/Kaleidoscope/Chapter6/toy.cpp
index 0c222173558..b5e4495539f 100644
--- a/examples/Kaleidoscope/Chapter6/toy.cpp
+++ b/examples/Kaleidoscope/Chapter6/toy.cpp
@@ -1004,7 +1004,7 @@ static void HandleTopLevelExpression() {
// Get the symbol's address and cast it to the right type (takes no
// arguments, returns a double) so we can call it as a native function.
- double (*FP)() = (double (*)())(intptr_t)ExprSymbol.getAddress();
+ double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress());
fprintf(stderr, "Evaluated to %f\n", FP());
// Delete the anonymous expression module from the JIT.
diff --git a/examples/Kaleidoscope/Chapter7/toy.cpp b/examples/Kaleidoscope/Chapter7/toy.cpp
index 79ac7b33d7a..32f4a658c5d 100644
--- a/examples/Kaleidoscope/Chapter7/toy.cpp
+++ b/examples/Kaleidoscope/Chapter7/toy.cpp
@@ -1173,7 +1173,7 @@ static void HandleTopLevelExpression() {
// Get the symbol's address and cast it to the right type (takes no
// arguments, returns a double) so we can call it as a native function.
- double (*FP)() = (double (*)())(intptr_t)ExprSymbol.getAddress();
+ double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress());
fprintf(stderr, "Evaluated to %f\n", FP());
// Delete the anonymous expression module from the JIT.
diff --git a/examples/Kaleidoscope/include/KaleidoscopeJIT.h b/examples/Kaleidoscope/include/KaleidoscopeJIT.h
index e389781d8f4..90ae3d1041e 100644
--- a/examples/Kaleidoscope/include/KaleidoscopeJIT.h
+++ b/examples/Kaleidoscope/include/KaleidoscopeJIT.h
@@ -63,8 +63,8 @@ public:
return JITSymbol(nullptr);
},
[](const std::string &S) { return nullptr; });
- auto H = CompileLayer.addModule(std::move(M),
- std::move(Resolver));
+ auto H = cantFail(CompileLayer.addModule(std::move(M),
+ std::move(Resolver)));
ModuleHandles.push_back(H);
return H;
@@ -72,7 +72,7 @@ public:
void removeModule(ModuleHandleT H) {
ModuleHandles.erase(find(ModuleHandles, H));
- CompileLayer.removeModule(H);
+ cantFail(CompileLayer.removeModule(H));
}
JITSymbol findSymbol(const std::string Name) {