[llvm] r368149 - Replace llvm::MutexGuard/UniqueLock with their standard equivalents
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 7 03:57:25 PDT 2019
Author: d0k
Date: Wed Aug 7 03:57:25 2019
New Revision: 368149
URL: http://llvm.org/viewvc/llvm-project?rev=368149&view=rev
Log:
Replace llvm::MutexGuard/UniqueLock with their standard equivalents
All supported platforms have <mutex> now, so we don't need our own
copies any longer. No functionality change intended.
Removed:
llvm/trunk/include/llvm/Support/MutexGuard.h
llvm/trunk/include/llvm/Support/UniqueLock.h
Modified:
llvm/trunk/include/llvm/IR/ValueMap.h
llvm/trunk/include/llvm/Support/UnicodeCharRanges.h
llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
llvm/trunk/lib/ExecutionEngine/GDBRegistrationListener.cpp
llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
llvm/trunk/lib/ExecutionEngine/OProfileJIT/OProfileWrapper.cpp
llvm/trunk/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
llvm/trunk/lib/Support/ManagedStatic.cpp
llvm/trunk/lib/Support/Unix/Process.inc
llvm/trunk/lib/Support/Unix/Signals.inc
llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp
Modified: llvm/trunk/include/llvm/IR/ValueMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/ValueMap.h?rev=368149&r1=368148&r2=368149&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/ValueMap.h (original)
+++ llvm/trunk/include/llvm/IR/ValueMap.h Wed Aug 7 03:57:25 2019
@@ -33,11 +33,11 @@
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Mutex.h"
-#include "llvm/Support/UniqueLock.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <iterator>
+#include <mutex>
#include <type_traits>
#include <utility>
@@ -266,9 +266,9 @@ public:
// Make a copy that won't get changed even when *this is destroyed.
ValueMapCallbackVH Copy(*this);
typename Config::mutex_type *M = Config::getMutex(Copy.Map->Data);
- unique_lock<typename Config::mutex_type> Guard;
+ std::unique_lock<typename Config::mutex_type> Guard;
if (M)
- Guard = unique_lock<typename Config::mutex_type>(*M);
+ Guard = std::unique_lock<typename Config::mutex_type>(*M);
Config::onDelete(Copy.Map->Data, Copy.Unwrap()); // May destroy *this.
Copy.Map->Map.erase(Copy); // Definitely destroys *this.
}
@@ -279,9 +279,9 @@ public:
// Make a copy that won't get changed even when *this is destroyed.
ValueMapCallbackVH Copy(*this);
typename Config::mutex_type *M = Config::getMutex(Copy.Map->Data);
- unique_lock<typename Config::mutex_type> Guard;
+ std::unique_lock<typename Config::mutex_type> Guard;
if (M)
- Guard = unique_lock<typename Config::mutex_type>(*M);
+ Guard = std::unique_lock<typename Config::mutex_type>(*M);
KeyT typed_new_key = cast<KeySansPointerT>(new_key);
// Can destroy *this:
Removed: llvm/trunk/include/llvm/Support/MutexGuard.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MutexGuard.h?rev=368148&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Support/MutexGuard.h (original)
+++ llvm/trunk/include/llvm/Support/MutexGuard.h (removed)
@@ -1,40 +0,0 @@
-//===-- Support/MutexGuard.h - Acquire/Release Mutex In Scope ---*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines a guard for a block of code that ensures a Mutex is locked
-// upon construction and released upon destruction.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_MUTEXGUARD_H
-#define LLVM_SUPPORT_MUTEXGUARD_H
-
-#include "llvm/Support/Mutex.h"
-
-namespace llvm {
- /// Instances of this class acquire a given Mutex Lock when constructed and
- /// hold that lock until destruction. The intention is to instantiate one of
- /// these on the stack at the top of some scope to be assured that C++
- /// destruction of the object will always release the Mutex and thus avoid
- /// a host of nasty multi-threading problems in the face of exceptions, etc.
- /// Guard a section of code with a Mutex.
- class MutexGuard {
- sys::Mutex &M;
- MutexGuard(const MutexGuard &) = delete;
- void operator=(const MutexGuard &) = delete;
- public:
- MutexGuard(sys::Mutex &m) : M(m) { M.lock(); }
- ~MutexGuard() { M.unlock(); }
- /// holds - Returns true if this locker instance holds the specified lock.
- /// This is mostly used in assertions to validate that the correct mutex
- /// is held.
- bool holds(const sys::Mutex& lock) const { return &M == &lock; }
- };
-}
-
-#endif // LLVM_SUPPORT_MUTEXGUARD_H
Modified: llvm/trunk/include/llvm/Support/UnicodeCharRanges.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/UnicodeCharRanges.h?rev=368149&r1=368148&r2=368149&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/UnicodeCharRanges.h (original)
+++ llvm/trunk/include/llvm/Support/UnicodeCharRanges.h Wed Aug 7 03:57:25 2019
@@ -9,11 +9,8 @@
#define LLVM_SUPPORT_UNICODECHARRANGES_H
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
-#include "llvm/Support/Mutex.h"
-#include "llvm/Support/MutexGuard.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
Removed: llvm/trunk/include/llvm/Support/UniqueLock.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/UniqueLock.h?rev=368148&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Support/UniqueLock.h (original)
+++ llvm/trunk/include/llvm/Support/UniqueLock.h (removed)
@@ -1,68 +0,0 @@
-//===- Support/UniqueLock.h - Acquire/Release Mutex In Scope ----*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines a guard for a block of code that ensures a Mutex is locked
-// upon construction and released upon destruction.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_UNIQUE_LOCK_H
-#define LLVM_SUPPORT_UNIQUE_LOCK_H
-
-#include <cassert>
-
-namespace llvm {
-
- /// A pared-down imitation of std::unique_lock from C++11. Contrary to the
- /// name, it's really more of a wrapper for a lock. It may or may not have
- /// an associated mutex, which is guaranteed to be locked upon creation
- /// and unlocked after destruction. unique_lock can also unlock the mutex
- /// and re-lock it freely during its lifetime.
- /// Guard a section of code with a mutex.
- template<typename MutexT>
- class unique_lock {
- MutexT *M = nullptr;
- bool locked = false;
-
- public:
- unique_lock() = default;
- explicit unique_lock(MutexT &m) : M(&m), locked(true) { M->lock(); }
- unique_lock(const unique_lock &) = delete;
- unique_lock &operator=(const unique_lock &) = delete;
-
- void operator=(unique_lock &&o) {
- if (owns_lock())
- M->unlock();
- M = o.M;
- locked = o.locked;
- o.M = nullptr;
- o.locked = false;
- }
-
- ~unique_lock() { if (owns_lock()) M->unlock(); }
-
- void lock() {
- assert(!locked && "mutex already locked!");
- assert(M && "no associated mutex!");
- M->lock();
- locked = true;
- }
-
- void unlock() {
- assert(locked && "unlocking a mutex that isn't locked!");
- assert(M && "no associated mutex!");
- M->unlock();
- locked = false;
- }
-
- bool owns_lock() { return locked; }
- };
-
-} // end namespace llvm
-
-#endif // LLVM_SUPPORT_UNIQUE_LOCK_H
Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=368149&r1=368148&r2=368149&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Wed Aug 7 03:57:25 2019
@@ -32,12 +32,12 @@
#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Host.h"
-#include "llvm/Support/MutexGuard.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include <cmath>
#include <cstring>
+#include <mutex>
using namespace llvm;
#define DEBUG_TYPE "jit"
@@ -191,7 +191,7 @@ uint64_t ExecutionEngineState::RemoveMap
std::string ExecutionEngine::getMangledName(const GlobalValue *GV) {
assert(GV->hasName() && "Global must have name.");
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
SmallString<128> FullName;
const DataLayout &DL =
@@ -204,12 +204,12 @@ std::string ExecutionEngine::getMangledN
}
void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
addGlobalMapping(getMangledName(GV), (uint64_t) Addr);
}
void ExecutionEngine::addGlobalMapping(StringRef Name, uint64_t Addr) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
assert(!Name.empty() && "Empty GlobalMapping symbol name!");
@@ -228,14 +228,14 @@ void ExecutionEngine::addGlobalMapping(S
}
void ExecutionEngine::clearAllGlobalMappings() {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
EEState.getGlobalAddressMap().clear();
EEState.getGlobalAddressReverseMap().clear();
}
void ExecutionEngine::clearGlobalMappingsFromModule(Module *M) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
for (GlobalObject &GO : M->global_objects())
EEState.RemoveMapping(getMangledName(&GO));
@@ -243,12 +243,12 @@ void ExecutionEngine::clearGlobalMapping
uint64_t ExecutionEngine::updateGlobalMapping(const GlobalValue *GV,
void *Addr) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
return updateGlobalMapping(getMangledName(GV), (uint64_t) Addr);
}
uint64_t ExecutionEngine::updateGlobalMapping(StringRef Name, uint64_t Addr) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
ExecutionEngineState::GlobalAddressMapTy &Map =
EEState.getGlobalAddressMap();
@@ -275,7 +275,7 @@ uint64_t ExecutionEngine::updateGlobalMa
}
uint64_t ExecutionEngine::getAddressToGlobalIfAvailable(StringRef S) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
uint64_t Address = 0;
ExecutionEngineState::GlobalAddressMapTy::iterator I =
EEState.getGlobalAddressMap().find(S);
@@ -286,19 +286,19 @@ uint64_t ExecutionEngine::getAddressToGl
void *ExecutionEngine::getPointerToGlobalIfAvailable(StringRef S) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
if (void* Address = (void *) getAddressToGlobalIfAvailable(S))
return Address;
return nullptr;
}
void *ExecutionEngine::getPointerToGlobalIfAvailable(const GlobalValue *GV) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
return getPointerToGlobalIfAvailable(getMangledName(GV));
}
const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
// If we haven't computed the reverse mapping yet, do so first.
if (EEState.getGlobalAddressReverseMap().empty()) {
@@ -575,7 +575,7 @@ void *ExecutionEngine::getPointerToGloba
if (Function *F = const_cast<Function*>(dyn_cast<Function>(GV)))
return getPointerToFunction(F);
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
if (void* P = getPointerToGlobalIfAvailable(GV))
return P;
Modified: llvm/trunk/lib/ExecutionEngine/GDBRegistrationListener.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/GDBRegistrationListener.cpp?rev=368149&r1=368148&r2=368149&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/GDBRegistrationListener.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/GDBRegistrationListener.cpp Wed Aug 7 03:57:25 2019
@@ -14,7 +14,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Mutex.h"
-#include "llvm/Support/MutexGuard.h"
+#include <mutex>
using namespace llvm;
using namespace llvm::object;
@@ -135,7 +135,7 @@ void NotifyDebugger(jit_code_entry* JITC
GDBJITRegistrationListener::~GDBJITRegistrationListener() {
// Free all registered object files.
- llvm::MutexGuard locked(*JITDebugLock);
+ std::lock_guard<llvm::sys::Mutex> locked(*JITDebugLock);
for (RegisteredObjectBufferMap::iterator I = ObjectBufferMap.begin(),
E = ObjectBufferMap.end();
I != E; ++I) {
@@ -159,7 +159,7 @@ void GDBJITRegistrationListener::notifyO
const char *Buffer = DebugObj.getBinary()->getMemoryBufferRef().getBufferStart();
size_t Size = DebugObj.getBinary()->getMemoryBufferRef().getBufferSize();
- llvm::MutexGuard locked(*JITDebugLock);
+ std::lock_guard<llvm::sys::Mutex> locked(*JITDebugLock);
assert(ObjectBufferMap.find(K) == ObjectBufferMap.end() &&
"Second attempt to perform debug registration.");
jit_code_entry* JITCodeEntry = new jit_code_entry();
@@ -178,7 +178,7 @@ void GDBJITRegistrationListener::notifyO
}
void GDBJITRegistrationListener::notifyFreeingObject(ObjectKey K) {
- llvm::MutexGuard locked(*JITDebugLock);
+ std::lock_guard<llvm::sys::Mutex> locked(*JITDebugLock);
RegisteredObjectBufferMap::iterator I = ObjectBufferMap.find(K);
if (I != ObjectBufferMap.end()) {
Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp?rev=368149&r1=368148&r2=368149&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Wed Aug 7 03:57:25 2019
@@ -32,7 +32,6 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Mutex.h"
-#include "llvm/Support/UniqueLock.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cmath>
@@ -41,6 +40,7 @@
#include <cstdio>
#include <cstring>
#include <map>
+#include <mutex>
#include <string>
#include <utility>
#include <vector>
@@ -258,7 +258,7 @@ GenericValue Interpreter::callExternalFu
ArrayRef<GenericValue> ArgVals) {
TheInterpreter = this;
- unique_lock<sys::Mutex> Guard(*FunctionsLock);
+ std::unique_lock<sys::Mutex> Guard(*FunctionsLock);
// Do a lookup to see if the function is in our cache... this should just be a
// deferred annotation!
Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=368149&r1=368148&r2=368149&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Wed Aug 7 03:57:25 2019
@@ -23,7 +23,7 @@
#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/MutexGuard.h"
+#include <mutex>
using namespace llvm;
@@ -88,7 +88,7 @@ MCJIT::MCJIT(std::unique_ptr<Module> M,
}
MCJIT::~MCJIT() {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
Dyld.deregisterEHFrames();
@@ -100,7 +100,7 @@ MCJIT::~MCJIT() {
}
void MCJIT::addModule(std::unique_ptr<Module> M) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
if (M->getDataLayout().isDefault())
M->setDataLayout(getDataLayout());
@@ -109,7 +109,7 @@ void MCJIT::addModule(std::unique_ptr<Mo
}
bool MCJIT::removeModule(Module *M) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
return OwnedModules.removeModule(M);
}
@@ -136,14 +136,14 @@ void MCJIT::addArchive(object::OwningBin
}
void MCJIT::setObjectCache(ObjectCache* NewCache) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
ObjCache = NewCache;
}
std::unique_ptr<MemoryBuffer> MCJIT::emitObject(Module *M) {
assert(M && "Can not emit a null module");
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
// Materialize all globals in the module if they have not been
// materialized already.
@@ -185,7 +185,7 @@ std::unique_ptr<MemoryBuffer> MCJIT::emi
void MCJIT::generateCodeForModule(Module *M) {
// Get a thread lock to make sure we aren't trying to load multiple times
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
// This must be a module which has already been added to this MCJIT instance.
assert(OwnedModules.ownsModule(M) &&
@@ -234,7 +234,7 @@ void MCJIT::generateCodeForModule(Module
}
void MCJIT::finalizeLoadedModules() {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
// Resolve any outstanding relocations.
Dyld.resolveRelocations();
@@ -250,7 +250,7 @@ void MCJIT::finalizeLoadedModules() {
// FIXME: Rename this.
void MCJIT::finalizeObject() {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
// Generate code for module is going to move objects out of the 'added' list,
// so we need to copy that out before using it:
@@ -265,7 +265,7 @@ void MCJIT::finalizeObject() {
}
void MCJIT::finalizeModule(Module *M) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
// This must be a module which has already been added to this MCJIT instance.
assert(OwnedModules.ownsModule(M) && "MCJIT::finalizeModule: Unknown module.");
@@ -292,7 +292,7 @@ Module *MCJIT::findModuleForSymbol(const
if (DemangledName[0] == getDataLayout().getGlobalPrefix())
DemangledName = DemangledName.substr(1);
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
// If it hasn't already been generated, see if it's in one of our modules.
for (ModulePtrSet::iterator I = OwnedModules.begin_added(),
@@ -332,7 +332,7 @@ uint64_t MCJIT::getSymbolAddress(const s
JITSymbol MCJIT::findSymbol(const std::string &Name,
bool CheckFunctionsOnly) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
// First, check to see if we already have this symbol.
if (auto Sym = findExistingSymbol(Name))
@@ -388,7 +388,7 @@ JITSymbol MCJIT::findSymbol(const std::s
}
uint64_t MCJIT::getGlobalValueAddress(const std::string &Name) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
uint64_t Result = getSymbolAddress(Name, false);
if (Result != 0)
finalizeLoadedModules();
@@ -396,7 +396,7 @@ uint64_t MCJIT::getGlobalValueAddress(co
}
uint64_t MCJIT::getFunctionAddress(const std::string &Name) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
uint64_t Result = getSymbolAddress(Name, true);
if (Result != 0)
finalizeLoadedModules();
@@ -405,7 +405,7 @@ uint64_t MCJIT::getFunctionAddress(const
// Deprecated. Use getFunctionAddress instead.
void *MCJIT::getPointerToFunction(Function *F) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
Mangler Mang;
SmallString<128> Name;
@@ -632,14 +632,14 @@ void *MCJIT::getPointerToNamedFunction(S
void MCJIT::RegisterJITEventListener(JITEventListener *L) {
if (!L)
return;
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
EventListeners.push_back(L);
}
void MCJIT::UnregisterJITEventListener(JITEventListener *L) {
if (!L)
return;
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
auto I = find(reverse(EventListeners), L);
if (I != EventListeners.rend()) {
std::swap(*I, EventListeners.back());
@@ -651,7 +651,7 @@ void MCJIT::notifyObjectLoaded(const obj
const RuntimeDyld::LoadedObjectInfo &L) {
uint64_t Key =
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(Obj.getData().data()));
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
MemMgr->notifyObjectLoaded(this, Obj);
for (unsigned I = 0, S = EventListeners.size(); I < S; ++I) {
EventListeners[I]->notifyObjectLoaded(Key, Obj, L);
@@ -661,7 +661,7 @@ void MCJIT::notifyObjectLoaded(const obj
void MCJIT::notifyFreeingObject(const object::ObjectFile &Obj) {
uint64_t Key =
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(Obj.getData().data()));
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
for (JITEventListener *L : EventListeners)
L->notifyFreeingObject(Key);
}
Modified: llvm/trunk/lib/ExecutionEngine/OProfileJIT/OProfileWrapper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/OProfileJIT/OProfileWrapper.cpp?rev=368149&r1=368148&r2=368149&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/OProfileJIT/OProfileWrapper.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/OProfileJIT/OProfileWrapper.cpp Wed Aug 7 03:57:25 2019
@@ -17,11 +17,11 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/Mutex.h"
-#include "llvm/Support/MutexGuard.h"
#include "llvm/Support/raw_ostream.h"
#include <cstring>
#include <dirent.h>
#include <fcntl.h>
+#include <mutex>
#include <stddef.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -54,7 +54,7 @@ bool OProfileWrapper::initialize() {
using namespace llvm;
using namespace llvm::sys;
- MutexGuard Guard(OProfileInitializationMutex);
+ std::lock_guard<sys::Mutex> Guard(OProfileInitializationMutex);
if (Initialized)
return OpenAgentFunc != 0;
Modified: llvm/trunk/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp?rev=368149&r1=368148&r2=368149&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp Wed Aug 7 03:57:25 2019
@@ -26,11 +26,11 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Mutex.h"
-#include "llvm/Support/MutexGuard.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/raw_ostream.h"
+#include <mutex>
#include <sys/mman.h> // mmap()
#include <sys/types.h> // getpid()
@@ -420,7 +420,7 @@ void PerfJITEventListener::NotifyCode(Ex
rec.Tid = get_threadid();
// avoid interspersing output
- MutexGuard Guard(Mutex);
+ std::lock_guard<sys::Mutex> Guard(Mutex);
rec.CodeIndex = CodeGeneration++; // under lock!
@@ -462,7 +462,7 @@ void PerfJITEventListener::NotifyDebug(u
// * char name[n] : source file name in ASCII, including null termination
// avoid interspersing output
- MutexGuard Guard(Mutex);
+ std::lock_guard<sys::Mutex> Guard(Mutex);
Dumpstream->write(reinterpret_cast<const char *>(&rec), sizeof(rec));
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=368149&r1=368148&r2=368149&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Wed Aug 7 03:57:25 2019
@@ -20,7 +20,7 @@
#include "llvm/Support/MSVCErrorWorkarounds.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MathExtras.h"
-#include "llvm/Support/MutexGuard.h"
+#include <mutex>
#include <future>
@@ -120,7 +120,7 @@ static void dumpSectionMemory(const Sect
// Resolve the relocations for all symbols we currently know about.
void RuntimeDyldImpl::resolveRelocations() {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
// Print out the sections prior to relocation.
LLVM_DEBUG(for (int i = 0, e = Sections.size(); i != e; ++i)
@@ -156,7 +156,7 @@ void RuntimeDyldImpl::resolveLocalReloca
void RuntimeDyldImpl::mapSectionAddress(const void *LocalAddress,
uint64_t TargetAddress) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
for (unsigned i = 0, e = Sections.size(); i != e; ++i) {
if (Sections[i].getAddress() == LocalAddress) {
reassignSectionAddress(i, TargetAddress);
@@ -177,7 +177,7 @@ static Error getOffset(const SymbolRef &
Expected<RuntimeDyldImpl::ObjSectionToIDMap>
RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) {
- MutexGuard locked(lock);
+ std::lock_guard<sys::Mutex> locked(lock);
// Save information about our target
Arch = (Triple::ArchType)Obj.getArch();
Modified: llvm/trunk/lib/Support/ManagedStatic.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ManagedStatic.cpp?rev=368149&r1=368148&r2=368149&view=diff
==============================================================================
--- llvm/trunk/lib/Support/ManagedStatic.cpp (original)
+++ llvm/trunk/lib/Support/ManagedStatic.cpp Wed Aug 7 03:57:25 2019
@@ -13,9 +13,9 @@
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Config/config.h"
#include "llvm/Support/Mutex.h"
-#include "llvm/Support/MutexGuard.h"
#include "llvm/Support/Threading.h"
#include <cassert>
+#include <mutex>
using namespace llvm;
static const ManagedStaticBase *StaticList = nullptr;
@@ -35,7 +35,7 @@ void ManagedStaticBase::RegisterManagedS
void (*Deleter)(void*)) const {
assert(Creator);
if (llvm_is_multithreaded()) {
- MutexGuard Lock(*getManagedStaticMutex());
+ std::lock_guard<sys::Mutex> Lock(*getManagedStaticMutex());
if (!Ptr.load(std::memory_order_relaxed)) {
void *Tmp = Creator();
@@ -77,7 +77,7 @@ void ManagedStaticBase::destroy() const
/// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
void llvm::llvm_shutdown() {
- MutexGuard Lock(*getManagedStaticMutex());
+ std::lock_guard<sys::Mutex> Lock(*getManagedStaticMutex());
while (StaticList)
StaticList->destroy();
Modified: llvm/trunk/lib/Support/Unix/Process.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Process.inc?rev=368149&r1=368148&r2=368149&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Process.inc (original)
+++ llvm/trunk/lib/Support/Unix/Process.inc Wed Aug 7 03:57:25 2019
@@ -16,7 +16,7 @@
#include "llvm/Config/config.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Mutex.h"
-#include "llvm/Support/MutexGuard.h"
+#include <mutex>
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
@@ -333,7 +333,7 @@ static ManagedStatic<sys::Mutex> TermCol
static bool terminalHasColors(int fd) {
#ifdef HAVE_TERMINFO
// First, acquire a global lock because these C routines are thread hostile.
- MutexGuard G(*TermColorMutex);
+ std::lock_guard<sys::Mutex> G(*TermColorMutex);
int errret = 0;
if (setupterm(nullptr, fd, &errret) != 0)
Modified: llvm/trunk/lib/Support/Unix/Signals.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Signals.inc?rev=368149&r1=368148&r2=368149&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Signals.inc (original)
+++ llvm/trunk/lib/Support/Unix/Signals.inc Wed Aug 7 03:57:25 2019
@@ -43,7 +43,6 @@
#include "llvm/Support/Mutex.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/SaveAndRestore.h"
-#include "llvm/Support/UniqueLock.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <string>
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp?rev=368149&r1=368148&r2=368149&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp Wed Aug 7 03:57:25 2019
@@ -19,10 +19,11 @@
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/MutexGuard.h"
+#include "llvm/Support/Mutex.h"
#include <algorithm>
#include <cstring>
#include <map>
+#include <mutex>
#include <string>
#include <vector>
@@ -38,12 +39,12 @@ static ManagedStatic<per_module_annot_t>
static sys::Mutex Lock;
void clearAnnotationCache(const Module *Mod) {
- MutexGuard Guard(Lock);
+ std::lock_guard<sys::Mutex> Guard(Lock);
annotationCache->erase(Mod);
}
static void cacheAnnotationFromMD(const MDNode *md, key_val_pair_t &retval) {
- MutexGuard Guard(Lock);
+ std::lock_guard<sys::Mutex> Guard(Lock);
assert(md && "Invalid mdnode for annotation");
assert((md->getNumOperands() % 2) == 1 && "Invalid number of operands");
// start index = 1, to skip the global variable key
@@ -69,7 +70,7 @@ static void cacheAnnotationFromMD(const
}
static void cacheAnnotationFromMD(const Module *m, const GlobalValue *gv) {
- MutexGuard Guard(Lock);
+ std::lock_guard<sys::Mutex> Guard(Lock);
NamedMDNode *NMD = m->getNamedMetadata("nvvm.annotations");
if (!NMD)
return;
@@ -103,7 +104,7 @@ static void cacheAnnotationFromMD(const
bool findOneNVVMAnnotation(const GlobalValue *gv, const std::string &prop,
unsigned &retval) {
- MutexGuard Guard(Lock);
+ std::lock_guard<sys::Mutex> Guard(Lock);
const Module *m = gv->getParent();
if ((*annotationCache).find(m) == (*annotationCache).end())
cacheAnnotationFromMD(m, gv);
@@ -117,7 +118,7 @@ bool findOneNVVMAnnotation(const GlobalV
bool findAllNVVMAnnotation(const GlobalValue *gv, const std::string &prop,
std::vector<unsigned> &retval) {
- MutexGuard Guard(Lock);
+ std::lock_guard<sys::Mutex> Guard(Lock);
const Module *m = gv->getParent();
if ((*annotationCache).find(m) == (*annotationCache).end())
cacheAnnotationFromMD(m, gv);
More information about the llvm-commits
mailing list