Move the smarts of AnalysisGroup registration into PassRegistry.
authorOwen Anderson <resistor@mac.com>
Wed, 21 Jul 2010 17:52:45 +0000 (17:52 +0000)
committerOwen Anderson <resistor@mac.com>
Wed, 21 Jul 2010 17:52:45 +0000 (17:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109019 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/PassRegistry.h
lib/VMCore/Pass.cpp
lib/VMCore/PassRegistry.cpp

index 7b1b6fc703acce608b166e0a7e0c8b9af2f2b7a1..193ecfd1b584d07668c4822e4a793e92d264eb2b 100644 (file)
@@ -58,9 +58,8 @@ public:
   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);
index 75ee17cd5a5c880c5012b1caecab2aa44e61a997..5a176d59f9b868ac927d991ccc3a8fd365311fb9 100644 (file)
@@ -264,30 +264,9 @@ Pass *PassInfo::createPass() const {
 //
 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);
 }
 
 
index 140719e12b35696e228fd957648f6abc8e57e322..844d82660b4241dcb988fdc1788c485b7c70e0e6 100644 (file)
@@ -108,20 +108,40 @@ void PassRegistry::enumerateWith(PassRegistrationListener *L) {
 
 
 /// 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());
+    }
   }
 }