diff options
author | Ed Schouten <ed@FreeBSD.org> | 2009-06-22 08:08:12 +0000 |
---|---|---|
committer | Ed Schouten <ed@FreeBSD.org> | 2009-06-22 08:08:12 +0000 |
commit | b2f21fb044b6b5c52cff6227f9f79ca4ed42b18f (patch) | |
tree | 86c1bc482baa6c81fc70b8d715153bfa93377186 /lib/VMCore/Function.cpp | |
parent | 600c6fa13de5c407dc36dbb0ab73807868741ae0 (diff) |
Notes
Diffstat (limited to 'lib/VMCore/Function.cpp')
-rw-r--r-- | lib/VMCore/Function.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 54bd895fd409..045056643b54 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -16,7 +16,10 @@ #include "llvm/IntrinsicInst.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/Support/LeakDetector.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/StringPool.h" +#include "llvm/System/RWMutex.h" +#include "llvm/System/Threading.h" #include "SymbolTableListTraitsImpl.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringExtras.h" @@ -230,17 +233,21 @@ void Function::removeAttribute(unsigned i, Attributes attr) { // use GC. static DenseMap<const Function*,PooledStringPtr> *GCNames; static StringPool *GCNamePool; +static ManagedStatic<sys::SmartRWMutex<true> > GCLock; bool Function::hasGC() const { + sys::SmartScopedReader<true> Reader(&*GCLock); return GCNames && GCNames->count(this); } const char *Function::getGC() const { assert(hasGC() && "Function has no collector"); + sys::SmartScopedReader<true> Reader(&*GCLock); return *(*GCNames)[this]; } void Function::setGC(const char *Str) { + sys::SmartScopedWriter<true> Writer(&*GCLock); if (!GCNamePool) GCNamePool = new StringPool(); if (!GCNames) @@ -249,6 +256,7 @@ void Function::setGC(const char *Str) { } void Function::clearGC() { + sys::SmartScopedWriter<true> Writer(&*GCLock); if (GCNames) { GCNames->erase(this); if (GCNames->empty()) { |