AttrListPtr operations need to be atomic.
authorOwen Anderson <resistor@mac.com>
Wed, 19 Aug 2009 22:58:34 +0000 (22:58 +0000)
committerOwen Anderson <resistor@mac.com>
Wed, 19 Aug 2009 22:58:34 +0000 (22:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79486 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Attributes.cpp

index 91c7320a708b5b3e880bc2183fe644b2a5c8d538..73c92ec6c09819c3f498364ec72305c05ee632de 100644 (file)
@@ -175,14 +175,17 @@ AttrListPtr AttrListPtr::get(const AttributeWithIndex *Attrs, unsigned NumAttrs)
 //===----------------------------------------------------------------------===//
 
 AttrListPtr::AttrListPtr(AttributeListImpl *LI) : AttrList(LI) {
+  sys::SmartScopedLock<true> Lock(*ALMutex);
   if (LI) LI->AddRef();
 }
 
 AttrListPtr::AttrListPtr(const AttrListPtr &P) : AttrList(P.AttrList) {
+  sys::SmartScopedLock<true> Lock(*ALMutex);
   if (AttrList) AttrList->AddRef();  
 }
 
 const AttrListPtr &AttrListPtr::operator=(const AttrListPtr &RHS) {
+  sys::SmartScopedLock<true> Lock(*ALMutex);
   if (AttrList == RHS.AttrList) return *this;
   if (AttrList) AttrList->DropRef();
   AttrList = RHS.AttrList;
@@ -191,6 +194,7 @@ const AttrListPtr &AttrListPtr::operator=(const AttrListPtr &RHS) {
 }
 
 AttrListPtr::~AttrListPtr() {
+  sys::SmartScopedLock<true> Lock(*ALMutex);
   if (AttrList) AttrList->DropRef();
 }