Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -37,7 +37,6 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" -#include "llvm/Support/Mutex.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetIntrinsicInfo.h" @@ -48,6 +47,7 @@ #include "llvm/Target/TargetSelectionDAGInfo.h" #include #include +#include using namespace llvm; @@ -6169,13 +6169,13 @@ static ManagedStatic > EVTs; static ManagedStatic SimpleVTArray; -static ManagedStatic > VTMutex; +static ManagedStatic VTMutex; /// getValueTypeList - Return a pointer to the specified value type. /// const EVT *SDNode::getValueTypeList(EVT VT) { if (VT.isExtended()) { - sys::SmartScopedLock Lock(*VTMutex); + std::lock_guard Lock(*VTMutex); return &(*EVTs->insert(VT).first); } else { assert(VT.getSimpleVT() < MVT::LAST_VALUETYPE && Index: lib/IR/LeakDetector.cpp =================================================================== --- lib/IR/LeakDetector.cpp +++ lib/IR/LeakDetector.cpp @@ -17,11 +17,11 @@ #include "llvm/IR/Value.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/Mutex.h" #include "llvm/Support/Threading.h" +#include using namespace llvm; -static ManagedStatic > ObjectsLock; +static ManagedStatic ObjectsLock; static ManagedStatic > Objects; static void clearGarbage(LLVMContext &Context) { @@ -30,7 +30,7 @@ } void LeakDetector::addGarbageObjectImpl(void *Object) { - sys::SmartScopedLock Lock(*ObjectsLock); + std::lock_guard Lock(*ObjectsLock); Objects->addGarbage(Object); } @@ -40,7 +40,7 @@ } void LeakDetector::removeGarbageObjectImpl(void *Object) { - sys::SmartScopedLock Lock(*ObjectsLock); + std::lock_guard Lock(*ObjectsLock); Objects->removeGarbage(Object); } @@ -52,7 +52,7 @@ void LeakDetector::checkForGarbageImpl(LLVMContext &Context, const std::string &Message) { LLVMContextImpl *pImpl = Context.pImpl; - sys::SmartScopedLock Lock(*ObjectsLock); + std::lock_guard Lock(*ObjectsLock); Objects->setName("GENERIC"); pImpl->LLVMObjects.setName("LLVM"); Index: lib/IR/LegacyPassManager.cpp =================================================================== --- lib/IR/LegacyPassManager.cpp +++ lib/IR/LegacyPassManager.cpp @@ -22,12 +22,12 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/Mutex.h" #include "llvm/Support/TimeValue.h" #include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" #include #include +#include using namespace llvm; using namespace llvm::legacy; @@ -459,7 +459,7 @@ /// -time-passes is enabled on the command line. /// -static ManagedStatic > TimingInfoMutex; +static ManagedStatic TimingInfoMutex; class TimingInfo { DenseMap TimingData; @@ -488,7 +488,7 @@ if (P->getAsPMDataManager()) return nullptr; - sys::SmartScopedLock Lock(*TimingInfoMutex); + std::lock_guard Lock(*TimingInfoMutex); Timer *&T = TimingData[P]; if (!T) T = new Timer(P->getPassName(), TG); Index: lib/Support/DynamicLibrary.cpp =================================================================== --- lib/Support/DynamicLibrary.cpp +++ lib/Support/DynamicLibrary.cpp @@ -19,17 +19,17 @@ #include "llvm/ADT/StringMap.h" #include "llvm/Config/config.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/Mutex.h" #include #include +#include // Collection of symbol name/value pairs to be searched prior to any libraries. static llvm::ManagedStatic > ExplicitSymbols; -static llvm::ManagedStatic > SymbolsMutex; +static llvm::ManagedStatic SymbolsMutex; void llvm::sys::DynamicLibrary::AddSymbol(StringRef symbolName, void *symbolValue) { - SmartScopedLock lock(*SymbolsMutex); + std::lock_guard Lock(*SymbolsMutex); (*ExplicitSymbols)[symbolName] = symbolValue; } @@ -55,7 +55,7 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename, std::string *errMsg) { - SmartScopedLock lock(*SymbolsMutex); + std::lock_guard Lock(*SymbolsMutex); void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL); if (!handle) { @@ -109,7 +109,7 @@ } void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) { - SmartScopedLock Lock(*SymbolsMutex); + std::lock_guard Lock(*SymbolsMutex); // First check symbols added via AddSymbol(). if (ExplicitSymbols.isConstructed()) { Index: lib/Support/PluginLoader.cpp =================================================================== --- lib/Support/PluginLoader.cpp +++ lib/Support/PluginLoader.cpp @@ -15,16 +15,16 @@ #include "llvm/Support/PluginLoader.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/Mutex.h" #include "llvm/Support/raw_ostream.h" +#include #include using namespace llvm; static ManagedStatic > Plugins; -static ManagedStatic > PluginsLock; +static ManagedStatic PluginsLock; void PluginLoader::operator=(const std::string &Filename) { - sys::SmartScopedLock Lock(*PluginsLock); + std::lock_guard Lock(*PluginsLock); std::string Error; if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) { errs() << "Error opening '" << Filename << "': " << Error @@ -35,12 +35,12 @@ } unsigned PluginLoader::getNumPlugins() { - sys::SmartScopedLock Lock(*PluginsLock); + std::lock_guard Lock(*PluginsLock); return Plugins.isConstructed() ? Plugins->size() : 0; } std::string &PluginLoader::getPlugin(unsigned num) { - sys::SmartScopedLock Lock(*PluginsLock); + std::lock_guard Lock(*PluginsLock); assert(Plugins.isConstructed() && num < Plugins->size() && "Asking for an out of bounds plugin"); return (*Plugins)[num]; Index: lib/Support/Statistic.cpp =================================================================== --- lib/Support/Statistic.cpp +++ lib/Support/Statistic.cpp @@ -27,10 +27,10 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/Format.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/Mutex.h" #include "llvm/Support/raw_ostream.h" #include #include +#include using namespace llvm; // CreateInfoOutputFile - Return a file stream to print our output on. @@ -63,14 +63,14 @@ } static ManagedStatic StatInfo; -static ManagedStatic > StatLock; +static ManagedStatic StatLock; /// RegisterStatistic - The first time a statistic is bumped, this method is /// called. void Statistic::RegisterStatistic() { // If stats are enabled, inform StatInfo that this statistic should be // printed. - sys::SmartScopedLock Writer(*StatLock); + std::lock_guard Writer(*StatLock); if (!Initialized) { if (Enabled) StatInfo->addStatistic(this); Index: lib/Support/Timer.cpp =================================================================== --- lib/Support/Timer.cpp +++ lib/Support/Timer.cpp @@ -18,9 +18,9 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Format.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/Mutex.h" #include "llvm/Support/Process.h" #include "llvm/Support/raw_ostream.h" +#include using namespace llvm; // CreateInfoOutputFile - Return a file stream to print our output on. @@ -39,7 +39,7 @@ return *LibSupportInfoOutputFilename; } -static ManagedStatic > TimerLock; +static ManagedStatic TimerLock; namespace { static cl::opt @@ -206,7 +206,7 @@ } Timer &get(StringRef Name, StringRef GroupName) { - sys::SmartScopedLock L(*TimerLock); + std::lock_guard Lock(*TimerLock); std::pair &GroupEntry = Map[GroupName]; @@ -226,7 +226,7 @@ static ManagedStatic NamedGroupedTimers; static Timer &getNamedRegionTimer(StringRef Name) { - sys::SmartScopedLock L(*TimerLock); + std::lock_guard Lock(*TimerLock); Timer &T = (*NamedTimers)[Name]; if (!T.isInitialized()) @@ -254,7 +254,7 @@ : Name(name.begin(), name.end()), FirstTimer(nullptr) { // Add the group to TimerGroupList. - sys::SmartScopedLock L(*TimerLock); + std::lock_guard L(*TimerLock); if (TimerGroupList) TimerGroupList->Prev = &Next; Next = TimerGroupList; @@ -269,7 +269,7 @@ removeTimer(*FirstTimer); // Remove the group from the TimerGroupList. - sys::SmartScopedLock L(*TimerLock); + std::lock_guard L(*TimerLock); *Prev = Next; if (Next) Next->Prev = Prev; @@ -277,7 +277,7 @@ void TimerGroup::removeTimer(Timer &T) { - sys::SmartScopedLock L(*TimerLock); + std::lock_guard L(*TimerLock); // If the timer was started, move its data to TimersToPrint. if (T.Started) @@ -301,7 +301,7 @@ } void TimerGroup::addTimer(Timer &T) { - sys::SmartScopedLock L(*TimerLock); + std::lock_guard L(*TimerLock); // Add the timer to our list. if (FirstTimer) @@ -362,7 +362,7 @@ /// print - Print any started timers in this group and zero them. void TimerGroup::print(raw_ostream &OS) { - sys::SmartScopedLock L(*TimerLock); + std::lock_guard L(*TimerLock); // See if any of our timers were started, if so add them to TimersToPrint and // reset them. @@ -382,7 +382,7 @@ /// printAll - This static method prints all timers and clears them all out. void TimerGroup::printAll(raw_ostream &OS) { - sys::SmartScopedLock L(*TimerLock); + std::lock_guard L(*TimerLock); for (TimerGroup *TG = TimerGroupList; TG; TG = TG->Next) TG->print(OS); Index: lib/Support/Windows/DynamicLibrary.inc =================================================================== --- lib/Support/Windows/DynamicLibrary.inc +++ lib/Support/Windows/DynamicLibrary.inc @@ -71,7 +71,7 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename, std::string *errMsg) { - SmartScopedLock lock(*SymbolsMutex); + std::lock_guard Lock(*SymbolsMutex); if (!filename) { // When no file is specified, enumerate all DLLs and EXEs in the process. @@ -121,7 +121,7 @@ #undef EXPLICIT_SYMBOL2 void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { - SmartScopedLock Lock(*SymbolsMutex); + std::lock_guard Lock(*SymbolsMutex); // First check symbols added via AddSymbol(). if (ExplicitSymbols.isConstructed()) {