mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-15 09:51:00 +00:00
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. llvm-svn: 368149
This commit is contained in:
parent
3db897a47d
commit
b3f29d6f74
@ -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:
|
||||
|
@ -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
|
@ -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>
|
||||
|
||||
|
@ -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
|
@ -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::RemoveMapping(StringRef Name) {
|
||||
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::getMangledName(const GlobalValue *GV) {
|
||||
}
|
||||
|
||||
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(StringRef Name, uint64_t Addr) {
|
||||
}
|
||||
|
||||
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::clearGlobalMappingsFromModule(Module *M) {
|
||||
|
||||
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::updateGlobalMapping(StringRef Name, uint64_t Addr) {
|
||||
}
|
||||
|
||||
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::getAddressToGlobalIfAvailable(StringRef S) {
|
||||
|
||||
|
||||
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::getPointerToGlobal(const GlobalValue *GV) {
|
||||
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;
|
||||
|
||||
|
@ -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* JITCodeEntry) {
|
||||
|
||||
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::notifyObjectLoaded(
|
||||
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::notifyObjectLoaded(
|
||||
}
|
||||
|
||||
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()) {
|
||||
|
@ -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::callExternalFunction(Function *F,
|
||||
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!
|
||||
|
@ -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, std::unique_ptr<TargetMachine> TM,
|
||||
}
|
||||
|
||||
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<Module> M) {
|
||||
}
|
||||
|
||||
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::OwningBinary<object::Archive> A) {
|
||||
}
|
||||
|
||||
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::emitObject(Module *M) {
|
||||
|
||||
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 *M) {
|
||||
}
|
||||
|
||||
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 std::string &Name,
|
||||
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 std::string &Name,
|
||||
|
||||
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::string &Name,
|
||||
}
|
||||
|
||||
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(const std::string &Name) {
|
||||
}
|
||||
|
||||
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 std::string &Name) {
|
||||
|
||||
// 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(StringRef Name, bool AbortOnFailure) {
|
||||
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 object::ObjectFile &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 object::ObjectFile &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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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(Expected<llvm::StringRef> &Symbol,
|
||||
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(uint64_t CodeAddr,
|
||||
// * 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));
|
||||
|
||||
|
@ -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 SectionEntry &S, StringRef State) {
|
||||
|
||||
// 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::resolveLocalRelocations() {
|
||||
|
||||
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 &Sym, SectionRef Sec,
|
||||
|
||||
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();
|
||||
|
@ -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::RegisterManagedStatic(void *(*Creator)(),
|
||||
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();
|
||||
|
@ -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> TermColorMutex;
|
||||
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)
|
||||
|
@ -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>
|
||||
|
@ -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> annotationCache;
|
||||
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 MDNode *md, key_val_pair_t &retval) {
|
||||
}
|
||||
|
||||
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 Module *m, const GlobalValue *gv) {
|
||||
|
||||
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 GlobalValue *gv, const std::string &prop,
|
||||
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user