summaryrefslogtreecommitdiffstats
path: root/llvm/tools/lli/OrcLazyJIT.h
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
commit4ce98662e7d109b4579c35945345db685ae5b3fb (patch)
tree4538ca3c0131f3275286aac4347bf712ed0068e7 /llvm/tools/lli/OrcLazyJIT.h
parentb909f11a319ae62e683d1f9d82e28a05b360b8ae (diff)
downloadbcm5719-llvm-4ce98662e7d109b4579c35945345db685ae5b3fb.tar.gz
bcm5719-llvm-4ce98662e7d109b4579c35945345db685ae5b3fb.zip
[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. llvm-svn: 307350
Diffstat (limited to 'llvm/tools/lli/OrcLazyJIT.h')
-rw-r--r--llvm/tools/lli/OrcLazyJIT.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/llvm/tools/lli/OrcLazyJIT.h b/llvm/tools/lli/OrcLazyJIT.h
index 5592fb65139..47a2acc4d7e 100644
--- a/llvm/tools/lli/OrcLazyJIT.h
+++ b/llvm/tools/lli/OrcLazyJIT.h
@@ -75,10 +75,14 @@ public:
CXXRuntimeOverrides.runDestructors();
// Run any IR destructors.
for (auto &DtorRunner : IRStaticDestructorRunners)
- DtorRunner.runViaLayer(CODLayer);
+ if (auto Err = DtorRunner.runViaLayer(CODLayer)) {
+ // FIXME: OrcLazyJIT should probably take a "shutdownError" callback to
+ // report these errors on.
+ report_fatal_error(std::move(Err));
+ }
}
- void addModule(std::shared_ptr<Module> M) {
+ Error addModule(std::shared_ptr<Module> M) {
if (M->getDataLayout().isDefault())
M->setDataLayout(DL);
@@ -125,19 +129,27 @@ public:
);
// Add the module to the JIT.
- ModulesHandle =
- CODLayer.addModule(std::move(M), std::move(Resolver));
+ if (auto ModulesHandleOrErr =
+ CODLayer.addModule(std::move(M), std::move(Resolver)))
+ ModulesHandle = std::move(*ModulesHandleOrErr);
+ else
+ return ModulesHandleOrErr.takeError();
+
} else
- CODLayer.addExtraModule(ModulesHandle, std::move(M));
+ if (auto Err = CODLayer.addExtraModule(ModulesHandle, std::move(M)))
+ return Err;
// Run the static constructors, and save the static destructor runner for
// execution when the JIT is torn down.
orc::CtorDtorRunner<CODLayerT> CtorRunner(std::move(CtorNames),
ModulesHandle);
- CtorRunner.runViaLayer(CODLayer);
+ if (auto Err = CtorRunner.runViaLayer(CODLayer))
+ return Err;
IRStaticDestructorRunners.emplace_back(std::move(DtorNames),
ModulesHandle);
+
+ return Error::success();
}
JITSymbol findSymbol(const std::string &Name) {
OpenPOWER on IntegriCloud