summaryrefslogtreecommitdiffstats
path: root/llvm/examples
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2019-12-04 22:45:38 -0800
committerLang Hames <lhames@gmail.com>2019-12-05 01:36:49 -0800
commit4fc68b9b7f3e07ea4425c6111e1a9455cf4aa322 (patch)
treea34b36b9bd3fc33df70ba3f6fcef2f17785ce69c /llvm/examples
parent76a5c8421e04b246892157fe18f1c082c908c5e9 (diff)
downloadbcm5719-llvm-4fc68b9b7f3e07ea4425c6111e1a9455cf4aa322.tar.gz
bcm5719-llvm-4fc68b9b7f3e07ea4425c6111e1a9455cf4aa322.zip
[ORC] Remove the automagic Main JITDylib fram ExecutionSession.
This patch removes the magic "main" JITDylib from ExecutionEngine. The main JITDylib was created automatically at ExecutionSession construction time, and all subsequently created JITDylibs were added to the main JITDylib's links-against list by default. This saves a couple of lines of boilerplate for simple JIT setups, but this isn't worth introducing magical behavior for. ORCv2 clients should now construct their own main JITDylib using ExecutionSession::createJITDylib and set up its linkages manually using JITDylib::setSearchOrder (or related methods in JITDylib).
Diffstat (limited to 'llvm/examples')
-rw-r--r--llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h12
-rw-r--r--llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h15
-rw-r--r--llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp21
3 files changed, 26 insertions, 22 deletions
diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h
index a7fa3afc470..020b72c2394 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h
+++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h
@@ -39,14 +39,17 @@ private:
MangleAndInterner Mangle;
ThreadSafeContext Ctx;
+ JITDylib &MainJD;
+
public:
KaleidoscopeJIT(JITTargetMachineBuilder JTMB, DataLayout DL)
: ObjectLayer(ES,
[]() { return std::make_unique<SectionMemoryManager>(); }),
CompileLayer(ES, ObjectLayer, ConcurrentIRCompiler(std::move(JTMB))),
DL(std::move(DL)), Mangle(ES, this->DL),
- Ctx(std::make_unique<LLVMContext>()) {
- ES.getMainJITDylib().addGenerator(
+ Ctx(std::make_unique<LLVMContext>()),
+ MainJD(ES.createJITDylib("<main>")) {
+ MainJD.addGenerator(
cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess(
DL.getGlobalPrefix())));
}
@@ -69,12 +72,11 @@ public:
LLVMContext &getContext() { return *Ctx.getContext(); }
Error addModule(std::unique_ptr<Module> M) {
- return CompileLayer.add(ES.getMainJITDylib(),
- ThreadSafeModule(std::move(M), Ctx));
+ return CompileLayer.add(MainJD, ThreadSafeModule(std::move(M), Ctx));
}
Expected<JITEvaluatedSymbol> lookup(StringRef Name) {
- return ES.lookup({&ES.getMainJITDylib()}, Mangle(Name.str()));
+ return ES.lookup({&MainJD}, Mangle(Name.str()));
}
};
diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h
index e9999efd37a..8037e58ae4f 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h
+++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h
@@ -45,15 +45,17 @@ private:
MangleAndInterner Mangle;
ThreadSafeContext Ctx;
+ JITDylib &MainJD;
+
public:
KaleidoscopeJIT(JITTargetMachineBuilder JTMB, DataLayout DL)
: ObjectLayer(ES,
[]() { return std::make_unique<SectionMemoryManager>(); }),
CompileLayer(ES, ObjectLayer, ConcurrentIRCompiler(std::move(JTMB))),
- OptimizeLayer(ES, CompileLayer, optimizeModule),
- DL(std::move(DL)), Mangle(ES, this->DL),
- Ctx(std::make_unique<LLVMContext>()) {
- ES.getMainJITDylib().addGenerator(
+ OptimizeLayer(ES, CompileLayer, optimizeModule), DL(std::move(DL)),
+ Mangle(ES, this->DL), Ctx(std::make_unique<LLVMContext>()),
+ MainJD(ES.createJITDylib("<main>")) {
+ MainJD.addGenerator(
cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess(
DL.getGlobalPrefix())));
}
@@ -76,12 +78,11 @@ public:
}
Error addModule(std::unique_ptr<Module> M) {
- return OptimizeLayer.add(ES.getMainJITDylib(),
- ThreadSafeModule(std::move(M), Ctx));
+ return OptimizeLayer.add(MainJD, ThreadSafeModule(std::move(M), Ctx));
}
Expected<JITEvaluatedSymbol> lookup(StringRef Name) {
- return ES.lookup({&ES.getMainJITDylib()}, Mangle(Name.str()));
+ return ES.lookup({&MainJD}, Mangle(Name.str()));
}
private:
diff --git a/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp b/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp
index 5a0ad376bcd..f4cfb7403db 100644
--- a/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp
+++ b/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp
@@ -76,12 +76,12 @@ public:
ExecutionSession &getES() { return *ES; }
- Error addModule(JITDylib &JD, ThreadSafeModule TSM) {
- return CODLayer.add(JD, std::move(TSM));
+ Error addModule(ThreadSafeModule TSM) {
+ return CODLayer.add(MainJD, std::move(TSM));
}
Expected<JITEvaluatedSymbol> lookup(StringRef UnmangledName) {
- return ES->lookup({&ES->getMainJITDylib()}, Mangle(UnmangledName));
+ return ES->lookup({&MainJD}, Mangle(UnmangledName));
}
~SpeculativeJIT() { CompileThreads.wait(); }
@@ -101,15 +101,15 @@ private:
std::unique_ptr<LazyCallThroughManager> LCTMgr,
IndirectStubsManagerBuilderFunction ISMBuilder,
std::unique_ptr<DynamicLibrarySearchGenerator> ProcessSymbolsGenerator)
- : ES(std::move(ES)), DL(std::move(DL)), LCTMgr(std::move(LCTMgr)),
+ : ES(std::move(ES)), DL(std::move(DL)),
+ MainJD(this->ES->createJITDylib("<main>")), LCTMgr(std::move(LCTMgr)),
CompileLayer(*this->ES, ObjLayer,
ConcurrentIRCompiler(std::move(JTMB))),
S(Imps, *this->ES),
SpeculateLayer(*this->ES, CompileLayer, S, Mangle, BlockFreqQuery()),
CODLayer(*this->ES, SpeculateLayer, *this->LCTMgr,
std::move(ISMBuilder)) {
- this->ES->getMainJITDylib().addGenerator(
- std::move(ProcessSymbolsGenerator));
+ MainJD.addGenerator(std::move(ProcessSymbolsGenerator));
this->CODLayer.setImplMap(&Imps);
this->ES->setDispatchMaterialization(
@@ -119,9 +119,9 @@ private:
auto Work = [SharedMU, &JD]() { SharedMU->doMaterialize(JD); };
CompileThreads.async(std::move(Work));
});
- ExitOnErr(S.addSpeculationRuntime(this->ES->getMainJITDylib(), Mangle));
+ ExitOnErr(S.addSpeculationRuntime(MainJD, Mangle));
LocalCXXRuntimeOverrides CXXRuntimeoverrides;
- ExitOnErr(CXXRuntimeoverrides.enable(this->ES->getMainJITDylib(), Mangle));
+ ExitOnErr(CXXRuntimeoverrides.enable(MainJD, Mangle));
}
static std::unique_ptr<SectionMemoryManager> createMemMgr() {
@@ -133,6 +133,8 @@ private:
MangleAndInterner Mangle{*ES, DL};
ThreadPool CompileThreads{NumThreads};
+ JITDylib &MainJD;
+
Triple TT;
std::unique_ptr<LazyCallThroughManager> LCTMgr;
IRCompileLayer CompileLayer;
@@ -172,8 +174,7 @@ int main(int argc, char *argv[]) {
return 1;
}
- ExitOnErr(SJ->addModule(SJ->getES().getMainJITDylib(),
- ThreadSafeModule(std::move(M), std::move(Ctx))));
+ ExitOnErr(SJ->addModule(ThreadSafeModule(std::move(M), std::move(Ctx))));
}
auto MainSym = ExitOnErr(SJ->lookup("main"));
OpenPOWER on IntegriCloud