summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/LeakDetector.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-06-18 21:35:56 +0000
committerOwen Anderson <resistor@mac.com>2009-06-18 21:35:56 +0000
commitb614f1e13cbb323a045daeef88196d210d0485bc (patch)
tree3066ea3af3ef7c97a7fd9853de7af9fa70fe1204 /llvm/lib/VMCore/LeakDetector.cpp
parent7f1ef67a7b42fff6dd6f497ff27e9a0c2ef028f4 (diff)
downloadbcm5719-llvm-b614f1e13cbb323a045daeef88196d210d0485bc.tar.gz
bcm5719-llvm-b614f1e13cbb323a045daeef88196d210d0485bc.zip
Simplify.
llvm-svn: 73725
Diffstat (limited to 'llvm/lib/VMCore/LeakDetector.cpp')
-rw-r--r--llvm/lib/VMCore/LeakDetector.cpp41
1 files changed, 12 insertions, 29 deletions
diff --git a/llvm/lib/VMCore/LeakDetector.cpp b/llvm/lib/VMCore/LeakDetector.cpp
index 036cb9c616c..b5926bcf441 100644
--- a/llvm/lib/VMCore/LeakDetector.cpp
+++ b/llvm/lib/VMCore/LeakDetector.cpp
@@ -32,7 +32,7 @@ namespace {
static void print(const Value* P) { cerr << *P; }
};
- ManagedStatic<sys::RWMutex> LeakDetectorLock;
+ ManagedStatic<sys::SmartRWMutex<true> > LeakDetectorLock;
template <typename T>
struct VISIBILITY_HIDDEN LeakDetectorImpl {
@@ -54,41 +54,26 @@ namespace {
// immediately, it is added to the CachedValue Value. If it is
// immediately removed, no set search need be performed.
void addGarbage(const T* o) {
- if (llvm_is_multithreaded()) {
- sys::ScopedWriter Writer(&*LeakDetectorLock);
- if (Cache) {
- assert(Ts.count(Cache) == 0 && "Object already in set!");
- Ts.insert(Cache);
- }
- Cache = o;
- } else {
- if (Cache) {
- assert(Ts.count(Cache) == 0 && "Object already in set!");
- Ts.insert(Cache);
- }
- Cache = o;
+ sys::SmartScopedWriter<true> Writer(&*LeakDetectorLock);
+ if (Cache) {
+ assert(Ts.count(Cache) == 0 && "Object already in set!");
+ Ts.insert(Cache);
}
+ Cache = o;
}
void removeGarbage(const T* o) {
- if (llvm_is_multithreaded()) {
- sys::ScopedWriter Writer(&*LeakDetectorLock);
- if (o == Cache)
- Cache = 0; // Cache hit
- else
- Ts.erase(o);
- } else {
- if (o == Cache)
- Cache = 0; // Cache hit
- else
- Ts.erase(o);
- }
+ sys::SmartScopedWriter<true> Writer(&*LeakDetectorLock);
+ if (o == Cache)
+ Cache = 0; // Cache hit
+ else
+ Ts.erase(o);
}
bool hasGarbage(const std::string& Message) {
addGarbage(0); // Flush the Cache
- if (llvm_is_multithreaded()) LeakDetectorLock->reader_acquire();
+ sys::SmartScopedReader<true> Reader(&*LeakDetectorLock);
assert(Cache == 0 && "No value should be cached anymore!");
if (!Ts.empty()) {
@@ -101,11 +86,9 @@ namespace {
}
cerr << '\n';
- if (llvm_is_multithreaded()) LeakDetectorLock->reader_release();
return true;
}
- if (llvm_is_multithreaded()) LeakDetectorLock->reader_release();
return false;
}
OpenPOWER on IntegriCloud