[llvm-commits] [llvm] r73723 - /llvm/trunk/lib/VMCore/Function.cpp
Owen Anderson
resistor at mac.com
Thu Jun 18 13:56:48 PDT 2009
Author: resistor
Date: Thu Jun 18 15:56:48 2009
New Revision: 73723
URL: http://llvm.org/viewvc/llvm-project?rev=73723&view=rev
Log:
Simplify.
Modified:
llvm/trunk/lib/VMCore/Function.cpp
Modified: llvm/trunk/lib/VMCore/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=73723&r1=73722&r2=73723&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Function.cpp (original)
+++ llvm/trunk/lib/VMCore/Function.cpp Thu Jun 18 15:56:48 2009
@@ -233,37 +233,30 @@
// use GC.
static DenseMap<const Function*,PooledStringPtr> *GCNames;
static StringPool *GCNamePool;
-static ManagedStatic<sys::RWMutex> GCLock;
+static ManagedStatic<sys::SmartRWMutex<true> > GCLock;
bool Function::hasGC() const {
- if (llvm_is_multithreaded()) {
- sys::ScopedReader Reader(&*GCLock);
- return GCNames && GCNames->count(this);
- } else
- return GCNames && GCNames->count(this);
+ sys::SmartScopedReader<true> Reader(&*GCLock);
+ return GCNames && GCNames->count(this);
}
const char *Function::getGC() const {
assert(hasGC() && "Function has no collector");
- if (llvm_is_multithreaded()) {
- sys::ScopedReader Reader(&*GCLock);
- return *(*GCNames)[this];
- } else
- return *(*GCNames)[this];
+ sys::SmartScopedReader<true> Reader(&*GCLock);
+ return *(*GCNames)[this];
}
void Function::setGC(const char *Str) {
- if (llvm_is_multithreaded()) GCLock->writer_acquire();
+ sys::SmartScopedWriter<true> Writer(&*GCLock);
if (!GCNamePool)
GCNamePool = new StringPool();
if (!GCNames)
GCNames = new DenseMap<const Function*,PooledStringPtr>();
(*GCNames)[this] = GCNamePool->intern(Str);
- if (llvm_is_multithreaded()) GCLock->writer_release();
}
void Function::clearGC() {
- if (llvm_is_multithreaded()) GCLock->writer_acquire();
+ sys::SmartScopedWriter<true> Writer(&*GCLock);
if (GCNames) {
GCNames->erase(this);
if (GCNames->empty()) {
@@ -275,7 +268,6 @@
}
}
}
- if (llvm_is_multithreaded()) GCLock->writer_release();
}
/// copyAttributesFrom - copy all additional attributes (those not needed to
More information about the llvm-commits
mailing list