[llvm-commits] [llvm] r109019 - in /llvm/trunk: include/llvm/PassRegistry.h lib/VMCore/Pass.cpp lib/VMCore/PassRegistry.cpp
Owen Anderson
resistor at mac.com
Wed Jul 21 10:52:45 PDT 2010
Author: resistor
Date: Wed Jul 21 12:52:45 2010
New Revision: 109019
URL: http://llvm.org/viewvc/llvm-project?rev=109019&view=rev
Log:
Move the smarts of AnalysisGroup registration into PassRegistry.
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=109019&r1=109018&r2=109019&view=diff
==============================================================================
--- llvm/trunk/include/llvm/PassRegistry.h (original)
+++ llvm/trunk/include/llvm/PassRegistry.h Wed Jul 21 12:52:45 2010
@@ -58,9 +58,8 @@
void unregisterPass(const PassInfo &PI);
/// Analysis Group Mechanisms.
- void registerAnalysisGroup(PassInfo *InterfaceInfo,
- const PassInfo *ImplementationInfo,
- bool isDefault);
+ void registerAnalysisGroup(intptr_t InterfaceID, intptr_t PassID,
+ PassInfo& Registeree, bool isDefault);
void enumerateWith(PassRegistrationListener *L);
void addRegistrationListener(PassRegistrationListener* L);
Modified: llvm/trunk/lib/VMCore/Pass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=109019&r1=109018&r2=109019&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Pass.cpp (original)
+++ llvm/trunk/lib/VMCore/Pass.cpp Wed Jul 21 12:52:45 2010
@@ -264,30 +264,9 @@
//
RegisterAGBase::RegisterAGBase(const char *Name, intptr_t InterfaceID,
intptr_t PassID, bool isDefault)
- : PassInfo(Name, InterfaceID) {
-
- PassInfo *InterfaceInfo =
- const_cast<PassInfo*>(Pass::lookupPassInfo(InterfaceID));
- if (InterfaceInfo == 0) {
- // First reference to Interface, register it now.
- PassRegistry::getPassRegistry()->registerPass(*this);
- InterfaceInfo = this;
- }
- assert(isAnalysisGroup() &&
- "Trying to join an analysis group that is a normal pass!");
-
- if (PassID) {
- const PassInfo *ImplementationInfo = Pass::lookupPassInfo(PassID);
- assert(ImplementationInfo &&
- "Must register pass before adding to AnalysisGroup!");
-
- // Make sure we keep track of the fact that the implementation implements
- // the interface.
- PassInfo *IIPI = const_cast<PassInfo*>(ImplementationInfo);
- IIPI->addInterfaceImplemented(InterfaceInfo);
-
- PassRegistry::getPassRegistry()->registerAnalysisGroup(InterfaceInfo, IIPI, isDefault);
- }
+ : PassInfo(Name, InterfaceID) {
+ PassRegistry::getPassRegistry()->registerAnalysisGroup(InterfaceID, PassID,
+ *this, isDefault);
}
Modified: llvm/trunk/lib/VMCore/PassRegistry.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassRegistry.cpp?rev=109019&r1=109018&r2=109019&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/PassRegistry.cpp (original)
+++ llvm/trunk/lib/VMCore/PassRegistry.cpp Wed Jul 21 12:52:45 2010
@@ -108,20 +108,40 @@
/// Analysis Group Mechanisms.
-void PassRegistry::registerAnalysisGroup(PassInfo *InterfaceInfo,
- const PassInfo *ImplementationInfo,
+void PassRegistry::registerAnalysisGroup(intptr_t InterfaceID,
+ intptr_t PassID,
+ PassInfo& Registeree,
bool isDefault) {
- sys::SmartScopedLock<true> Guard(Lock);
- 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(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");
- InterfaceInfo->setNormalCtor(ImplementationInfo->getNormalCtor());
+ PassInfo *InterfaceInfo = const_cast<PassInfo*>(getPassInfo(InterfaceID));
+ if (InterfaceInfo == 0) {
+ // First reference to Interface, register it now.
+ registerPass(Registeree);
+ InterfaceInfo = &Registeree;
+ }
+ assert(Registeree.isAnalysisGroup() &&
+ "Trying to join an analysis group that is a normal pass!");
+
+ if (PassID) {
+ PassInfo *ImplementationInfo = const_cast<PassInfo*>(getPassInfo(PassID));
+ assert(ImplementationInfo &&
+ "Must register pass before adding to AnalysisGroup!");
+
+ // Make sure we keep track of the fact that the implementation implements
+ // the interface.
+ ImplementationInfo->addInterfaceImplemented(InterfaceInfo);
+
+ sys::SmartScopedLock<true> Guard(Lock);
+ 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(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");
+ InterfaceInfo->setNormalCtor(ImplementationInfo->getNormalCtor());
+ }
}
}
More information about the llvm-commits
mailing list