From d0438546ef3c8b98355ad4f3c74658fc712b857d Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Wed, 19 Aug 2009 22:58:34 +0000 Subject: [PATCH] AttrListPtr operations need to be atomic. llvm-svn: 79486 --- lib/VMCore/Attributes.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp index 91c7320a708..73c92ec6c09 100644 --- a/lib/VMCore/Attributes.cpp +++ b/lib/VMCore/Attributes.cpp @@ -175,14 +175,17 @@ AttrListPtr AttrListPtr::get(const AttributeWithIndex *Attrs, unsigned NumAttrs) //===----------------------------------------------------------------------===// AttrListPtr::AttrListPtr(AttributeListImpl *LI) : AttrList(LI) { + sys::SmartScopedLock Lock(*ALMutex); if (LI) LI->AddRef(); } AttrListPtr::AttrListPtr(const AttrListPtr &P) : AttrList(P.AttrList) { + sys::SmartScopedLock Lock(*ALMutex); if (AttrList) AttrList->AddRef(); } const AttrListPtr &AttrListPtr::operator=(const AttrListPtr &RHS) { + sys::SmartScopedLock 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 Lock(*ALMutex); if (AttrList) AttrList->DropRef(); }