diff options
author | Chris Lattner <sabre@nondot.org> | 2007-04-21 00:12:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-04-21 00:12:18 +0000 |
commit | d1458f1d3019f7e5581480dfbb7a0f81ecd27ac0 (patch) | |
tree | 43f29cc5f8f9f88d051c4b123f1867b49c24fdbd /lib/VMCore/Pass.cpp | |
parent | cd070759c42a385e869f0faf9cee16ec6b1cb4ae (diff) | |
download | external_llvm-d1458f1d3019f7e5581480dfbb7a0f81ecd27ac0.zip external_llvm-d1458f1d3019f7e5581480dfbb7a0f81ecd27ac0.tar.gz external_llvm-d1458f1d3019f7e5581480dfbb7a0f81ecd27ac0.tar.bz2 |
Fix a bug that prevented the JIT from working correctly after llvm_shutdown.
Pass info objects are initialized by static ctors, so deleting them at
llvm_shutdown time prevents resurrection from working.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36292 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Pass.cpp')
-rw-r--r-- | lib/VMCore/Pass.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index b593d47..be49ae4 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -189,9 +189,19 @@ public: }; } -static ManagedStatic<PassRegistrar> PassRegistrarObj; static std::vector<PassRegistrationListener*> *Listeners = 0; +// 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 *getPassRegistrar() { + static PassRegistrar *PassRegistrarObj = 0; + if (!PassRegistrarObj) + PassRegistrarObj = new PassRegistrar(); + return PassRegistrarObj; +} + // getPassInfo - Return the PassInfo data structure that corresponds to this // pass... const PassInfo *Pass::getPassInfo() const { @@ -200,11 +210,11 @@ const PassInfo *Pass::getPassInfo() const { } const PassInfo *Pass::lookupPassInfo(const std::type_info &TI) { - return PassRegistrarObj->GetPassInfo(TI); + return getPassRegistrar()->GetPassInfo(TI); } void RegisterPassBase::registerPass() { - PassRegistrarObj->RegisterPass(PIObj); + getPassRegistrar()->RegisterPass(PIObj); // Notify any listeners. if (Listeners) @@ -214,7 +224,7 @@ void RegisterPassBase::registerPass() { } void RegisterPassBase::unregisterPass() { - PassRegistrarObj->UnregisterPass(PIObj); + getPassRegistrar()->UnregisterPass(PIObj); } //===----------------------------------------------------------------------===// @@ -247,7 +257,7 @@ RegisterAGBase::RegisterAGBase(const std::type_info &Interface, PassInfo *IIPI = const_cast<PassInfo*>(ImplementationInfo); IIPI->addInterfaceImplemented(InterfaceInfo); - PassRegistrarObj->RegisterAnalysisGroup(InterfaceInfo, IIPI, isDefault); + getPassRegistrar()->RegisterAnalysisGroup(InterfaceInfo, IIPI, isDefault); } } @@ -286,7 +296,7 @@ PassRegistrationListener::~PassRegistrationListener() { // passEnumerate callback on each PassInfo object. // void PassRegistrationListener::enumeratePasses() { - PassRegistrarObj->EnumerateWith(this); + getPassRegistrar()->EnumerateWith(this); } //===----------------------------------------------------------------------===// |