diff options
Diffstat (limited to 'lib/ExecutionEngine/MCJIT/MCJIT.cpp')
-rw-r--r-- | lib/ExecutionEngine/MCJIT/MCJIT.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/lib/ExecutionEngine/MCJIT/MCJIT.cpp index f7b8a3b657ee..2c663c2e1edf 100644 --- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -39,11 +39,10 @@ static struct RegisterJIT { extern "C" void LLVMLinkInMCJIT() { } -ExecutionEngine* -MCJIT::createJIT(std::unique_ptr<Module> M, - std::string *ErrorStr, +ExecutionEngine * +MCJIT::createJIT(std::unique_ptr<Module> M, std::string *ErrorStr, std::shared_ptr<MCJITMemoryManager> MemMgr, - std::shared_ptr<JITSymbolResolver> Resolver, + std::shared_ptr<LegacyJITSymbolResolver> Resolver, std::unique_ptr<TargetMachine> TM) { // Try to register the program as a source of symbols to resolve against. // @@ -64,7 +63,7 @@ MCJIT::createJIT(std::unique_ptr<Module> M, MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> TM, std::shared_ptr<MCJITMemoryManager> MemMgr, - std::shared_ptr<JITSymbolResolver> Resolver) + std::shared_ptr<LegacyJITSymbolResolver> Resolver) : ExecutionEngine(TM->createDataLayout(), std::move(M)), TM(std::move(TM)), Ctx(nullptr), MemMgr(std::move(MemMgr)), Resolver(*this, std::move(Resolver)), Dyld(*this->MemMgr, this->Resolver), @@ -143,8 +142,14 @@ void MCJIT::setObjectCache(ObjectCache* NewCache) { } std::unique_ptr<MemoryBuffer> MCJIT::emitObject(Module *M) { + assert(M && "Can not emit a null module"); + MutexGuard locked(lock); + // Materialize all globals in the module if they have not been + // materialized already. + cantFail(M->materializeAll()); + // This must be a module which has already been added but not loaded to this // MCJIT instance, since these conditions are tested by our caller, // generateCodeForModule. @@ -165,7 +170,7 @@ std::unique_ptr<MemoryBuffer> MCJIT::emitObject(Module *M) { // Flush the output buffer to get the generated code into memory std::unique_ptr<MemoryBuffer> CompiledObjBuffer( - new ObjectMemoryBuffer(std::move(ObjBufferSV))); + new SmallVectorMemoryBuffer(std::move(ObjBufferSV))); // If we have an object cache, tell it about the new object. // Note that we're using the compiled image, not the loaded image (as below). @@ -666,3 +671,5 @@ LinkingSymbolResolver::findSymbol(const std::string &Name) { return nullptr; return ClientResolver->findSymbol(Name); } + +void LinkingSymbolResolver::anchor() {} |