summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-07-07 18:33:04 +0000
committerOwen Anderson <resistor@mac.com>2009-07-07 18:33:04 +0000
commita9d1f2c559ef4b2549e29288fe6944e68913ba0f (patch)
tree79e3d7e0aafc4352dafe175986671f4353c0c5e2
parentfd15beefeedcb8108913e75e7c736dfcc17b433a (diff)
downloadllvm-a9d1f2c559ef4b2549e29288fe6944e68913ba0f.tar.gz
llvm-a9d1f2c559ef4b2549e29288fe6944e68913ba0f.tar.bz2
llvm-a9d1f2c559ef4b2549e29288fe6944e68913ba0f.tar.xz
Have scoped mutexes take referenes instead of pointers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74931 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/System/Mutex.h8
-rw-r--r--include/llvm/System/RWMutex.h18
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp2
-rw-r--r--lib/CompilerDriver/Plugin.cpp8
-rw-r--r--lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp4
-rw-r--r--lib/Support/Annotation.cpp8
-rw-r--r--lib/Support/PluginLoader.cpp6
-rw-r--r--lib/Support/Statistic.cpp2
-rw-r--r--lib/Support/Timer.cpp14
-rw-r--r--lib/Target/TargetData.cpp6
-rw-r--r--lib/VMCore/Constants.cpp24
-rw-r--r--lib/VMCore/Function.cpp8
-rw-r--r--lib/VMCore/LeakDetector.cpp6
-rw-r--r--lib/VMCore/Pass.cpp6
-rw-r--r--lib/VMCore/PassManager.cpp4
-rw-r--r--lib/VMCore/Type.cpp14
-rw-r--r--lib/VMCore/TypeSymbolTable.cpp10
-rw-r--r--lib/VMCore/Value.cpp6
18 files changed, 76 insertions, 78 deletions
diff --git a/include/llvm/System/Mutex.h b/include/llvm/System/Mutex.h
index d2c457dbc9..9ef5942a70 100644
--- a/include/llvm/System/Mutex.h
+++ b/include/llvm/System/Mutex.h
@@ -131,15 +131,15 @@ namespace llvm
template<bool mt_only>
class SmartScopedLock {
- SmartMutex<mt_only>* mtx;
+ SmartMutex<mt_only>& mtx;
public:
- SmartScopedLock(SmartMutex<mt_only>* m) : mtx(m) {
- mtx->acquire();
+ SmartScopedLock(SmartMutex<mt_only>& m) : mtx(m) {
+ mtx.acquire();
}
~SmartScopedLock() {
- mtx->release();
+ mtx.release();
}
};
diff --git a/include/llvm/System/RWMutex.h b/include/llvm/System/RWMutex.h
index e577d457af..3a288180bf 100644
--- a/include/llvm/System/RWMutex.h
+++ b/include/llvm/System/RWMutex.h
@@ -141,15 +141,14 @@ namespace llvm
/// ScopedReader - RAII acquisition of a reader lock
template<bool mt_only>
struct SmartScopedReader {
- SmartRWMutex<mt_only>* mutex;
+ SmartRWMutex<mt_only>& mutex;
- explicit SmartScopedReader(SmartRWMutex<mt_only>* m) {
- mutex = m;
- mutex->reader_acquire();
+ explicit SmartScopedReader(SmartRWMutex<mt_only>& m) : mutex(m) {
+ mutex.reader_acquire();
}
~SmartScopedReader() {
- mutex->reader_release();
+ mutex.reader_release();
}
};
typedef SmartScopedReader<false> ScopedReader;
@@ -157,15 +156,14 @@ namespace llvm
/// ScopedWriter - RAII acquisition of a writer lock
template<bool mt_only>
struct SmartScopedWriter {
- SmartRWMutex<mt_only>* mutex;
+ SmartRWMutex<mt_only>& mutex;
- explicit SmartScopedWriter(SmartRWMutex<mt_only>* m) {
- mutex = m;
- mutex->writer_acquire();
+ explicit SmartScopedWriter(SmartRWMutex<mt_only>& m) : mutex(m) {
+ mutex.writer_acquire();
}
~SmartScopedWriter() {
- mutex->writer_release();
+ mutex.writer_release();
}
};
typedef SmartScopedWriter<false> ScopedWriter;
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index c8f4b520ff..5f45c980a5 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5010,7 +5010,7 @@ static ManagedStatic<sys::SmartMutex<true> > VTMutex;
/// getValueTypeList - Return a pointer to the specified value type.
///
const MVT *SDNode::getValueTypeList(MVT VT) {
- sys::SmartScopedLock<true> Lock(&*VTMutex);
+ sys::SmartScopedLock<true> Lock(*VTMutex);
if (VT.isExtended()) {
return &(*EVTs->insert(VT).first);
} else {
diff --git a/lib/CompilerDriver/Plugin.cpp b/lib/CompilerDriver/Plugin.cpp
index cb3c7be39d..7310d120bf 100644
--- a/lib/CompilerDriver/Plugin.cpp
+++ b/lib/CompilerDriver/Plugin.cpp
@@ -42,7 +42,7 @@ namespace {
namespace llvmc {
PluginLoader::PluginLoader() {
- llvm::sys::SmartScopedLock<true> Lock(&*PluginMutex);
+ llvm::sys::SmartScopedLock<true> Lock(*PluginMutex);
if (!pluginListInitialized) {
for (PluginRegistry::iterator B = PluginRegistry::begin(),
E = PluginRegistry::end(); B != E; ++B)
@@ -53,7 +53,7 @@ namespace llvmc {
}
PluginLoader::~PluginLoader() {
- llvm::sys::SmartScopedLock<true> Lock(&*PluginMutex);
+ llvm::sys::SmartScopedLock<true> Lock(*PluginMutex);
if (pluginListInitialized) {
for (PluginList::iterator B = Plugins.begin(), E = Plugins.end();
B != E; ++B)
@@ -63,14 +63,14 @@ namespace llvmc {
}
void PluginLoader::PopulateLanguageMap(LanguageMap& langMap) {
- llvm::sys::SmartScopedLock<true> Lock(&*PluginMutex);
+ llvm::sys::SmartScopedLock<true> Lock(*PluginMutex);
for (PluginList::iterator B = Plugins.begin(), E = Plugins.end();
B != E; ++B)
(*B)->PopulateLanguageMap(langMap);
}
void PluginLoader::PopulateCompilationGraph(CompilationGraph& graph) {
- llvm::sys::SmartScopedLock<true> Lock(&*PluginMutex);
+ llvm::sys::SmartScopedLock<true> Lock(*PluginMutex);
for (PluginList::iterator B = Plugins.begin(), E = Plugins.end();
B != E; ++B)
(*B)->PopulateCompilationGraph(graph);
diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
index b8525a30ec..21a6f761db 100644
--- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
+++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
@@ -97,7 +97,7 @@ static ExFunc lookupFunction(const Function *F) {
ExtName += getTypeID(FT->getContainedType(i));
ExtName += "_" + F->getName();
- sys::ScopedLock Writer(&*FunctionsLock);
+ sys::ScopedLock Writer(*FunctionsLock);
ExFunc FnPtr = FuncNames[ExtName];
if (FnPtr == 0)
FnPtr = FuncNames["lle_X_"+F->getName()];
@@ -539,7 +539,7 @@ GenericValue lle_X_fprintf(const FunctionType *FT,
void Interpreter::initializeExternalFunctions() {
- sys::ScopedLock Writer(&*FunctionsLock);
+ sys::ScopedLock Writer(*FunctionsLock);
FuncNames["lle_X_atexit"] = lle_X_atexit;
FuncNames["lle_X_exit"] = lle_X_exit;
FuncNames["lle_X_abort"] = lle_X_abort;
diff --git a/lib/Support/Annotation.cpp b/lib/Support/Annotation.cpp
index 4b5b97e41f..9f76256b29 100644
--- a/lib/Support/Annotation.cpp
+++ b/lib/Support/Annotation.cpp
@@ -55,7 +55,7 @@ static FactMapType &getFactMap() {
}
static void eraseFromFactMap(unsigned ID) {
- sys::SmartScopedWriter<true> Writer(&*AnnotationsLock);
+ sys::SmartScopedWriter<true> Writer(*AnnotationsLock);
TheFactMap->erase(ID);
}
@@ -66,7 +66,7 @@ AnnotationID AnnotationManager::getID(const char *Name) { // Name -> ID
AnnotationsLock->reader_release();
if (I == E) {
- sys::SmartScopedWriter<true> Writer(&*AnnotationsLock);
+ sys::SmartScopedWriter<true> Writer(*AnnotationsLock);
I = IDMap->find(Name);
if (I == IDMap->end()) {
unsigned newCount = sys::AtomicIncrement(&IDCounter);
@@ -91,7 +91,7 @@ AnnotationID AnnotationManager::getID(const char *Name, Factory Fact,
// only be used for debugging.
//
const char *AnnotationManager::getName(AnnotationID ID) { // ID -> Name
- sys::SmartScopedReader<true> Reader(&*AnnotationsLock);
+ sys::SmartScopedReader<true> Reader(*AnnotationsLock);
IDMapType &TheMap = *IDMap;
for (IDMapType::iterator I = TheMap.begin(); ; ++I) {
assert(I != TheMap.end() && "Annotation ID is unknown!");
@@ -106,7 +106,7 @@ const char *AnnotationManager::getName(AnnotationID ID) { // ID -> Name
void AnnotationManager::registerAnnotationFactory(AnnotationID ID, AnnFactory F,
void *ExtraData) {
if (F) {
- sys::SmartScopedWriter<true> Writer(&*AnnotationsLock);
+ sys::SmartScopedWriter<true> Writer(*AnnotationsLock);
getFactMap()[ID.ID] = std::make_pair(F, ExtraData);
} else {
eraseFromFactMap(ID.ID);
diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp
index ef32af4b3f..ea191ad739 100644
--- a/lib/Support/PluginLoader.cpp
+++ b/lib/Support/PluginLoader.cpp
@@ -25,7 +25,7 @@ static ManagedStatic<std::vector<std::string> > Plugins;
static ManagedStatic<sys::SmartMutex<true> > PluginsLock;
void PluginLoader::operator=(const std::string &Filename) {
- sys::SmartScopedLock<true> Lock(&*PluginsLock);
+ sys::SmartScopedLock<true> Lock(*PluginsLock);
std::string Error;
if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) {
cerr << "Error opening '" << Filename << "': " << Error
@@ -36,12 +36,12 @@ void PluginLoader::operator=(const std::string &Filename) {
}
unsigned PluginLoader::getNumPlugins() {
- sys::SmartScopedLock<true> Lock(&*PluginsLock);
+ sys::SmartScopedLock<true> Lock(*PluginsLock);
return Plugins.isConstructed() ? Plugins->size() : 0;
}
std::string &PluginLoader::getPlugin(unsigned num) {
- sys::SmartScopedLock<true> Lock(&*PluginsLock);
+ sys::SmartScopedLock<true> Lock(*PluginsLock);
assert(Plugins.isConstructed() && num < Plugins->size() &&
"Asking for an out of bounds plugin");
return (*Plugins)[num];
diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp
index 33570b0ee5..06496fae91 100644
--- a/lib/Support/Statistic.cpp
+++ b/lib/Support/Statistic.cpp
@@ -65,7 +65,7 @@ static ManagedStatic<sys::Mutex> StatLock;
void Statistic::RegisterStatistic() {
// If stats are enabled, inform StatInfo that this statistic should be
// printed.
- sys::ScopedLock Writer(&*StatLock);
+ sys::ScopedLock Writer(*StatLock);
if (!Initialized) {
if (Enabled)
StatInfo->addStatistic(this);
diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp
index ede1dc96e8..8eef2bd48d 100644
--- a/lib/Support/Timer.cpp
+++ b/lib/Support/Timer.cpp
@@ -145,7 +145,7 @@ static TimeRecord getTimeRecord(bool Start) {
static ManagedStatic<std::vector<Timer*> > ActiveTimers;
void Timer::startTimer() {
- sys::SmartScopedLock<true> L(&Lock);
+ sys::SmartScopedLock<true> L(Lock);
Started = true;
ActiveTimers->push_back(this);
TimeRecord TR = getTimeRecord(true);
@@ -157,7 +157,7 @@ void Timer::startTimer() {
}
void Timer::stopTimer() {
- sys::SmartScopedLock<true> L(&Lock);
+ sys::SmartScopedLock<true> L(Lock);
TimeRecord TR = getTimeRecord(false);
Elapsed += TR.Elapsed;
UserTime += TR.UserTime;
@@ -229,7 +229,7 @@ static ManagedStatic<Name2Timer> NamedTimers;
static ManagedStatic<Name2Pair> NamedGroupedTimers;
static Timer &getNamedRegionTimer(const std::string &Name) {
- sys::SmartScopedLock<true> L(&*TimerLock);
+ sys::SmartScopedLock<true> L(*TimerLock);
Name2Timer::iterator I = NamedTimers->find(Name);
if (I != NamedTimers->end())
return I->second;
@@ -239,7 +239,7 @@ static Timer &getNamedRegionTimer(const std::string &Name) {
static Timer &getNamedRegionTimer(const std::string &Name,
const std::string &GroupName) {
- sys::SmartScopedLock<true> L(&*TimerLock);
+ sys::SmartScopedLock<true> L(*TimerLock);
Name2Pair::iterator I = NamedGroupedTimers->find(GroupName);
if (I == NamedGroupedTimers->end()) {
@@ -365,7 +365,7 @@ llvm::GetLibSupportInfoOutputFile() {
void TimerGroup::removeTimer() {
- sys::SmartScopedLock<true> L(&*TimerLock);
+ sys::SmartScopedLock<true> L(*TimerLock);
if (--NumTimers == 0 && !TimersToPrint.empty()) { // Print timing report...
// Sort the timers in descending order by amount of time taken...
std::sort(TimersToPrint.begin(), TimersToPrint.end(),
@@ -434,12 +434,12 @@ void TimerGroup::removeTimer() {
}
void TimerGroup::addTimer() {
- sys::SmartScopedLock<true> L(&*TimerLock);
+ sys::SmartScopedLock<true> L(*TimerLock);
++NumTimers;
}
void TimerGroup::addTimerToPrint(const Timer &T) {
- sys::SmartScopedLock<true> L(&*TimerLock);
+ sys::SmartScopedLock<true> L(*TimerLock);
TimersToPrint.push_back(Timer(true, T));
}
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp
index 7b843df742..7dfa057643 100644
--- a/lib/Target/TargetData.cpp
+++ b/lib/Target/TargetData.cpp
@@ -352,7 +352,7 @@ TargetData::~TargetData() {
if (!LayoutInfo.isConstructed())
return;
- sys::SmartScopedLock<true> Lock(&*LayoutLock);
+ sys::SmartScopedLock<true> Lock(*LayoutLock);
// Remove any layouts for this TD.
LayoutInfoTy &TheMap = *LayoutInfo;
for (LayoutInfoTy::iterator I = TheMap.begin(), E = TheMap.end(); I != E; ) {
@@ -369,7 +369,7 @@ TargetData::~TargetData() {
const StructLayout *TargetData::getStructLayout(const StructType *Ty) const {
LayoutInfoTy &TheMap = *LayoutInfo;
- sys::SmartScopedLock<true> Lock(&*LayoutLock);
+ sys::SmartScopedLock<true> Lock(*LayoutLock);
StructLayout *&SL = TheMap[LayoutKey(this, Ty)];
if (SL) return SL;
@@ -394,7 +394,7 @@ const StructLayout *TargetData::getStructLayout(const StructType *Ty) const {
void TargetData::InvalidateStructLayoutInfo(const StructType *Ty) const {
if (!LayoutInfo.isConstructed()) return; // No cache.
- sys::SmartScopedLock<true> Lock(&*LayoutLock);
+ sys::SmartScopedLock<true> Lock(*LayoutLock);
LayoutInfoTy::iterator I = LayoutInfo->find(LayoutKey(this, Ty));
if (I == LayoutInfo->end()) return;
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index a9e4e78ee1..a350031627 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -307,7 +307,7 @@ ConstantInt *ConstantInt::get(const APInt& V) {
ConstantsLock->reader_release();
if (!Slot) {
- sys::SmartScopedWriter<true> Writer(&*ConstantsLock);
+ sys::SmartScopedWriter<true> Writer(*ConstantsLock);
ConstantInt *&NewSlot = (*IntConstants)[Key];
if (!Slot) {
NewSlot = new ConstantInt(ITy, V);
@@ -414,7 +414,7 @@ ConstantFP *ConstantFP::get(const APFloat &V) {
ConstantsLock->reader_release();
if (!Slot) {
- sys::SmartScopedWriter<true> Writer(&*ConstantsLock);
+ sys::SmartScopedWriter<true> Writer(*ConstantsLock);
ConstantFP *&NewSlot = (*FPConstants)[Key];
if (!NewSlot) {
const Type *Ty;
@@ -1231,7 +1231,7 @@ public:
/// getOrCreate - Return the specified constant from the map, creating it if
/// necessary.
ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) {
- sys::SmartScopedLock<true> Lock(&ValueMapLock);
+ sys::SmartScopedLock<true> Lock(ValueMapLock);
MapKey Lookup(Ty, V);
ConstantClass* Result = 0;
@@ -1249,7 +1249,7 @@ public:
}
void remove(ConstantClass *CP) {
- sys::SmartScopedLock<true> Lock(&ValueMapLock);
+ sys::SmartScopedLock<true> Lock(ValueMapLock);
typename MapTy::iterator I = FindExistingElement(CP);
assert(I != Map.end() && "Constant not found in constant table!");
assert(I->second == CP && "Didn't find correct element?");
@@ -1334,7 +1334,7 @@ public:
}
void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
- sys::SmartScopedLock<true> Lock(&ValueMapLock);
+ sys::SmartScopedLock<true> Lock(ValueMapLock);
typename AbstractTypeMapTy::iterator I =
AbstractTypeMap.find(cast<Type>(OldTy));
@@ -1793,7 +1793,7 @@ MDString::MDString(const char *begin, const char *end)
static ManagedStatic<StringMap<MDString*> > MDStringCache;
MDString *MDString::get(const char *StrBegin, const char *StrEnd) {
- sys::SmartScopedWriter<true> Writer(&*ConstantsLock);
+ sys::SmartScopedWriter<true> Writer(*ConstantsLock);
StringMapEntry<MDString *> &Entry = MDStringCache->GetOrCreateValue(
StrBegin, StrEnd);
MDString *&S = Entry.getValue();
@@ -1804,7 +1804,7 @@ MDString *MDString::get(const char *StrBegin, const char *StrEnd) {
}
MDString *MDString::get(const std::string &Str) {
- sys::SmartScopedWriter<true> Writer(&*ConstantsLock);
+ sys::SmartScopedWriter<true> Writer(*ConstantsLock);
StringMapEntry<MDString *> &Entry = MDStringCache->GetOrCreateValue(
Str.data(), Str.data() + Str.size());
MDString *&S = Entry.getValue();
@@ -1815,7 +1815,7 @@ MDString *MDString::get(const std::string &Str) {
}
void MDString::destroyConstant() {
- sys::SmartScopedWriter<true> Writer(&*ConstantsLock);
+ sys::SmartScopedWriter<true> Writer(*ConstantsLock);
MDStringCache->erase(MDStringCache->find(StrBegin, StrEnd));
destroyConstantImpl();
}
@@ -1847,7 +1847,7 @@ MDNode *MDNode::get(Value*const* Vals, unsigned NumVals) {
ConstantsLock->reader_release();
if (!N) {
- sys::SmartScopedWriter<true> Writer(&*ConstantsLock);
+ sys::SmartScopedWriter<true> Writer(*ConstantsLock);
N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint);
if (!N) {
// InsertPoint will have been set by the FindNodeOrInsertPos call.
@@ -1859,7 +1859,7 @@ MDNode *MDNode::get(Value*const* Vals, unsigned NumVals) {
}
void MDNode::destroyConstant() {
- sys::SmartScopedWriter<true> Writer(&*ConstantsLock);
+ sys::SmartScopedWriter<true> Writer(*ConstantsLock);
MDNodeSet->RemoveNode(this);
destroyConstantImpl();
@@ -2790,7 +2790,7 @@ void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To,
Replacement = ConstantAggregateZero::get(getType());
} else {
// Check to see if we have this array type already.
- sys::SmartScopedWriter<true> Writer(&*ConstantsLock);
+ sys::SmartScopedWriter<true> Writer(*ConstantsLock);
bool Exists;
ArrayConstantsTy::MapTy::iterator I =
ArrayConstants->InsertOrGetItem(Lookup, Exists);
@@ -2866,7 +2866,7 @@ void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To,
Replacement = ConstantAggregateZero::get(getType());
} else {
// Check to see if we have this array type already.
- sys::SmartScopedWriter<true> Writer(&*ConstantsLock);
+ sys::SmartScopedWriter<true> Writer(*ConstantsLock);
bool Exists;
StructConstantsTy::MapTy::iterator I =
StructConstants->InsertOrGetItem(Lookup, Exists);
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index a259335016..08acc5fec7 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -242,18 +242,18 @@ static StringPool *GCNamePool;
static ManagedStatic<sys::SmartRWMutex<true> > GCLock;
bool Function::hasGC() const {
- sys::SmartScopedReader<true> Reader(&*GCLock);
+ 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);
+ sys::SmartScopedReader<true> Reader(*GCLock);
return *(*GCNames)[this];
}
void Function::setGC(const char *Str) {
- sys::SmartScopedWriter<true> Writer(&*GCLock);
+ sys::SmartScopedWriter<true> Writer(*GCLock);
if (!GCNamePool)
GCNamePool = new StringPool();
if (!GCNames)
@@ -262,7 +262,7 @@ void Function::setGC(const char *Str) {
}
void Function::clearGC() {
- sys::SmartScopedWriter<true> Writer(&*GCLock);
+ sys::SmartScopedWriter<true> Writer(*GCLock);
if (GCNames) {
GCNames->erase(this);
if (GCNames->empty()) {
diff --git a/lib/VMCore/LeakDetector.cpp b/lib/VMCore/LeakDetector.cpp
index b5926bcf44..a6be1afed4 100644
--- a/lib/VMCore/LeakDetector.cpp
+++ b/lib/VMCore/LeakDetector.cpp
@@ -54,7 +54,7 @@ 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) {
- sys::SmartScopedWriter<true> Writer(&*LeakDetectorLock);
+ sys::SmartScopedWriter<true> Writer(*LeakDetectorLock);
if (Cache) {
assert(Ts.count(Cache) == 0 && "Object already in set!");
Ts.insert(Cache);
@@ -63,7 +63,7 @@ namespace {
}
void removeGarbage(const T* o) {
- sys::SmartScopedWriter<true> Writer(&*LeakDetectorLock);
+ sys::SmartScopedWriter<true> Writer(*LeakDetectorLock);
if (o == Cache)
Cache = 0; // Cache hit
else
@@ -73,7 +73,7 @@ namespace {
bool hasGarbage(const std::string& Message) {
addGarbage(0); // Flush the Cache
- sys::SmartScopedReader<true> Reader(&*LeakDetectorLock);
+ sys::SmartScopedReader<true> Reader(*LeakDetectorLock);
assert(Cache == 0 && "No value should be cached anymore!");
if (!Ts.empty()) {
diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp
index b037994d42..d82389d99d 100644
--- a/lib/VMCore/Pass.cpp
+++ b/lib/VMCore/Pass.cpp
@@ -233,7 +233,7 @@ void PassInfo::registerPass() {
getPassRegistrar()->RegisterPass(*this);
// Notify any listeners.
- sys::SmartScopedLock<true> Lock(&ListenersLock);
+ sys::SmartScopedLock<true> Lock(ListenersLock);
if (Listeners)
for (std::vector<PassRegistrationListener*>::iterator
I = Listeners->begin(), E = Listeners->end(); I != E; ++I)
@@ -286,14 +286,14 @@ RegisterAGBase::RegisterAGBase(const char *Name, intptr_t InterfaceID,
// PassRegistrationListener ctor - Add the current object to the list of
// PassRegistrationListeners...
PassRegistrationListener::PassRegistrationListener() {
- sys::SmartScopedLock<true> Lock(&ListenersLock);
+ sys::SmartScopedLock<true> Lock(ListenersLock);
if (!Listeners) Listeners = new std::vector<PassRegistrationListener*>();
Listeners->push_back(this);
}
// dtor - Remove object from list of listeners...
PassRegistrationListener::~PassRegistrationListener() {
- sys::SmartScopedLock<true> Lock(&ListenersLock);
+ sys::SmartScopedLock<true> Lock(ListenersLock);
std::vector<PassRegistrationListener*>::iterator I =
std::find(Listeners->begin(), Listeners->end(), this);
assert(Listeners && I != Listeners->end() &&
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp
index 46f1243e12..74c09fd865 100644
--- a/lib/VMCore/PassManager.cpp
+++ b/lib/VMCore/PassManager.cpp
@@ -392,7 +392,7 @@ public:
if (dynamic_cast<PMDataManager *>(P))
return;
- sys::SmartScopedLock<true> Lock(&*TimingInfoMutex);
+ sys::SmartScopedLock<true> Lock(*TimingInfoMutex);
std::map<Pass*, Timer>::iterator I = TimingData.find(P);
if (I == TimingData.end())
I=TimingData.insert(std::make_pair(P, Timer(P->getPassName(), TG))).first;
@@ -403,7 +403,7 @@ public:
if (dynamic_cast<PMDataManager *>(P))
return;
- sys::SmartScopedLock<true> Lock(&*TimingInfoMutex);
+ sys::SmartScopedLock<true> Lock(*TimingInfoMutex);
std::map<Pass*, Timer>::iterator I = TimingData.find(P);
assert(I != TimingData.end() && "passStarted/passEnded not nested right!");
I->second.stopTimer();
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp
index 40d7517049..b415251497 100644
--- a/lib/VMCore/Type.cpp
+++ b/lib/VMCore/Type.cpp
@@ -1006,7 +1006,7 @@ const IntegerType *IntegerType::get(unsigned NumBits) {
// First, see if the type is already in the table, for which
// a reader lock suffices.
- sys::SmartScopedLock<true> L(&*TypeMapLock);
+ sys::SmartScopedLock<true> L(*TypeMapLock);
ITy = IntegerTypes->get(IVT);
if (!ITy) {
@@ -1079,7 +1079,7 @@ FunctionType *FunctionType::get(const Type *ReturnType,
FunctionValType VT(ReturnType, Params, isVarArg);
FunctionType *FT = 0;
- sys::SmartScopedLock<true> L(&*TypeMapLock);
+ sys::SmartScopedLock<true> L(*TypeMapLock);
FT = FunctionTypes->get(VT);
if (!FT) {
@@ -1129,7 +1129,7 @@ ArrayType *ArrayType::get(const Type *ElementType, uint64_t NumElements) {
ArrayValType AVT(ElementType, NumElements);
ArrayType *AT = 0;
- sys::SmartScopedLock<true> L(&*TypeMapLock);
+ sys::SmartScopedLock<true> L(*TypeMapLock);
AT = ArrayTypes->get(AVT);
if (!AT) {
@@ -1188,7 +1188,7 @@ VectorType *VectorType::get(const Type *ElementType, unsigned NumElements) {
VectorValType PVT(ElementType, NumElements);
VectorType *PT = 0;
- sys::SmartScopedLock<true> L(&*TypeMapLock);
+ sys::SmartScopedLock<true> L(*TypeMapLock);
PT = VectorTypes->get(PVT);
if (!PT) {
@@ -1250,7 +1250,7 @@ StructType *StructType::get(const std::vector<const Type*> &ETypes,
StructValType STV(ETypes, isPacked);
StructType *ST = 0;
- sys::SmartScopedLock<true> L(&*TypeMapLock);
+ sys::SmartScopedLock<true> L(*TypeMapLock);
ST = StructTypes->get(STV);
if (!ST) {
@@ -1329,7 +1329,7 @@ PointerType *PointerType::get(const Type *ValueType, unsigned AddressSpace) {
PointerType *PT = 0;
- sys::SmartScopedLock<true> L(&*TypeMapLock);
+ sys::SmartScopedLock<true> L(*TypeMapLock);
PT = PointerTypes->get(PVT);
if (!PT) {
@@ -1488,7 +1488,7 @@ void DerivedType::unlockedRefineAbstractTypeTo(const Type *NewType) {
void DerivedType::refineAbstractTypeTo(const Type *NewType) {
// All recursive calls will go through unlockedRefineAbstractTypeTo,
// to avoid deadlock problems.
- sys::SmartScopedLock<true> L(&*TypeMapLock);
+ sys::SmartScopedLock<true> L(*TypeMapLock);
unlockedRefineAbstractTypeTo(NewType);
}
diff --git a/lib/VMCore/TypeSymbolTable.cpp b/lib/VMCore/TypeSymbolTable.cpp
index 5ae60e28d7..54da809963 100644
--- a/lib/VMCore/TypeSymbolTable.cpp
+++ b/lib/VMCore/TypeSymbolTable.cpp
@@ -37,7 +37,7 @@ TypeSymbolTable::~TypeSymbolTable() {
std::string TypeSymbolTable::getUniqueName(const std::string &BaseName) const {
std::string TryName = BaseName;
- sys::SmartScopedReader<true> Reader(&*TypeSymbolTableLock);
+ sys::SmartScopedReader<true> Reader(*TypeSymbolTableLock);
const_iterator End = tmap.end();
@@ -49,7 +49,7 @@ std::string TypeSymbolTable::getUniqueName(const std::string &BaseName) const {
// lookup a type by name - returns null on failure
Type* TypeSymbolTable::lookup(const std::string& Name) const {
- sys::SmartScopedReader<true> Reader(&*TypeSymbolTableLock);
+ sys::SmartScopedReader<true> Reader(*TypeSymbolTableLock);
const_iterator TI = tmap.find(Name);
Type* result = 0;
@@ -134,7 +134,7 @@ void TypeSymbolTable::insert(const std::string& Name, const Type* T) {
// This function is called when one of the types in the type plane are refined
void TypeSymbolTable::refineAbstractType(const DerivedType *OldType,
const Type *NewType) {
- sys::SmartScopedReader<true> Reader(&*TypeSymbolTableLock);
+ sys::SmartScopedReader<true> Reader(*TypeSymbolTableLock);
// Loop over all of the types in the symbol table, replacing any references
// to OldType with references to NewType. Note that there may be multiple
@@ -165,7 +165,7 @@ void TypeSymbolTable::typeBecameConcrete(const DerivedType *AbsTy) {
// Loop over all of the types in the symbol table, dropping any abstract
// type user entries for AbsTy which occur because there are names for the
// type.
- sys::SmartScopedReader<true> Reader(&*TypeSymbolTableLock);
+ sys::SmartScopedReader<true> Reader(*TypeSymbolTableLock);
for (iterator TI = begin(), TE = end(); TI != TE; ++TI)
if (TI->second == const_cast<Type*>(static_cast<const Type*>(AbsTy)))
AbsTy->removeAbstractTypeUser(this);
@@ -179,7 +179,7 @@ static void DumpTypes(const std::pair<const std::string, const Type*>& T ) {
void TypeSymbolTable::dump() const {
cerr << "TypeSymbolPlane: ";
- sys::SmartScopedReader<true> Reader(&*TypeSymbolTableLock);
+ sys::SmartScopedReader<true> Reader(*TypeSymbolTableLock);
for_each(tmap.begin(), tmap.end(), DumpTypes);
}
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp
index c952b7888c..e980a5d0ff 100644
--- a/lib/VMCore/Value.cpp
+++ b/lib/VMCore/Value.cpp
@@ -430,7 +430,7 @@ void ValueHandleBase::AddToUseList() {
if (VP->HasValueHandle) {
// If this value already has a ValueHandle, then it must be in the
// ValueHandles map already.
- sys::SmartScopedReader<true> Reader(&*ValueHandlesLock);
+ sys::SmartScopedReader<true> Reader(*ValueHandlesLock);
ValueHandleBase *&Entry = (*ValueHandles)[VP];
assert(Entry != 0 && "Value doesn't have any handles?");
AddToExistingUseList(&Entry);
@@ -442,7 +442,7 @@ void ValueHandleBase::AddToUseList() {
// reallocate itself, which would invalidate all of the PrevP pointers that
// point into the old table. Handle this by checking for reallocation and
// updating the stale pointers only if needed.
- sys::SmartScopedWriter<true> Writer(&*ValueHandlesLock);
+ sys::SmartScopedWriter<true> Writer(*ValueHandlesLock);
ValueHandlesTy &Handles = *ValueHandles;
const void *OldBucketPtr = Handles.getPointerIntoBucketsArray();
@@ -484,7 +484,7 @@ void ValueHandleBase::RemoveFromUseList() {
// If the Next pointer was null, then it is possible that this was the last
// ValueHandle watching VP. If so, delete its entry from the ValueHandles
// map.
- sys::SmartScopedWriter<true> Writer(&*ValueHandlesLock);
+ sys::SmartScopedWriter<true> Writer(*ValueHandlesLock);
ValueHandlesTy &Handles = *ValueHandles;
if (Handles.isPointerIntoBucketsArray(PrevPtr)) {
Handles.erase(VP);