diff --git a/llvm/lib/ExecutionEngine/JIT/JIT.cpp b/llvm/lib/ExecutionEngine/JIT/JIT.cpp index 413308c3df89..f57de179c501 100644 --- a/llvm/lib/ExecutionEngine/JIT/JIT.cpp +++ b/llvm/lib/ExecutionEngine/JIT/JIT.cpp @@ -489,8 +489,6 @@ void *JIT::getPointerToFunction(Function *F) { if (void *Addr = getPointerToGlobalIfAvailable(F)) return Addr; // Check if function already code gen'd - MutexGuard locked(lock); - // Make sure we read in the function if it exists in this Module. if (F->hasNotBeenReadFromBitcode()) { // Determine the module provider this function is provided by. @@ -516,6 +514,8 @@ void *JIT::getPointerToFunction(Function *F) { return Addr; } + MutexGuard locked(lock); + if (F->isDeclaration()) { void *Addr = getPointerToNamedFunction(F->getName()); addGlobalMapping(F, Addr);