mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-26 05:25:47 +00:00
Switch analysis groups to be unregistered when llvm_shutdown is called.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32110 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -197,8 +197,6 @@ protected:
|
|||||||
const std::type_info *Pass = 0,
|
const std::type_info *Pass = 0,
|
||||||
bool isDefault = false);
|
bool isDefault = false);
|
||||||
void setGroupName(const char *Name);
|
void setGroupName(const char *Name);
|
||||||
public:
|
|
||||||
~RegisterAGBase();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Interface, bool Default = false>
|
template<typename Interface, bool Default = false>
|
||||||
|
@@ -286,8 +286,22 @@ void BasicBlockPass::addToPassManager(BasicBlockPassManager *PM,
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Pass Registration mechanism
|
// Pass Registration mechanism
|
||||||
//
|
//
|
||||||
|
namespace {
|
||||||
class PassRegistrar {
|
class PassRegistrar {
|
||||||
|
/// PassInfoMap - Keep track of the passinfo object for each registered llvm
|
||||||
|
/// pass.
|
||||||
std::map<TypeInfo, PassInfo*> PassInfoMap;
|
std::map<TypeInfo, PassInfo*> PassInfoMap;
|
||||||
|
|
||||||
|
/// AnalysisGroupInfo - Keep track of information for each analysis group.
|
||||||
|
struct AnalysisGroupInfo {
|
||||||
|
const PassInfo *DefaultImpl;
|
||||||
|
std::set<const PassInfo *> Implementations;
|
||||||
|
AnalysisGroupInfo() : DefaultImpl(0) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// AnalysisGroupInfoMap - Information for each analysis group.
|
||||||
|
std::map<const PassInfo *, AnalysisGroupInfo> AnalysisGroupInfoMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const PassInfo *GetPassInfo(const std::type_info &TI) const {
|
const PassInfo *GetPassInfo(const std::type_info &TI) const {
|
||||||
@@ -315,8 +329,27 @@ public:
|
|||||||
E = PassInfoMap.end(); I != E; ++I)
|
E = PassInfoMap.end(); I != E; ++I)
|
||||||
L->passEnumerate(I->second);
|
L->passEnumerate(I->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Analysis Group Mechanisms.
|
||||||
|
void RegisterAnalysisGroup(PassInfo *InterfaceInfo,
|
||||||
|
const PassInfo *ImplementationInfo,
|
||||||
|
bool isDefault) {
|
||||||
|
AnalysisGroupInfo &AGI = AnalysisGroupInfoMap[InterfaceInfo];
|
||||||
|
assert(AGI.Implementations.count(ImplementationInfo) == 0 &&
|
||||||
|
"Cannot add a pass to the same analysis group more than once!");
|
||||||
|
AGI.Implementations.insert(ImplementationInfo);
|
||||||
|
if (isDefault) {
|
||||||
|
assert(AGI.DefaultImpl == 0 && InterfaceInfo->getNormalCtor() == 0 &&
|
||||||
|
"Default implementation for analysis group already specified!");
|
||||||
|
assert(ImplementationInfo->getNormalCtor() &&
|
||||||
|
"Cannot specify pass as default if it does not have a default ctor");
|
||||||
|
AGI.DefaultImpl = ImplementationInfo;
|
||||||
|
InterfaceInfo->setNormalCtor(ImplementationInfo->getNormalCtor());
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static ManagedStatic<PassRegistrar> PassRegistrarObj;
|
static ManagedStatic<PassRegistrar> PassRegistrarObj;
|
||||||
static std::vector<PassRegistrationListener*> *Listeners = 0;
|
static std::vector<PassRegistrationListener*> *Listeners = 0;
|
||||||
@@ -350,14 +383,6 @@ void RegisterPassBase::unregisterPass() {
|
|||||||
// Analysis Group Implementation Code
|
// Analysis Group Implementation Code
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
struct AnalysisGroupInfo {
|
|
||||||
const PassInfo *DefaultImpl;
|
|
||||||
std::set<const PassInfo *> Implementations;
|
|
||||||
AnalysisGroupInfo() : DefaultImpl(0) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::map<const PassInfo *, AnalysisGroupInfo> *AnalysisGroupInfoMap = 0;
|
|
||||||
|
|
||||||
// RegisterAGBase implementation
|
// RegisterAGBase implementation
|
||||||
//
|
//
|
||||||
RegisterAGBase::RegisterAGBase(const std::type_info &Interface,
|
RegisterAGBase::RegisterAGBase(const std::type_info &Interface,
|
||||||
@@ -383,23 +408,8 @@ RegisterAGBase::RegisterAGBase(const std::type_info &Interface,
|
|||||||
// the interface.
|
// the interface.
|
||||||
PassInfo *IIPI = const_cast<PassInfo*>(ImplementationInfo);
|
PassInfo *IIPI = const_cast<PassInfo*>(ImplementationInfo);
|
||||||
IIPI->addInterfaceImplemented(InterfaceInfo);
|
IIPI->addInterfaceImplemented(InterfaceInfo);
|
||||||
|
|
||||||
// Lazily allocate to avoid nasty initialization order dependencies
|
PassRegistrarObj->RegisterAnalysisGroup(InterfaceInfo, IIPI, isDefault);
|
||||||
if (AnalysisGroupInfoMap == 0)
|
|
||||||
AnalysisGroupInfoMap = new std::map<const PassInfo *,AnalysisGroupInfo>();
|
|
||||||
|
|
||||||
AnalysisGroupInfo &AGI = (*AnalysisGroupInfoMap)[InterfaceInfo];
|
|
||||||
assert(AGI.Implementations.count(ImplementationInfo) == 0 &&
|
|
||||||
"Cannot add a pass to the same analysis group more than once!");
|
|
||||||
AGI.Implementations.insert(ImplementationInfo);
|
|
||||||
if (isDefault) {
|
|
||||||
assert(AGI.DefaultImpl == 0 && InterfaceInfo->getNormalCtor() == 0 &&
|
|
||||||
"Default implementation for analysis group already specified!");
|
|
||||||
assert(ImplementationInfo->getNormalCtor() &&
|
|
||||||
"Cannot specify pass as default if it does not have a default ctor");
|
|
||||||
AGI.DefaultImpl = ImplementationInfo;
|
|
||||||
InterfaceInfo->setNormalCtor(ImplementationInfo->getNormalCtor());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,35 +418,6 @@ void RegisterAGBase::setGroupName(const char *Name) {
|
|||||||
InterfaceInfo->setPassName(Name);
|
InterfaceInfo->setPassName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterAGBase::~RegisterAGBase() {
|
|
||||||
if (ImplementationInfo) {
|
|
||||||
assert(AnalysisGroupInfoMap && "Inserted into map, but map doesn't exist?");
|
|
||||||
AnalysisGroupInfo &AGI = (*AnalysisGroupInfoMap)[InterfaceInfo];
|
|
||||||
|
|
||||||
assert(AGI.Implementations.count(ImplementationInfo) &&
|
|
||||||
"Pass not a member of analysis group?");
|
|
||||||
|
|
||||||
if (AGI.DefaultImpl == ImplementationInfo)
|
|
||||||
AGI.DefaultImpl = 0;
|
|
||||||
|
|
||||||
AGI.Implementations.erase(ImplementationInfo);
|
|
||||||
|
|
||||||
// Last member of this analysis group? Unregister PassInfo, delete map entry
|
|
||||||
if (AGI.Implementations.empty()) {
|
|
||||||
assert(AGI.DefaultImpl == 0 &&
|
|
||||||
"Default implementation didn't unregister?");
|
|
||||||
AnalysisGroupInfoMap->erase(InterfaceInfo);
|
|
||||||
if (AnalysisGroupInfoMap->empty()) { // Delete map if empty
|
|
||||||
delete AnalysisGroupInfoMap;
|
|
||||||
AnalysisGroupInfoMap = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (InterfaceInfo == &PIObj)
|
|
||||||
unregisterPass();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// PassRegistrationListener implementation
|
// PassRegistrationListener implementation
|
||||||
|
Reference in New Issue
Block a user