diff options
author | Lang Hames <lhames@gmail.com> | 2018-10-16 20:13:06 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2018-10-16 20:13:06 +0000 |
commit | 8b94274f22d8c346103c5682e7899e8b43db16d7 (patch) | |
tree | ab087f3142915bbc8d445561570f4ee30385227d /llvm/lib/ExecutionEngine/Orc/LLJIT.cpp | |
parent | 4084df00402bc9b69b15b56cbdd8f5f8be81cc0a (diff) | |
download | bcm5719-llvm-8b94274f22d8c346103c5682e7899e8b43db16d7.tar.gz bcm5719-llvm-8b94274f22d8c346103c5682e7899e8b43db16d7.zip |
[ORC] Make the VModuleKey optional, propagate it via MaterializationUnit and
MaterializationResponsibility.
VModuleKeys are intended to enable selective removal of modules from a JIT
session, however for a wide variety of use cases selective removal is not
needed and introduces unnecessary overhead. As of this commit, the default
constructed VModuleKey value is reserved as a "do not track" value, and
becomes the default when adding a new module to the JIT.
This commit also changes the propagation of VModuleKeys. They were passed
alongside the MaterializationResponsibity instance in XXLayer::emit methods,
but are now propagated as part of the MaterializationResponsibility instance
itself (and as part of MaterializationUnit when stored in a JITDylib).
Associating VModuleKeys with MaterializationUnits in this way should allow
for a thread-safe module removal mechanism in the future, even when a module
is in the process of being compiled, by having the
MaterializationResponsibility object check in on its VModuleKey's state
before commiting its results to the JITDylib.
llvm-svn: 344643
Diffstat (limited to 'llvm/lib/ExecutionEngine/Orc/LLJIT.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/Orc/LLJIT.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp index e464da267ae..ac71a5e7673 100644 --- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp +++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp @@ -65,15 +65,13 @@ Error LLJIT::addIRModule(JITDylib &JD, ThreadSafeModule TSM) { if (auto Err = applyDataLayout(*TSM.getModule())) return Err; - auto K = ES->allocateVModule(); - return CompileLayer.add(JD, K, std::move(TSM)); + return CompileLayer.add(JD, std::move(TSM), ES->allocateVModule()); } Error LLJIT::addObjectFile(JITDylib &JD, std::unique_ptr<MemoryBuffer> Obj) { assert(Obj && "Can not add null object"); - auto K = ES->allocateVModule(); - return ObjLinkingLayer.add(JD, K, std::move(Obj)); + return ObjLinkingLayer.add(JD, std::move(Obj), ES->allocateVModule()); } Expected<JITEvaluatedSymbol> LLJIT::lookupLinkerMangled(JITDylib &JD, @@ -84,8 +82,9 @@ Expected<JITEvaluatedSymbol> LLJIT::lookupLinkerMangled(JITDylib &JD, LLJIT::LLJIT(std::unique_ptr<ExecutionSession> ES, std::unique_ptr<TargetMachine> TM, DataLayout DL) : ES(std::move(ES)), Main(this->ES->getMainJITDylib()), DL(std::move(DL)), - ObjLinkingLayer(*this->ES, - [this](VModuleKey K) { return getMemoryManager(K); }), + ObjLinkingLayer( + *this->ES, + []() { return llvm::make_unique<SectionMemoryManager>(); }), CompileLayer(*this->ES, ObjLinkingLayer, TMOwningSimpleCompiler(std::move(TM))), CtorRunner(Main), DtorRunner(Main) {} @@ -93,8 +92,9 @@ LLJIT::LLJIT(std::unique_ptr<ExecutionSession> ES, LLJIT::LLJIT(std::unique_ptr<ExecutionSession> ES, JITTargetMachineBuilder JTMB, DataLayout DL, unsigned NumCompileThreads) : ES(std::move(ES)), Main(this->ES->getMainJITDylib()), DL(std::move(DL)), - ObjLinkingLayer(*this->ES, - [this](VModuleKey K) { return getMemoryManager(K); }), + ObjLinkingLayer( + *this->ES, + []() { return llvm::make_unique<SectionMemoryManager>(); }), CompileLayer(*this->ES, ObjLinkingLayer, ConcurrentIRCompiler(std::move(JTMB))), CtorRunner(Main), DtorRunner(Main) { @@ -117,11 +117,6 @@ LLJIT::LLJIT(std::unique_ptr<ExecutionSession> ES, JITTargetMachineBuilder JTMB, }); } -std::unique_ptr<RuntimeDyld::MemoryManager> -LLJIT::getMemoryManager(VModuleKey K) { - return llvm::make_unique<SectionMemoryManager>(); -} - std::string LLJIT::mangle(StringRef UnmangledName) { std::string MangledName; { @@ -187,8 +182,7 @@ Error LLLazyJIT::addLazyIRModule(JITDylib &JD, ThreadSafeModule TSM) { recordCtorDtors(*TSM.getModule()); - auto K = ES->allocateVModule(); - return CODLayer.add(JD, K, std::move(TSM)); + return CODLayer.add(JD, std::move(TSM), ES->allocateVModule()); } LLLazyJIT::LLLazyJIT( |