mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-20 10:24:12 +00:00
remove a bunch of locking from LLVMContextImpl. Since only one thread
can be banging on a context at a time, this isn't needed. Owen, please review. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85728 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -15,6 +15,7 @@
|
|||||||
#define LLVM_TYPE_SYMBOL_TABLE_H
|
#define LLVM_TYPE_SYMBOL_TABLE_H
|
||||||
|
|
||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
@ -69,12 +70,16 @@ public:
|
|||||||
/// Lookup the type associated with name.
|
/// Lookup the type associated with name.
|
||||||
/// @returns end() if the name is not found, or an iterator at the entry for
|
/// @returns end() if the name is not found, or an iterator at the entry for
|
||||||
/// Type.
|
/// Type.
|
||||||
iterator find(const StringRef &name);
|
iterator find(const StringRef &Name) {
|
||||||
|
return tmap.find(Name);
|
||||||
|
}
|
||||||
|
|
||||||
/// Lookup the type associated with name.
|
/// Lookup the type associated with name.
|
||||||
/// @returns end() if the name is not found, or an iterator at the entry for
|
/// @returns end() if the name is not found, or an iterator at the entry for
|
||||||
/// Type.
|
/// Type.
|
||||||
const_iterator find(const StringRef &name) const;
|
const_iterator find(const StringRef &Name) const {
|
||||||
|
return tmap.find(Name);
|
||||||
|
}
|
||||||
|
|
||||||
/// @returns true iff the symbol table is empty.
|
/// @returns true iff the symbol table is empty.
|
||||||
/// @brief Determine if the symbol table is empty
|
/// @brief Determine if the symbol table is empty
|
||||||
|
@ -126,6 +126,9 @@ static bool MarkAliveBlocks(BasicBlock *BB,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store to undef and store to null are undefined and used to signal that
|
||||||
|
// they should be changed to unreachable by passes that can't modify the
|
||||||
|
// CFG.
|
||||||
if (StoreInst *SI = dyn_cast<StoreInst>(BBI)) {
|
if (StoreInst *SI = dyn_cast<StoreInst>(BBI)) {
|
||||||
Value *Ptr = SI->getOperand(1);
|
Value *Ptr = SI->getOperand(1);
|
||||||
|
|
||||||
|
@ -29,9 +29,6 @@
|
|||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||||
#include "llvm/System/Mutex.h"
|
|
||||||
#include "llvm/System/RWMutex.h"
|
|
||||||
#include "llvm/System/Threading.h"
|
|
||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/DenseMap.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/System/Mutex.h"
|
|
||||||
#include "llvm/System/RWMutex.h"
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
@ -529,12 +527,7 @@ private:
|
|||||||
///
|
///
|
||||||
AbstractTypeMapTy AbstractTypeMap;
|
AbstractTypeMapTy AbstractTypeMap;
|
||||||
|
|
||||||
/// ConstantUniqueMapLock - Mutex for this map.
|
|
||||||
sys::SmartMutex<true> ConstantUniqueMapLock;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// NOTE: This function is not locked. It is the caller's responsibility
|
|
||||||
// to enforce proper synchronization.
|
|
||||||
typename MapTy::iterator map_begin() { return Map.begin(); }
|
typename MapTy::iterator map_begin() { return Map.begin(); }
|
||||||
typename MapTy::iterator map_end() { return Map.end(); }
|
typename MapTy::iterator map_end() { return Map.end(); }
|
||||||
|
|
||||||
@ -551,8 +544,6 @@ public:
|
|||||||
/// entry and Exists=true. If not, the iterator points to the newly
|
/// entry and Exists=true. If not, the iterator points to the newly
|
||||||
/// inserted entry and returns Exists=false. Newly inserted entries have
|
/// inserted entry and returns Exists=false. Newly inserted entries have
|
||||||
/// I->second == 0, and should be filled in.
|
/// I->second == 0, and should be filled in.
|
||||||
/// NOTE: This function is not locked. It is the caller's responsibility
|
|
||||||
// to enforce proper synchronization.
|
|
||||||
typename MapTy::iterator InsertOrGetItem(std::pair<MapKey, ConstantClass *>
|
typename MapTy::iterator InsertOrGetItem(std::pair<MapKey, ConstantClass *>
|
||||||
&InsertVal,
|
&InsertVal,
|
||||||
bool &Exists) {
|
bool &Exists) {
|
||||||
@ -619,7 +610,6 @@ public:
|
|||||||
/// getOrCreate - Return the specified constant from the map, creating it if
|
/// getOrCreate - Return the specified constant from the map, creating it if
|
||||||
/// necessary.
|
/// necessary.
|
||||||
ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) {
|
ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) {
|
||||||
sys::SmartScopedLock<true> Lock(ConstantUniqueMapLock);
|
|
||||||
MapKey Lookup(Ty, V);
|
MapKey Lookup(Ty, V);
|
||||||
ConstantClass* Result = 0;
|
ConstantClass* Result = 0;
|
||||||
|
|
||||||
@ -674,7 +664,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void remove(ConstantClass *CP) {
|
void remove(ConstantClass *CP) {
|
||||||
sys::SmartScopedLock<true> Lock(ConstantUniqueMapLock);
|
|
||||||
typename MapTy::iterator I = FindExistingElement(CP);
|
typename MapTy::iterator I = FindExistingElement(CP);
|
||||||
assert(I != Map.end() && "Constant not found in constant table!");
|
assert(I != Map.end() && "Constant not found in constant table!");
|
||||||
assert(I->second == CP && "Didn't find correct element?");
|
assert(I->second == CP && "Didn't find correct element?");
|
||||||
@ -694,8 +683,6 @@ public:
|
|||||||
/// MoveConstantToNewSlot - If we are about to change C to be the element
|
/// MoveConstantToNewSlot - If we are about to change C to be the element
|
||||||
/// specified by I, update our internal data structures to reflect this
|
/// specified by I, update our internal data structures to reflect this
|
||||||
/// fact.
|
/// fact.
|
||||||
/// NOTE: This function is not locked. It is the responsibility of the
|
|
||||||
/// caller to enforce proper synchronization if using this method.
|
|
||||||
void MoveConstantToNewSlot(ConstantClass *C, typename MapTy::iterator I) {
|
void MoveConstantToNewSlot(ConstantClass *C, typename MapTy::iterator I) {
|
||||||
// First, remove the old location of the specified constant in the map.
|
// First, remove the old location of the specified constant in the map.
|
||||||
typename MapTy::iterator OldI = FindExistingElement(C);
|
typename MapTy::iterator OldI = FindExistingElement(C);
|
||||||
@ -725,7 +712,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
|
void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
|
||||||
sys::SmartScopedLock<true> Lock(ConstantUniqueMapLock);
|
|
||||||
typename AbstractTypeMapTy::iterator I = AbstractTypeMap.find(OldTy);
|
typename AbstractTypeMapTy::iterator I = AbstractTypeMap.find(OldTy);
|
||||||
|
|
||||||
assert(I != AbstractTypeMap.end() &&
|
assert(I != AbstractTypeMap.end() &&
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
#include "llvm/Metadata.h"
|
#include "llvm/Metadata.h"
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/System/Mutex.h"
|
|
||||||
#include "llvm/System/RWMutex.h"
|
|
||||||
#include "llvm/Assembly/Writer.h"
|
#include "llvm/Assembly/Writer.h"
|
||||||
#include "llvm/ADT/APFloat.h"
|
#include "llvm/ADT/APFloat.h"
|
||||||
#include "llvm/ADT/APInt.h"
|
#include "llvm/ADT/APInt.h"
|
||||||
@ -132,18 +130,8 @@ public:
|
|||||||
ConstantInt *TheTrueVal;
|
ConstantInt *TheTrueVal;
|
||||||
ConstantInt *TheFalseVal;
|
ConstantInt *TheFalseVal;
|
||||||
|
|
||||||
// Lock used for guarding access to the leak detector
|
|
||||||
sys::SmartMutex<true> LLVMObjectsLock;
|
|
||||||
LeakDetectorImpl<Value> LLVMObjects;
|
LeakDetectorImpl<Value> LLVMObjects;
|
||||||
|
|
||||||
// Lock used for guarding access to the type maps.
|
|
||||||
sys::SmartMutex<true> TypeMapLock;
|
|
||||||
|
|
||||||
// Recursive lock used for guarding access to AbstractTypeUsers.
|
|
||||||
// NOTE: The true template parameter means this will no-op when we're not in
|
|
||||||
// multithreaded mode.
|
|
||||||
sys::SmartMutex<true> AbstractTypeUsersLock;
|
|
||||||
|
|
||||||
// Basic type instances.
|
// Basic type instances.
|
||||||
const Type VoidTy;
|
const Type VoidTy;
|
||||||
const Type LabelTy;
|
const Type LabelTy;
|
||||||
|
@ -36,7 +36,6 @@ void LeakDetector::addGarbageObjectImpl(void *Object) {
|
|||||||
|
|
||||||
void LeakDetector::addGarbageObjectImpl(const Value *Object) {
|
void LeakDetector::addGarbageObjectImpl(const Value *Object) {
|
||||||
LLVMContextImpl *pImpl = Object->getContext().pImpl;
|
LLVMContextImpl *pImpl = Object->getContext().pImpl;
|
||||||
sys::SmartScopedLock<true> Lock(pImpl->LLVMObjectsLock);
|
|
||||||
pImpl->LLVMObjects.addGarbage(Object);
|
pImpl->LLVMObjects.addGarbage(Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +46,6 @@ void LeakDetector::removeGarbageObjectImpl(void *Object) {
|
|||||||
|
|
||||||
void LeakDetector::removeGarbageObjectImpl(const Value *Object) {
|
void LeakDetector::removeGarbageObjectImpl(const Value *Object) {
|
||||||
LLVMContextImpl *pImpl = Object->getContext().pImpl;
|
LLVMContextImpl *pImpl = Object->getContext().pImpl;
|
||||||
sys::SmartScopedLock<true> Lock(pImpl->LLVMObjectsLock);
|
|
||||||
pImpl->LLVMObjects.removeGarbage(Object);
|
pImpl->LLVMObjects.removeGarbage(Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +53,6 @@ void LeakDetector::checkForGarbageImpl(LLVMContext &Context,
|
|||||||
const std::string &Message) {
|
const std::string &Message) {
|
||||||
LLVMContextImpl *pImpl = Context.pImpl;
|
LLVMContextImpl *pImpl = Context.pImpl;
|
||||||
sys::SmartScopedLock<true> Lock(*ObjectsLock);
|
sys::SmartScopedLock<true> Lock(*ObjectsLock);
|
||||||
sys::SmartScopedLock<true> CLock(pImpl->LLVMObjectsLock);
|
|
||||||
|
|
||||||
Objects->setName("GENERIC");
|
Objects->setName("GENERIC");
|
||||||
pImpl->LLVMObjects.setName("LLVM");
|
pImpl->LLVMObjects.setName("LLVM");
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
#include "llvm/Value.h"
|
#include "llvm/Value.h"
|
||||||
#include "llvm/ADT/SmallPtrSet.h"
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/System/Mutex.h"
|
|
||||||
#include "llvm/System/RWMutex.h"
|
|
||||||
#include "llvm/System/Threading.h"
|
#include "llvm/System/Threading.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
@ -768,7 +766,6 @@ const IntegerType *IntegerType::get(LLVMContext &C, unsigned NumBits) {
|
|||||||
|
|
||||||
// First, see if the type is already in the table, for which
|
// First, see if the type is already in the table, for which
|
||||||
// a reader lock suffices.
|
// a reader lock suffices.
|
||||||
sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
|
|
||||||
ITy = pImpl->IntegerTypes.get(IVT);
|
ITy = pImpl->IntegerTypes.get(IVT);
|
||||||
|
|
||||||
if (!ITy) {
|
if (!ITy) {
|
||||||
@ -810,7 +807,6 @@ FunctionType *FunctionType::get(const Type *ReturnType,
|
|||||||
|
|
||||||
LLVMContextImpl *pImpl = ReturnType->getContext().pImpl;
|
LLVMContextImpl *pImpl = ReturnType->getContext().pImpl;
|
||||||
|
|
||||||
sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
|
|
||||||
FT = pImpl->FunctionTypes.get(VT);
|
FT = pImpl->FunctionTypes.get(VT);
|
||||||
|
|
||||||
if (!FT) {
|
if (!FT) {
|
||||||
@ -835,7 +831,6 @@ ArrayType *ArrayType::get(const Type *ElementType, uint64_t NumElements) {
|
|||||||
|
|
||||||
LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
|
LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
|
||||||
|
|
||||||
sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
|
|
||||||
AT = pImpl->ArrayTypes.get(AVT);
|
AT = pImpl->ArrayTypes.get(AVT);
|
||||||
|
|
||||||
if (!AT) {
|
if (!AT) {
|
||||||
@ -861,7 +856,6 @@ VectorType *VectorType::get(const Type *ElementType, unsigned NumElements) {
|
|||||||
|
|
||||||
LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
|
LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
|
||||||
|
|
||||||
sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
|
|
||||||
PT = pImpl->VectorTypes.get(PVT);
|
PT = pImpl->VectorTypes.get(PVT);
|
||||||
|
|
||||||
if (!PT) {
|
if (!PT) {
|
||||||
@ -890,7 +884,6 @@ StructType *StructType::get(LLVMContext &Context,
|
|||||||
|
|
||||||
LLVMContextImpl *pImpl = Context.pImpl;
|
LLVMContextImpl *pImpl = Context.pImpl;
|
||||||
|
|
||||||
sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
|
|
||||||
ST = pImpl->StructTypes.get(STV);
|
ST = pImpl->StructTypes.get(STV);
|
||||||
|
|
||||||
if (!ST) {
|
if (!ST) {
|
||||||
@ -938,7 +931,6 @@ PointerType *PointerType::get(const Type *ValueType, unsigned AddressSpace) {
|
|||||||
|
|
||||||
LLVMContextImpl *pImpl = ValueType->getContext().pImpl;
|
LLVMContextImpl *pImpl = ValueType->getContext().pImpl;
|
||||||
|
|
||||||
sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
|
|
||||||
PT = pImpl->PointerTypes.get(PVT);
|
PT = pImpl->PointerTypes.get(PVT);
|
||||||
|
|
||||||
if (!PT) {
|
if (!PT) {
|
||||||
@ -970,10 +962,7 @@ bool PointerType::isValidElementType(const Type *ElemTy) {
|
|||||||
// it. This function is called primarily by the PATypeHandle class.
|
// it. This function is called primarily by the PATypeHandle class.
|
||||||
void Type::addAbstractTypeUser(AbstractTypeUser *U) const {
|
void Type::addAbstractTypeUser(AbstractTypeUser *U) const {
|
||||||
assert(isAbstract() && "addAbstractTypeUser: Current type not abstract!");
|
assert(isAbstract() && "addAbstractTypeUser: Current type not abstract!");
|
||||||
LLVMContextImpl *pImpl = getContext().pImpl;
|
|
||||||
pImpl->AbstractTypeUsersLock.acquire();
|
|
||||||
AbstractTypeUsers.push_back(U);
|
AbstractTypeUsers.push_back(U);
|
||||||
pImpl->AbstractTypeUsersLock.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -983,8 +972,6 @@ void Type::addAbstractTypeUser(AbstractTypeUser *U) const {
|
|||||||
// is annihilated, because there is no way to get a reference to it ever again.
|
// is annihilated, because there is no way to get a reference to it ever again.
|
||||||
//
|
//
|
||||||
void Type::removeAbstractTypeUser(AbstractTypeUser *U) const {
|
void Type::removeAbstractTypeUser(AbstractTypeUser *U) const {
|
||||||
LLVMContextImpl *pImpl = getContext().pImpl;
|
|
||||||
pImpl->AbstractTypeUsersLock.acquire();
|
|
||||||
|
|
||||||
// Search from back to front because we will notify users from back to
|
// Search from back to front because we will notify users from back to
|
||||||
// front. Also, it is likely that there will be a stack like behavior to
|
// front. Also, it is likely that there will be a stack like behavior to
|
||||||
@ -1013,7 +1000,6 @@ void Type::removeAbstractTypeUser(AbstractTypeUser *U) const {
|
|||||||
this->destroy();
|
this->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
pImpl->AbstractTypeUsersLock.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// unlockedRefineAbstractTypeTo - This function is used when it is discovered
|
// unlockedRefineAbstractTypeTo - This function is used when it is discovered
|
||||||
@ -1065,7 +1051,6 @@ void DerivedType::unlockedRefineAbstractTypeTo(const Type *NewType) {
|
|||||||
// will not cause users to drop off of the use list. If we resolve to ourself
|
// will not cause users to drop off of the use list. If we resolve to ourself
|
||||||
// we succeed!
|
// we succeed!
|
||||||
//
|
//
|
||||||
pImpl->AbstractTypeUsersLock.acquire();
|
|
||||||
while (!AbstractTypeUsers.empty() && NewTy != this) {
|
while (!AbstractTypeUsers.empty() && NewTy != this) {
|
||||||
AbstractTypeUser *User = AbstractTypeUsers.back();
|
AbstractTypeUser *User = AbstractTypeUsers.back();
|
||||||
|
|
||||||
@ -1081,7 +1066,6 @@ void DerivedType::unlockedRefineAbstractTypeTo(const Type *NewType) {
|
|||||||
assert(AbstractTypeUsers.size() != OldSize &&
|
assert(AbstractTypeUsers.size() != OldSize &&
|
||||||
"AbsTyUser did not remove self from user list!");
|
"AbsTyUser did not remove self from user list!");
|
||||||
}
|
}
|
||||||
pImpl->AbstractTypeUsersLock.release();
|
|
||||||
|
|
||||||
// If we were successful removing all users from the type, 'this' will be
|
// If we were successful removing all users from the type, 'this' will be
|
||||||
// deleted when the last PATypeHolder is destroyed or updated from this type.
|
// deleted when the last PATypeHolder is destroyed or updated from this type.
|
||||||
@ -1095,7 +1079,6 @@ void DerivedType::unlockedRefineAbstractTypeTo(const Type *NewType) {
|
|||||||
void DerivedType::refineAbstractTypeTo(const Type *NewType) {
|
void DerivedType::refineAbstractTypeTo(const Type *NewType) {
|
||||||
// All recursive calls will go through unlockedRefineAbstractTypeTo,
|
// All recursive calls will go through unlockedRefineAbstractTypeTo,
|
||||||
// to avoid deadlock problems.
|
// to avoid deadlock problems.
|
||||||
sys::SmartScopedLock<true> L(NewType->getContext().pImpl->TypeMapLock);
|
|
||||||
unlockedRefineAbstractTypeTo(NewType);
|
unlockedRefineAbstractTypeTo(NewType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1107,9 +1090,6 @@ void DerivedType::notifyUsesThatTypeBecameConcrete() {
|
|||||||
DEBUG(errs() << "typeIsREFINED type: " << (void*)this << " " << *this <<"\n");
|
DEBUG(errs() << "typeIsREFINED type: " << (void*)this << " " << *this <<"\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LLVMContextImpl *pImpl = getContext().pImpl;
|
|
||||||
|
|
||||||
pImpl->AbstractTypeUsersLock.acquire();
|
|
||||||
unsigned OldSize = AbstractTypeUsers.size(); OldSize=OldSize;
|
unsigned OldSize = AbstractTypeUsers.size(); OldSize=OldSize;
|
||||||
while (!AbstractTypeUsers.empty()) {
|
while (!AbstractTypeUsers.empty()) {
|
||||||
AbstractTypeUser *ATU = AbstractTypeUsers.back();
|
AbstractTypeUser *ATU = AbstractTypeUsers.back();
|
||||||
@ -1118,7 +1098,6 @@ void DerivedType::notifyUsesThatTypeBecameConcrete() {
|
|||||||
assert(AbstractTypeUsers.size() < OldSize-- &&
|
assert(AbstractTypeUsers.size() < OldSize-- &&
|
||||||
"AbstractTypeUser did not remove itself from the use list!");
|
"AbstractTypeUser did not remove itself from the use list!");
|
||||||
}
|
}
|
||||||
pImpl->AbstractTypeUsersLock.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// refineAbstractType - Called when a contained type is found to be more
|
// refineAbstractType - Called when a contained type is found to be more
|
||||||
|
@ -17,16 +17,12 @@
|
|||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/System/RWMutex.h"
|
|
||||||
#include "llvm/System/Threading.h"
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
#define DEBUG_SYMBOL_TABLE 0
|
#define DEBUG_SYMBOL_TABLE 0
|
||||||
#define DEBUG_ABSTYPE 0
|
#define DEBUG_ABSTYPE 0
|
||||||
|
|
||||||
static ManagedStatic<sys::SmartRWMutex<true> > TypeSymbolTableLock;
|
|
||||||
|
|
||||||
TypeSymbolTable::~TypeSymbolTable() {
|
TypeSymbolTable::~TypeSymbolTable() {
|
||||||
// Drop all abstract type references in the type plane...
|
// Drop all abstract type references in the type plane...
|
||||||
for (iterator TI = tmap.begin(), TE = tmap.end(); TI != TE; ++TI) {
|
for (iterator TI = tmap.begin(), TE = tmap.end(); TI != TE; ++TI) {
|
||||||
@ -38,8 +34,6 @@ TypeSymbolTable::~TypeSymbolTable() {
|
|||||||
std::string TypeSymbolTable::getUniqueName(const StringRef &BaseName) const {
|
std::string TypeSymbolTable::getUniqueName(const StringRef &BaseName) const {
|
||||||
std::string TryName = BaseName;
|
std::string TryName = BaseName;
|
||||||
|
|
||||||
sys::SmartScopedReader<true> Reader(*TypeSymbolTableLock);
|
|
||||||
|
|
||||||
const_iterator End = tmap.end();
|
const_iterator End = tmap.end();
|
||||||
|
|
||||||
// See if the name exists
|
// See if the name exists
|
||||||
@ -50,8 +44,6 @@ std::string TypeSymbolTable::getUniqueName(const StringRef &BaseName) const {
|
|||||||
|
|
||||||
// lookup a type by name - returns null on failure
|
// lookup a type by name - returns null on failure
|
||||||
Type* TypeSymbolTable::lookup(const StringRef &Name) const {
|
Type* TypeSymbolTable::lookup(const StringRef &Name) const {
|
||||||
sys::SmartScopedReader<true> Reader(*TypeSymbolTableLock);
|
|
||||||
|
|
||||||
const_iterator TI = tmap.find(Name);
|
const_iterator TI = tmap.find(Name);
|
||||||
Type* result = 0;
|
Type* result = 0;
|
||||||
if (TI != tmap.end())
|
if (TI != tmap.end())
|
||||||
@ -59,21 +51,9 @@ Type* TypeSymbolTable::lookup(const StringRef &Name) const {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeSymbolTable::iterator TypeSymbolTable::find(const StringRef &Name) {
|
|
||||||
sys::SmartScopedReader<true> Reader(*TypeSymbolTableLock);
|
|
||||||
return tmap.find(Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
TypeSymbolTable::const_iterator
|
|
||||||
TypeSymbolTable::find(const StringRef &Name) const {
|
|
||||||
sys::SmartScopedReader<true> Reader(*TypeSymbolTableLock);
|
|
||||||
return tmap.find(Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove - Remove a type from the symbol table...
|
// remove - Remove a type from the symbol table...
|
||||||
Type* TypeSymbolTable::remove(iterator Entry) {
|
Type* TypeSymbolTable::remove(iterator Entry) {
|
||||||
TypeSymbolTableLock->writer_acquire();
|
|
||||||
|
|
||||||
assert(Entry != tmap.end() && "Invalid entry to remove!");
|
assert(Entry != tmap.end() && "Invalid entry to remove!");
|
||||||
const Type* Result = Entry->second;
|
const Type* Result = Entry->second;
|
||||||
|
|
||||||
@ -84,8 +64,6 @@ Type* TypeSymbolTable::remove(iterator Entry) {
|
|||||||
|
|
||||||
tmap.erase(Entry);
|
tmap.erase(Entry);
|
||||||
|
|
||||||
TypeSymbolTableLock->writer_release();
|
|
||||||
|
|
||||||
// If we are removing an abstract type, remove the symbol table from it's use
|
// If we are removing an abstract type, remove the symbol table from it's use
|
||||||
// list...
|
// list...
|
||||||
if (Result->isAbstract()) {
|
if (Result->isAbstract()) {
|
||||||
@ -105,8 +83,6 @@ Type* TypeSymbolTable::remove(iterator Entry) {
|
|||||||
void TypeSymbolTable::insert(const StringRef &Name, const Type* T) {
|
void TypeSymbolTable::insert(const StringRef &Name, const Type* T) {
|
||||||
assert(T && "Can't insert null type into symbol table!");
|
assert(T && "Can't insert null type into symbol table!");
|
||||||
|
|
||||||
TypeSymbolTableLock->writer_acquire();
|
|
||||||
|
|
||||||
if (tmap.insert(std::make_pair(Name, T)).second) {
|
if (tmap.insert(std::make_pair(Name, T)).second) {
|
||||||
// Type inserted fine with no conflict.
|
// Type inserted fine with no conflict.
|
||||||
|
|
||||||
@ -132,8 +108,6 @@ void TypeSymbolTable::insert(const StringRef &Name, const Type* T) {
|
|||||||
tmap.insert(make_pair(UniqueName, T));
|
tmap.insert(make_pair(UniqueName, T));
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeSymbolTableLock->writer_release();
|
|
||||||
|
|
||||||
// If we are adding an abstract type, add the symbol table to it's use list.
|
// If we are adding an abstract type, add the symbol table to it's use list.
|
||||||
if (T->isAbstract()) {
|
if (T->isAbstract()) {
|
||||||
cast<DerivedType>(T)->addAbstractTypeUser(this);
|
cast<DerivedType>(T)->addAbstractTypeUser(this);
|
||||||
@ -146,8 +120,6 @@ void TypeSymbolTable::insert(const StringRef &Name, const Type* T) {
|
|||||||
// This function is called when one of the types in the type plane are refined
|
// This function is called when one of the types in the type plane are refined
|
||||||
void TypeSymbolTable::refineAbstractType(const DerivedType *OldType,
|
void TypeSymbolTable::refineAbstractType(const DerivedType *OldType,
|
||||||
const Type *NewType) {
|
const Type *NewType) {
|
||||||
sys::SmartScopedReader<true> Reader(*TypeSymbolTableLock);
|
|
||||||
|
|
||||||
// Loop over all of the types in the symbol table, replacing any references
|
// 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
|
// to OldType with references to NewType. Note that there may be multiple
|
||||||
// occurrences, and although we only need to remove one at a time, it's
|
// occurrences, and although we only need to remove one at a time, it's
|
||||||
@ -177,7 +149,6 @@ void TypeSymbolTable::typeBecameConcrete(const DerivedType *AbsTy) {
|
|||||||
// Loop over all of the types in the symbol table, dropping any abstract
|
// 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 user entries for AbsTy which occur because there are names for the
|
||||||
// type.
|
// type.
|
||||||
sys::SmartScopedReader<true> Reader(*TypeSymbolTableLock);
|
|
||||||
for (iterator TI = begin(), TE = end(); TI != TE; ++TI)
|
for (iterator TI = begin(), TE = end(); TI != TE; ++TI)
|
||||||
if (TI->second == const_cast<Type*>(static_cast<const Type*>(AbsTy)))
|
if (TI->second == const_cast<Type*>(static_cast<const Type*>(AbsTy)))
|
||||||
AbsTy->removeAbstractTypeUser(this);
|
AbsTy->removeAbstractTypeUser(this);
|
||||||
@ -191,8 +162,6 @@ static void DumpTypes(const std::pair<const std::string, const Type*>& T ) {
|
|||||||
|
|
||||||
void TypeSymbolTable::dump() const {
|
void TypeSymbolTable::dump() const {
|
||||||
errs() << "TypeSymbolPlane: ";
|
errs() << "TypeSymbolPlane: ";
|
||||||
sys::SmartScopedReader<true> Reader(*TypeSymbolTableLock);
|
|
||||||
for_each(tmap.begin(), tmap.end(), DumpTypes);
|
for_each(tmap.begin(), tmap.end(), DumpTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: sw=2 ai
|
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
#include "llvm/Support/LeakDetector.h"
|
#include "llvm/Support/LeakDetector.h"
|
||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
#include "llvm/Support/ValueHandle.h"
|
#include "llvm/Support/ValueHandle.h"
|
||||||
#include "llvm/System/RWMutex.h"
|
|
||||||
#include "llvm/System/Threading.h"
|
|
||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/DenseMap.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
Reference in New Issue
Block a user