Index: include/llvm/ExecutionEngine/ExecutionEngine.h =================================================================== --- include/llvm/ExecutionEngine/ExecutionEngine.h +++ include/llvm/ExecutionEngine/ExecutionEngine.h @@ -22,10 +22,10 @@ #include "llvm/IR/ValueMap.h" #include "llvm/MC/MCCodeGenInfo.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/Mutex.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include +#include #include #include @@ -42,7 +42,6 @@ class JITMemoryManager; class MachineCodeInfo; class Module; -class MutexGuard; class ObjectCache; class RTDyldMemoryManager; class Triple; @@ -59,7 +58,7 @@ public: struct AddressMapConfig : public ValueMapConfig { typedef ExecutionEngineState *ExtraData; - static sys::Mutex *getMutex(ExecutionEngineState *EES); + static std::recursive_mutex *getMutex(ExecutionEngineState *EES); static void onDelete(ExecutionEngineState *EES, const GlobalValue *Old); static void onRAUW(ExecutionEngineState *, const GlobalValue *, const GlobalValue *); @@ -164,7 +163,7 @@ /// lock - This lock protects the ExecutionEngine, MCJIT, JIT, JITResolver and /// JITEmitter classes. It must be held while changing the internal state of /// any of those classes. - sys::Mutex lock; + std::recursive_mutex lock; //===--------------------------------------------------------------------===// // ExecutionEngine Startup Index: include/llvm/IR/ValueMap.h =================================================================== --- include/llvm/IR/ValueMap.h +++ include/llvm/IR/ValueMap.h @@ -28,9 +28,9 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/IR/ValueHandle.h" -#include "llvm/Support/Mutex.h" #include "llvm/Support/type_traits.h" #include +#include namespace llvm { @@ -67,7 +67,9 @@ /// and onDelete) and not inside other ValueMap methods. NULL means that no /// mutex is necessary. template - static sys::Mutex *getMutex(const ExtraDataT &/*Data*/) { return nullptr; } + static std::recursive_mutex *getMutex(const ExtraDataT &/*Data*/) { + return nullptr; + } }; /// See the file comment. @@ -212,22 +214,22 @@ void deleted() override { // Make a copy that won't get changed even when *this is destroyed. ValueMapCallbackVH Copy(*this); - sys::Mutex *M = Config::getMutex(Copy.Map->Data); + std::recursive_mutex *M = Config::getMutex(Copy.Map->Data); if (M) - M->acquire(); + M->lock(); Config::onDelete(Copy.Map->Data, Copy.Unwrap()); // May destroy *this. Copy.Map->Map.erase(Copy); // Definitely destroys *this. if (M) - M->release(); + M->unlock(); } void allUsesReplacedWith(Value *new_key) override { assert(isa(new_key) && "Invalid RAUW on key of ValueMap<>"); // Make a copy that won't get changed even when *this is destroyed. ValueMapCallbackVH Copy(*this); - sys::Mutex *M = Config::getMutex(Copy.Map->Data); + std::recursive_mutex *M = Config::getMutex(Copy.Map->Data); if (M) - M->acquire(); + M->lock(); KeyT typed_new_key = cast(new_key); // Can destroy *this: @@ -243,7 +245,7 @@ } } if (M) - M->release(); + M->unlock(); } }; Index: lib/ExecutionEngine/ExecutionEngine.cpp =================================================================== --- lib/ExecutionEngine/ExecutionEngine.cpp +++ lib/ExecutionEngine/ExecutionEngine.cpp @@ -166,7 +166,7 @@ } void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) { - MutexGuard locked(lock); + std::lock_guard locked(lock); DEBUG(dbgs() << "JIT: Map \'" << GV->getName() << "\' to [" << Addr << "]\n";); @@ -184,14 +184,14 @@ } void ExecutionEngine::clearAllGlobalMappings() { - MutexGuard locked(lock); + std::lock_guard locked(lock); EEState.getGlobalAddressMap().clear(); EEState.getGlobalAddressReverseMap().clear(); } void ExecutionEngine::clearGlobalMappingsFromModule(Module *M) { - MutexGuard locked(lock); + std::lock_guard locked(lock); for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; ++FI) EEState.RemoveMapping(FI); @@ -201,7 +201,7 @@ } void *ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) { - MutexGuard locked(lock); + std::lock_guard locked(lock); ExecutionEngineState::GlobalAddressMapTy &Map = EEState.getGlobalAddressMap(); @@ -228,7 +228,7 @@ } void *ExecutionEngine::getPointerToGlobalIfAvailable(const GlobalValue *GV) { - MutexGuard locked(lock); + std::lock_guard locked(lock); ExecutionEngineState::GlobalAddressMapTy::iterator I = EEState.getGlobalAddressMap().find(GV); @@ -236,7 +236,7 @@ } const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) { - MutexGuard locked(lock); + std::lock_guard locked(lock); // If we haven't computed the reverse mapping yet, do so first. if (EEState.getGlobalAddressReverseMap().empty()) { @@ -555,7 +555,7 @@ if (Function *F = const_cast(dyn_cast(GV))) return getPointerToFunction(F); - MutexGuard locked(lock); + std::lock_guard locked(lock); if (void *P = EEState.getGlobalAddressMap()[GV]) return P; @@ -1346,7 +1346,7 @@ : EE(EE), GlobalAddressMap(this) { } -sys::Mutex * +std::recursive_mutex * ExecutionEngineState::AddressMapConfig::getMutex(ExecutionEngineState *EES) { return &EES->EE.lock; }