[llvm-commits] [llvm] r73617 - /llvm/trunk/lib/VMCore/Type.cpp
Owen Anderson
resistor at mac.com
Wed Jun 17 10:13:58 PDT 2009
Author: resistor
Date: Wed Jun 17 12:13:54 2009
New Revision: 73617
URL: http://llvm.org/viewvc/llvm-project?rev=73617&view=rev
Log:
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.
Modified:
llvm/trunk/lib/VMCore/Type.cpp
Modified: llvm/trunk/lib/VMCore/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=73617&r1=73616&r2=73617&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Type.cpp (original)
+++ llvm/trunk/lib/VMCore/Type.cpp Wed Jun 17 12:13:54 2009
@@ -46,7 +46,7 @@
// Reader/writer lock used for guarding access to the type maps.
static ManagedStatic<sys::RWMutex> TypeMapLock;
-// Lock used for guarding access to AbstractTypeUsers.
+// Recursive lock used for guarding access to AbstractTypeUsers.
static ManagedStatic<sys::Mutex> AbstractTypeUsersLock;
// Concrete/Abstract TypeDescriptions - We lazily calculate type descriptions
@@ -1544,6 +1544,7 @@
// 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 @@
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 @@
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 @@
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
More information about the llvm-commits
mailing list