[llvm-commits] [llvm] r100519 - /llvm/trunk/lib/VMCore/Pass.cpp
Owen Anderson
resistor at mac.com
Mon Apr 5 21:20:48 PDT 2010
Author: resistor
Date: Mon Apr 5 23:20:48 2010
New Revision: 100519
URL: http://llvm.org/viewvc/llvm-project?rev=100519&view=rev
Log:
Use a ManagedCleanup to prevent leaking the PassRegistrar map. In breaks the
use case where someone wants to resurrect LLVM after calling llvm_shutdown,
but I'm not aware of any clients that are affected by this.
Modified:
llvm/trunk/lib/VMCore/Pass.cpp
Modified: llvm/trunk/lib/VMCore/Pass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=100519&r1=100518&r2=100519&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Pass.cpp (original)
+++ llvm/trunk/lib/VMCore/Pass.cpp Mon Apr 5 23:20:48 2010
@@ -294,13 +294,8 @@
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
-// ctors, and having llvm_shutdown clear this map prevents successful
-// ressurection after llvm_shutdown is run.
+static PassRegistrar *PassRegistrarObj = 0;
static PassRegistrar *getPassRegistrar() {
- static PassRegistrar *PassRegistrarObj = 0;
-
// Use double-checked locking to safely initialize the registrar when
// we're running in multithreaded mode.
PassRegistrar* tmp = PassRegistrarObj;
@@ -323,6 +318,19 @@
return PassRegistrarObj;
}
+// 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 cleanupPassRegistrar(void*) {
+ if (PassRegistrarObj) {
+ delete PassRegistrarObj;
+ PassRegistrarObj = 0;
+ }
+}
+ManagedCleanup<&cleanupPassRegistrar> registrarCleanup;
+
// getPassInfo - Return the PassInfo data structure that corresponds to this
// pass...
const PassInfo *Pass::getPassInfo() const {
More information about the llvm-commits
mailing list