summaryrefslogtreecommitdiff
path: root/tools/lli/OrcLazyJIT.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lli/OrcLazyJIT.h')
-rw-r--r--tools/lli/OrcLazyJIT.h29
1 files changed, 20 insertions, 9 deletions
diff --git a/tools/lli/OrcLazyJIT.h b/tools/lli/OrcLazyJIT.h
index fc02a10b514e0..47a2acc4d7e60 100644
--- a/tools/lli/OrcLazyJIT.h
+++ b/tools/lli/OrcLazyJIT.h
@@ -61,7 +61,8 @@ public:
IndirectStubsManagerBuilder IndirectStubsMgrBuilder,
bool InlineStubs)
: TM(std::move(TM)), DL(this->TM->createDataLayout()),
- CCMgr(std::move(CCMgr)),
+ CCMgr(std::move(CCMgr)),
+ ObjectLayer([]() { return std::make_shared<SectionMemoryManager>(); }),
CompileLayer(ObjectLayer, orc::SimpleCompiler(*this->TM)),
IRDumpLayer(CompileLayer, createDebugDumper()),
CODLayer(IRDumpLayer, extractSingleFunction, *this->CCMgr,
@@ -74,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);
@@ -124,21 +129,27 @@ public:
);
// Add the module to the JIT.
- ModulesHandle =
- CODLayer.addModule(std::move(M),
- llvm::make_unique<SectionMemoryManager>(),
- 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) {