[llvm-commits] [llvm] r79258 - in /llvm/trunk/lib/VMCore: LLVMContextImpl.h Type.cpp
Owen Anderson
resistor at mac.com
Mon Aug 17 10:59:36 PDT 2009
Author: resistor
Date: Mon Aug 17 12:59:35 2009
New Revision: 79258
URL: http://llvm.org/viewvc/llvm-project?rev=79258&view=rev
Log:
Privatize the last bits of static type state.
Modified:
llvm/trunk/lib/VMCore/LLVMContextImpl.h
llvm/trunk/lib/VMCore/Type.cpp
Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=79258&r1=79257&r2=79258&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original)
+++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Mon Aug 17 12:59:35 2009
@@ -22,6 +22,7 @@
#include "llvm/DerivedTypes.h"
#include "llvm/System/Mutex.h"
#include "llvm/System/RWMutex.h"
+#include "llvm/Assembly/Writer.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/DenseMap.h"
@@ -136,6 +137,18 @@
// 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;
+
+ // Concrete/Abstract TypeDescriptions - We lazily calculate type descriptions
+ // for types as they are needed. Because resolution of types must invalidate
+ // all of the abstract type descriptions, we keep them in a seperate map to
+ // make this easy.
+ TypePrinting ConcreteTypeDescriptions;
+ TypePrinting AbstractTypeDescriptions;
+
TypeMap<ArrayValType, ArrayType> ArrayTypes;
TypeMap<VectorValType, VectorType> VectorTypes;
TypeMap<PointerValType, PointerType> PointerTypes;
Modified: llvm/trunk/lib/VMCore/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=79258&r1=79257&r2=79258&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Type.cpp (original)
+++ llvm/trunk/lib/VMCore/Type.cpp Mon Aug 17 12:59:35 2009
@@ -47,18 +47,6 @@
// Type Class Implementation
//===----------------------------------------------------------------------===//
-// 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.
-static ManagedStatic<sys::SmartMutex<true> > AbstractTypeUsersLock;
-
-// Concrete/Abstract TypeDescriptions - We lazily calculate type descriptions
-// for types as they are needed. Because resolution of types must invalidate
-// all of the abstract type descriptions, we keep them in a seperate map to make
-// this easy.
-static ManagedStatic<TypePrinting> ConcreteTypeDescriptions;
-static ManagedStatic<TypePrinting> AbstractTypeDescriptions;
-
/// Because of the way Type subclasses are allocated, this function is necessary
/// to use the correct kind of "delete" operator to deallocate the Type object.
/// Some type objects (FunctionTy, StructTy) allocate additional space after
@@ -273,8 +261,11 @@
std::string Type::getDescription() const {
+ LLVMContextImpl *pImpl = getContext().pImpl;
TypePrinting &Map =
- isAbstract() ? *AbstractTypeDescriptions : *ConcreteTypeDescriptions;
+ isAbstract() ?
+ pImpl->AbstractTypeDescriptions :
+ pImpl->ConcreteTypeDescriptions;
std::string DescStr;
raw_string_ostream DescOS(DescStr);
@@ -983,9 +974,10 @@
// it. This function is called primarily by the PATypeHandle class.
void Type::addAbstractTypeUser(AbstractTypeUser *U) const {
assert(isAbstract() && "addAbstractTypeUser: Current type not abstract!");
- AbstractTypeUsersLock->acquire();
+ LLVMContextImpl *pImpl = getContext().pImpl;
+ pImpl->AbstractTypeUsersLock.acquire();
AbstractTypeUsers.push_back(U);
- AbstractTypeUsersLock->release();
+ pImpl->AbstractTypeUsersLock.release();
}
@@ -995,7 +987,8 @@
// is annihilated, because there is no way to get a reference to it ever again.
//
void Type::removeAbstractTypeUser(AbstractTypeUser *U) const {
- AbstractTypeUsersLock->acquire();
+ LLVMContextImpl *pImpl = getContext().pImpl;
+ pImpl->AbstractTypeUsersLock.acquire();
// 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
@@ -1024,7 +1017,7 @@
this->destroy();
}
- AbstractTypeUsersLock->release();
+ pImpl->AbstractTypeUsersLock.release();
}
// unlockedRefineAbstractTypeTo - This function is used when it is discovered
@@ -1038,9 +1031,10 @@
assert(this != NewType && "Can't refine to myself!");
assert(ForwardType == 0 && "This type has already been refined!");
+ LLVMContextImpl *pImpl = getContext().pImpl;
+
// The descriptions may be out of date. Conservatively clear them all!
- if (AbstractTypeDescriptions.isConstructed())
- AbstractTypeDescriptions->clear();
+ pImpl->AbstractTypeDescriptions.clear();
#ifdef DEBUG_MERGE_TYPES
DOUT << "REFINING abstract type [" << (void*)this << " "
@@ -1075,7 +1069,7 @@
// will not cause users to drop off of the use list. If we resolve to ourself
// we succeed!
//
- AbstractTypeUsersLock->acquire();
+ pImpl->AbstractTypeUsersLock.acquire();
while (!AbstractTypeUsers.empty() && NewTy != this) {
AbstractTypeUser *User = AbstractTypeUsers.back();
@@ -1091,7 +1085,7 @@
assert(AbstractTypeUsers.size() != OldSize &&
"AbsTyUser did not remove self from user list!");
}
- AbstractTypeUsersLock->release();
+ pImpl->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.
@@ -1117,7 +1111,9 @@
DOUT << "typeIsREFINED type: " << (void*)this << " " << *this << "\n";
#endif
- AbstractTypeUsersLock->acquire();
+ LLVMContextImpl *pImpl = getContext().pImpl;
+
+ pImpl->AbstractTypeUsersLock.acquire();
unsigned OldSize = AbstractTypeUsers.size(); OldSize=OldSize;
while (!AbstractTypeUsers.empty()) {
AbstractTypeUser *ATU = AbstractTypeUsers.back();
@@ -1126,7 +1122,7 @@
assert(AbstractTypeUsers.size() < OldSize-- &&
"AbstractTypeUser did not remove itself from the use list!");
}
- AbstractTypeUsersLock->release();
+ pImpl->AbstractTypeUsersLock.release();
}
// refineAbstractType - Called when a contained type is found to be more
More information about the llvm-commits
mailing list