From 6e5eccf86b54bc8b0cc25c263ed0cfaff8670f28 Mon Sep 17 00:00:00 2001 From: Mon P Wang Date: Fri, 10 Oct 2008 01:47:42 +0000 Subject: Moved guard mutex upwards to guard materializing a function in getPointerToFunction llvm-svn: 57340 --- llvm/lib/ExecutionEngine/JIT/JIT.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/ExecutionEngine/JIT/JIT.cpp b/llvm/lib/ExecutionEngine/JIT/JIT.cpp index 383b3804758..413308c3df8 100644 --- a/llvm/lib/ExecutionEngine/JIT/JIT.cpp +++ b/llvm/lib/ExecutionEngine/JIT/JIT.cpp @@ -489,6 +489,8 @@ 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. @@ -509,13 +511,11 @@ void *JIT::getPointerToFunction(Function *F) { abort(); } } - + if (void *Addr = getPointerToGlobalIfAvailable(F)) { return Addr; } - MutexGuard locked(lock); - if (F->isDeclaration()) { void *Addr = getPointerToNamedFunction(F->getName()); addGlobalMapping(F, Addr); -- cgit v1.2.3