summaryrefslogtreecommitdiff
path: root/lib/VMCore/Pass.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-06-24 00:25:42 +0000
committerOwen Anderson <resistor@mac.com>2009-06-24 00:25:42 +0000
commit6b96f6cfeb41576b62190483f8d87d3da1572486 (patch)
treeafd0c9c13e90aa5960bb2d642331d8cbf7f7ddc3 /lib/VMCore/Pass.cpp
parenta96751fc8ff1cc9a225ffbba73de53e2b9e1ae35 (diff)
downloadllvm-6b96f6cfeb41576b62190483f8d87d3da1572486.tar.gz
llvm-6b96f6cfeb41576b62190483f8d87d3da1572486.tar.bz2
llvm-6b96f6cfeb41576b62190483f8d87d3da1572486.tar.xz
Guard the listeners list. Unfortunately, this requires a real static rather
than a managed static because other managed statics can (and do) access this list in their destructors. Yes, I know it's horrible. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74029 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Pass.cpp')
-rw-r--r--lib/VMCore/Pass.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp
index e943e31b1e..b037994d42 100644
--- a/lib/VMCore/Pass.cpp
+++ b/lib/VMCore/Pass.cpp
@@ -20,6 +20,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/System/Atomic.h"
+#include "llvm/System/Mutex.h"
#include "llvm/System/Threading.h"
#include <algorithm>
#include <map>
@@ -187,6 +188,7 @@ public:
}
static std::vector<PassRegistrationListener*> *Listeners = 0;
+static sys::SmartMutex<true> ListenersLock;
// FIXME: This should use ManagedStatic to manage the pass registrar.
// Unfortunately, we can't do this, because passes are registered with static
@@ -231,6 +233,7 @@ void PassInfo::registerPass() {
getPassRegistrar()->RegisterPass(*this);
// Notify any listeners.
+ sys::SmartScopedLock<true> Lock(&ListenersLock);
if (Listeners)
for (std::vector<PassRegistrationListener*>::iterator
I = Listeners->begin(), E = Listeners->end(); I != E; ++I)
@@ -283,12 +286,14 @@ RegisterAGBase::RegisterAGBase(const char *Name, intptr_t InterfaceID,
// PassRegistrationListener ctor - Add the current object to the list of
// PassRegistrationListeners...
PassRegistrationListener::PassRegistrationListener() {
+ sys::SmartScopedLock<true> Lock(&ListenersLock);
if (!Listeners) Listeners = new std::vector<PassRegistrationListener*>();
Listeners->push_back(this);
}
// dtor - Remove object from list of listeners...
PassRegistrationListener::~PassRegistrationListener() {
+ sys::SmartScopedLock<true> Lock(&ListenersLock);
std::vector<PassRegistrationListener*>::iterator I =
std::find(Listeners->begin(), Listeners->end(), this);
assert(Listeners && I != Listeners->end() &&