diff options
author | Owen Anderson <resistor@mac.com> | 2010-07-20 21:22:24 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2010-07-20 21:22:24 +0000 |
commit | aac07eaeef0b29690f18061abc148a2608cd77de (patch) | |
tree | 0574003a37189ba73fb7d548177ff93b3b97eb6a /lib/VMCore/Pass.cpp | |
parent | aad9c4cf67821eee981f8e7eb870b77c3727b26e (diff) | |
download | external_llvm-aac07eaeef0b29690f18061abc148a2608cd77de.zip external_llvm-aac07eaeef0b29690f18061abc148a2608cd77de.tar.gz external_llvm-aac07eaeef0b29690f18061abc148a2608cd77de.tar.bz2 |
Move more functionality from Pass.cpp to PassRegistry.cpp. This global will go away eventually, but for now we still need it around.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108932 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Pass.cpp')
-rw-r--r-- | lib/VMCore/Pass.cpp | 53 |
1 files changed, 6 insertions, 47 deletions
diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index 4b19e53..255be38 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -241,47 +241,6 @@ PassManagerType BasicBlockPass::getPotentialPassManagerType() const { static std::vector<PassRegistrationListener*> *Listeners = 0; static sys::SmartMutex<true> ListenersLock; -static PassRegistry *PassRegistryObj = 0; -static PassRegistry *getPassRegistry() { - // Use double-checked locking to safely initialize the registrar when - // we're running in multithreaded mode. - PassRegistry* tmp = PassRegistryObj; - if (llvm_is_multithreaded()) { - sys::MemoryFence(); - if (!tmp) { - llvm_acquire_global_lock(); - tmp = PassRegistryObj; - if (!tmp) { - tmp = new PassRegistry(); - sys::MemoryFence(); - PassRegistryObj = tmp; - } - llvm_release_global_lock(); - } - } else if (!tmp) { - PassRegistryObj = new PassRegistry(); - } - - return PassRegistryObj; -} - -namespace { - -// FIXME: We use ManagedCleanup to erase the pass registrar on shutdown. -// Unfortunately, passes are registered with static ctors, and having -// llvm_shutdown clear this map prevents successful ressurection after -// llvm_shutdown is run. Ideally we should find a solution so that we don't -// leak the map, AND can still resurrect after shutdown. -void cleanupPassRegistry(void*) { - if (PassRegistryObj) { - delete PassRegistryObj; - PassRegistryObj = 0; - } -} -ManagedCleanup<&cleanupPassRegistry> registryCleanup ATTRIBUTE_USED; - -} - // getPassInfo - Return the PassInfo data structure that corresponds to this // pass... const PassInfo *Pass::getPassInfo() const { @@ -289,15 +248,15 @@ const PassInfo *Pass::getPassInfo() const { } const PassInfo *Pass::lookupPassInfo(intptr_t TI) { - return getPassRegistry()->getPassInfo(TI); + return PassRegistry::getPassRegistry()->getPassInfo(TI); } const PassInfo *Pass::lookupPassInfo(StringRef Arg) { - return getPassRegistry()->getPassInfo(Arg); + return PassRegistry::getPassRegistry()->getPassInfo(Arg); } void PassInfo::registerPass() { - getPassRegistry()->registerPass(*this); + PassRegistry::getPassRegistry()->registerPass(*this); // Notify any listeners. sys::SmartScopedLock<true> Lock(ListenersLock); @@ -308,7 +267,7 @@ void PassInfo::registerPass() { } void PassInfo::unregisterPass() { - getPassRegistry()->unregisterPass(*this); + PassRegistry::getPassRegistry()->unregisterPass(*this); } Pass *PassInfo::createPass() const { @@ -349,7 +308,7 @@ RegisterAGBase::RegisterAGBase(const char *Name, intptr_t InterfaceID, PassInfo *IIPI = const_cast<PassInfo*>(ImplementationInfo); IIPI->addInterfaceImplemented(InterfaceInfo); - getPassRegistry()->registerAnalysisGroup(InterfaceInfo, IIPI, isDefault); + PassRegistry::getPassRegistry()->registerAnalysisGroup(InterfaceInfo, IIPI, isDefault); } } @@ -385,7 +344,7 @@ PassRegistrationListener::~PassRegistrationListener() { // passEnumerate callback on each PassInfo object. // void PassRegistrationListener::enumeratePasses() { - getPassRegistry()->enumerateWith(this); + PassRegistry::getPassRegistry()->enumerateWith(this); } PassNameParser::~PassNameParser() {} |