Replace Execution Engine's mutex with std::recursive_mutex.

This change has a bit of a trickle down effect due to the fact that
there are a number of derived implementations of ExecutionEngine,
and that the mutex is not tightly encapsulated so is used by other
classes directly.

Reviewed by: rnk

Differential Revision: http://reviews.llvm.org/D4196

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211214 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Zachary Turner
2014-06-18 20:17:35 +00:00
parent b2791542c2
commit 1f502bd9d7
7 changed files with 69 additions and 71 deletions

View File

@ -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 <iterator>
#include <mutex>
namespace llvm {
@ -45,7 +45,7 @@ class ValueMapConstIterator;
/// This class defines the default behavior for configurable aspects of
/// ValueMap<>. User Configs should inherit from this class to be as compatible
/// as possible with future versions of ValueMap.
template<typename KeyT, typename MutexT = sys::Mutex>
template<typename KeyT, typename MutexT = std::recursive_mutex>
struct ValueMapConfig {
typedef MutexT mutex_type;
@ -216,11 +216,11 @@ public:
ValueMapCallbackVH Copy(*this);
typename Config::mutex_type *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<KeySansPointerT>(new_key) &&
@ -229,7 +229,7 @@ public:
ValueMapCallbackVH Copy(*this);
typename Config::mutex_type *M = Config::getMutex(Copy.Map->Data);
if (M)
M->acquire();
M->lock();
KeyT typed_new_key = cast<KeySansPointerT>(new_key);
// Can destroy *this:
@ -245,7 +245,7 @@ public:
}
}
if (M)
M->release();
M->unlock();
}
};