Add locking around the attributes list.

llvm-svn: 79255
This commit is contained in:
Owen Anderson 2009-08-17 17:10:58 +00:00
parent 820739dccc
commit d91e6b097d
1 changed files with 6 additions and 0 deletions

View File

@ -15,6 +15,7 @@
#include "llvm/Type.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/System/Mutex.h"
#include "llvm/Support/Streams.h"
#include "llvm/Support/ManagedStatic.h"
using namespace llvm;
@ -124,9 +125,11 @@ public:
};
}
static ManagedStatic<sys::SmartMutex<true> > ALMutex;
static ManagedStatic<FoldingSet<AttributeListImpl> > AttributesLists;
AttributeListImpl::~AttributeListImpl() {
sys::SmartScopedLock<true> Lock(*ALMutex);
AttributesLists->RemoveNode(this);
}
@ -149,6 +152,9 @@ AttrListPtr AttrListPtr::get(const AttributeWithIndex *Attrs, unsigned NumAttrs)
FoldingSetNodeID ID;
AttributeListImpl::Profile(ID, Attrs, NumAttrs);
void *InsertPos;
sys::SmartScopedLock<true> Lock(*ALMutex);
AttributeListImpl *PAL =
AttributesLists->FindNodeOrInsertPos(ID, InsertPos);