diff options
author | Owen Anderson <resistor@mac.com> | 2009-06-18 21:35:56 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-06-18 21:35:56 +0000 |
commit | e8b42a42024a94035185a2e69d7acd5e63740e76 (patch) | |
tree | 0d6cfcde8064ebdf07d173538d4846ba9a6b4dff /lib | |
parent | 24164bc8f563a34eb00a7d4a5dd6acafadf0f3fc (diff) | |
download | external_llvm-e8b42a42024a94035185a2e69d7acd5e63740e76.zip external_llvm-e8b42a42024a94035185a2e69d7acd5e63740e76.tar.gz external_llvm-e8b42a42024a94035185a2e69d7acd5e63740e76.tar.bz2 |
Simplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73725 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VMCore/LeakDetector.cpp | 41 |
1 files changed, 12 insertions, 29 deletions
diff --git a/lib/VMCore/LeakDetector.cpp b/lib/VMCore/LeakDetector.cpp index 036cb9c..b5926bc 100644 --- a/lib/VMCore/LeakDetector.cpp +++ b/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; } |