From: Owen Anderson Date: Wed, 17 Jun 2009 17:13:54 +0000 (+0000) Subject: We need to guard reads of the AbstractTypeUsers list, as well as writes to it. While... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4f0ac58da12f8a1258c40fa762c7ece31d2685b0;p=oota-llvm.git We need to guard reads of the AbstractTypeUsers list, as well as writes to it. While it would be nice to use a R/W lock here, we can't, because it HAS to be recursive. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73617 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 34ba5be8bef..b815eec665b 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -46,7 +46,7 @@ AbstractTypeUser::~AbstractTypeUser() {} // Reader/writer lock used for guarding access to the type maps. static ManagedStatic TypeMapLock; -// Lock used for guarding access to AbstractTypeUsers. +// Recursive lock used for guarding access to AbstractTypeUsers. static ManagedStatic AbstractTypeUsersLock; // Concrete/Abstract TypeDescriptions - We lazily calculate type descriptions @@ -1544,6 +1544,7 @@ void DerivedType::unlockedRefineAbstractTypeTo(const Type *NewType) { // will not cause users to drop off of the use list. If we resolve to ourself // we succeed! // + if (llvm_is_multithreaded()) AbstractTypeUsersLock->acquire(); while (!AbstractTypeUsers.empty() && NewTy != this) { AbstractTypeUser *User = AbstractTypeUsers.back(); @@ -1559,6 +1560,7 @@ void DerivedType::unlockedRefineAbstractTypeTo(const Type *NewType) { assert(AbstractTypeUsers.size() != OldSize && "AbsTyUser did not remove self from user list!"); } + if (llvm_is_multithreaded()) AbstractTypeUsersLock->release(); // 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. @@ -1589,6 +1591,7 @@ void DerivedType::notifyUsesThatTypeBecameConcrete() { DOUT << "typeIsREFINED type: " << (void*)this << " " << *this << "\n"; #endif + if (llvm_is_multithreaded()) AbstractTypeUsersLock->acquire(); unsigned OldSize = AbstractTypeUsers.size(); OldSize=OldSize; while (!AbstractTypeUsers.empty()) { AbstractTypeUser *ATU = AbstractTypeUsers.back(); @@ -1597,6 +1600,7 @@ void DerivedType::notifyUsesThatTypeBecameConcrete() { assert(AbstractTypeUsers.size() < OldSize-- && "AbstractTypeUser did not remove itself from the use list!"); } + if (llvm_is_multithreaded()) AbstractTypeUsersLock->release(); } // refineAbstractType - Called when a contained type is found to be more