From 596c1dc3e228795562975396bcd9672840aa3c82 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Mon, 17 Aug 2009 17:10:58 +0000 Subject: [PATCH] Add locking around the attributes list. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79255 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Attributes.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp index 5d763c34fe5..91c7320a708 100644 --- a/lib/VMCore/Attributes.cpp +++ b/lib/VMCore/Attributes.cpp @@ -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 > ALMutex; static ManagedStatic > AttributesLists; AttributeListImpl::~AttributeListImpl() { + sys::SmartScopedLock 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 Lock(*ALMutex); + AttributeListImpl *PAL = AttributesLists->FindNodeOrInsertPos(ID, InsertPos);