diff options
author | Zachary Turner <zturner@google.com> | 2014-06-12 00:16:36 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2014-06-12 00:16:36 +0000 |
commit | a4dc93e6b620c1191f6c914f829cc23b77726bc5 (patch) | |
tree | e36e26fb1de314d3f749d6b9889851f7aae80488 /lib/IR | |
parent | 87fcb536ab8e70f3578c88c57d12c2ffee86abd2 (diff) | |
download | llvm-a4dc93e6b620c1191f6c914f829cc23b77726bc5.tar.gz llvm-a4dc93e6b620c1191f6c914f829cc23b77726bc5.tar.bz2 llvm-a4dc93e6b620c1191f6c914f829cc23b77726bc5.tar.xz |
Do not register and de-register PassRegistrationListeners during
construction and destruction.
PassRegistrationListener is intended for use as a generic listener.
In some cases, PassRegistrationListener-derived classes were being
created, and automatically registered and de-registered in static
constructors and destructors. Since ManagedStatics are destroyed
prior to program shutdown, this leads to errors where an attempt is
made to access a ManagedStatic that has already been destroyed.
Reviewed by: rnk, dblaikie
Differential Revision: http://reviews.llvm.org/D4106
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210724 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r-- | lib/IR/Pass.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/IR/Pass.cpp b/lib/IR/Pass.cpp index bb55d2af7c..916d79b4cb 100644 --- a/lib/IR/Pass.cpp +++ b/lib/IR/Pass.cpp @@ -224,17 +224,6 @@ RegisterAGBase::RegisterAGBase(const char *Name, const void *InterfaceID, // PassRegistrationListener implementation // -// PassRegistrationListener ctor - Add the current object to the list of -// PassRegistrationListeners... -PassRegistrationListener::PassRegistrationListener() { - PassRegistry::getPassRegistry()->addRegistrationListener(this); -} - -// dtor - Remove object from list of listeners... -PassRegistrationListener::~PassRegistrationListener() { - PassRegistry::getPassRegistry()->removeRegistrationListener(this); -} - // enumeratePasses - Iterate over the registered passes, calling the // passEnumerate callback on each PassInfo object. // @@ -242,7 +231,16 @@ void PassRegistrationListener::enumeratePasses() { PassRegistry::getPassRegistry()->enumerateWith(this); } -PassNameParser::~PassNameParser() {} +PassNameParser::PassNameParser() + : Opt(nullptr) { + PassRegistry::getPassRegistry()->addRegistrationListener(this); +} + +PassNameParser::~PassNameParser() { + // This only gets called during static destruction, in which case the + // PassRegistry will have already been destroyed by llvm_shutdown(). So + // attempting to remove the registration listener is an error. +} //===----------------------------------------------------------------------===// // AnalysisUsage Class Implementation |