diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp index 82647ea94401..2c663c2e1edf 100644 --- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -142,8 +142,14 @@ void MCJIT::setObjectCache(ObjectCache* NewCache) { } std::unique_ptr 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.