From e6b73b045ef4b803cf9c86c90b99aea966b17728 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 12 Jun 2018 20:43:15 +0000 Subject: [PATCH] [MCJIT] Call materializeAll on modules before compiling them in MCJIT. This only affects modules with lazy GVMaterializers attached (usually modules read off disk using the lazy bitcode reader). For such modules, materializing before compiling prevents crashes due to missing function bodies / initializers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334535 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ExecutionEngine/MCJIT/MCJIT.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/lib/ExecutionEngine/MCJIT/MCJIT.cpp index 82647ea9440..2c663c2e1ed 100644 --- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/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. -- 2.11.0