[llvm] r334535 - [MCJIT] Call materializeAll on modules before compiling them in MCJIT.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 12 13:43:15 PDT 2018
Author: lhames
Date: Tue Jun 12 13:43:15 2018
New Revision: 334535
URL: http://llvm.org/viewvc/llvm-project?rev=334535&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=334535&r1=334534&r2=334535&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Tue Jun 12 13:43:15 2018
@@ -142,8 +142,14 @@ void MCJIT::setObjectCache(ObjectCache*
}
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.
More information about the llvm-commits
mailing list