[llvm-commits] [llvm] r108932 - in /llvm/trunk: include/llvm/PassRegistry.h lib/VMCore/Pass.cpp lib/VMCore/PassRegistry.cpp
Owen Anderson
resistor at mac.com
Tue Jul 20 14:22:24 PDT 2010
Author: resistor
Date: Tue Jul 20 16:22:24 2010
New Revision: 108932
URL: http://llvm.org/viewvc/llvm-project?rev=108932&view=rev
Log:
Move more functionality from Pass.cpp to PassRegistry.cpp. This global will go away eventually, but for now we still need it around.
Modified:
llvm/trunk/include/llvm/PassRegistry.h
llvm/trunk/lib/VMCore/Pass.cpp
llvm/trunk/lib/VMCore/PassRegistry.cpp
Modified: llvm/trunk/include/llvm/PassRegistry.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassRegistry.h?rev=108932&r1=108931&r2=108932&view=diff
==============================================================================
--- llvm/trunk/include/llvm/PassRegistry.h (original)
+++ llvm/trunk/include/llvm/PassRegistry.h Tue Jul 20 16:22:24 2010
@@ -46,6 +46,8 @@
std::map<const PassInfo*, AnalysisGroupInfo> AnalysisGroupInfoMap;
public:
+ static PassRegistry *getPassRegistry();
+
const PassInfo *getPassInfo(intptr_t TI) const;
const PassInfo *getPassInfo(StringRef Arg) const;
Modified: llvm/trunk/lib/VMCore/Pass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=108932&r1=108931&r2=108932&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Pass.cpp (original)
+++ llvm/trunk/lib/VMCore/Pass.cpp Tue Jul 20 16:22:24 2010
@@ -241,47 +241,6 @@
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::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::unregisterPass() {
- getPassRegistry()->unregisterPass(*this);
+ PassRegistry::getPassRegistry()->unregisterPass(*this);
}
Pass *PassInfo::createPass() const {
@@ -349,7 +308,7 @@
PassInfo *IIPI = const_cast<PassInfo*>(ImplementationInfo);
IIPI->addInterfaceImplemented(InterfaceInfo);
- getPassRegistry()->registerAnalysisGroup(InterfaceInfo, IIPI, isDefault);
+ PassRegistry::getPassRegistry()->registerAnalysisGroup(InterfaceInfo, IIPI, isDefault);
}
}
@@ -385,7 +344,7 @@
// passEnumerate callback on each PassInfo object.
//
void PassRegistrationListener::enumeratePasses() {
- getPassRegistry()->enumerateWith(this);
+ PassRegistry::getPassRegistry()->enumerateWith(this);
}
PassNameParser::~PassNameParser() {}
Modified: llvm/trunk/lib/VMCore/PassRegistry.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassRegistry.cpp?rev=108932&r1=108931&r2=108932&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/PassRegistry.cpp (original)
+++ llvm/trunk/lib/VMCore/PassRegistry.cpp Tue Jul 20 16:22:24 2010
@@ -13,7 +13,49 @@
//===----------------------------------------------------------------------===//
#include "llvm/PassRegistry.h"
-#include "llvm/System/Mutex.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ManagedStatic.h"
+
+static PassRegistry *PassRegistryObj = 0;
+PassRegistry *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;
+
+}
const PassInfo *PassRegistry::getPassInfo(intptr_t TI) const {
sys::SmartScopedLock<true> Guard(Lock);
More information about the llvm-commits
mailing list