[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Dominators.cpp Pass.cpp PassManager.cpp Verifier.cpp

Devang Patel dpatel at apple.com
Tue May 1 14:17:47 PDT 2007



Changes in directory llvm/lib/VMCore:

AsmWriter.cpp updated: 1.279 -> 1.280
Dominators.cpp updated: 1.97 -> 1.98
Pass.cpp updated: 1.87 -> 1.88
PassManager.cpp updated: 1.153 -> 1.154
Verifier.cpp updated: 1.209 -> 1.210
---
Log message:

Do not use typeinfo to identify pass in pass manager.


---
Diffs of the changes:  (+51 -32)

 AsmWriter.cpp   |    2 ++
 Dominators.cpp  |    3 +++
 Pass.cpp        |   29 ++++++++++++++---------------
 PassManager.cpp |   25 +++++++++++++++++--------
 Verifier.cpp    |   24 +++++++++++++++---------
 5 files changed, 51 insertions(+), 32 deletions(-)


Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.279 llvm/lib/VMCore/AsmWriter.cpp:1.280
--- llvm/lib/VMCore/AsmWriter.cpp:1.279	Sun Apr 29 13:35:00 2007
+++ llvm/lib/VMCore/AsmWriter.cpp	Tue May  1 16:15:47 2007
@@ -135,8 +135,10 @@
 
 }  // end namespace llvm
 
+const int PrintModulePass::ID = 0;
 static RegisterPass<PrintModulePass>
 X("printm", "Print module to stderr");
+const int PrintFunctionPass::ID = 0;
 static RegisterPass<PrintFunctionPass>
 Y("print","Print function to stderr");
 


Index: llvm/lib/VMCore/Dominators.cpp
diff -u llvm/lib/VMCore/Dominators.cpp:1.97 llvm/lib/VMCore/Dominators.cpp:1.98
--- llvm/lib/VMCore/Dominators.cpp:1.97	Fri Apr 20 19:36:45 2007
+++ llvm/lib/VMCore/Dominators.cpp	Tue May  1 16:15:47 2007
@@ -58,6 +58,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+const int DominatorTree::ID = 0;
 static RegisterPass<DominatorTree>
 E("domtree", "Dominator Tree Construction", true);
 
@@ -353,6 +354,7 @@
 //  DominanceFrontier Implementation
 //===----------------------------------------------------------------------===//
 
+const int DominanceFrontier::ID = 0;
 static RegisterPass<DominanceFrontier>
 G("domfrontier", "Dominance Frontier Construction", true);
 
@@ -833,6 +835,7 @@
 // ETForest implementation
 //===----------------------------------------------------------------------===//
 
+const int ETForest::ID = 0;
 static RegisterPass<ETForest>
 D("etforest", "ET Forest Construction", true);
 


Index: llvm/lib/VMCore/Pass.cpp
diff -u llvm/lib/VMCore/Pass.cpp:1.87 llvm/lib/VMCore/Pass.cpp:1.88
--- llvm/lib/VMCore/Pass.cpp:1.87	Thu Apr 26 16:33:42 2007
+++ llvm/lib/VMCore/Pass.cpp	Tue May  1 16:15:47 2007
@@ -133,7 +133,7 @@
 class PassRegistrar {
   /// PassInfoMap - Keep track of the passinfo object for each registered llvm
   /// pass.
-  std::map<TypeInfo, PassInfo*> PassInfoMap;
+  std::map<intptr_t, PassInfo*> PassInfoMap;
   
   /// AnalysisGroupInfo - Keep track of information for each analysis group.
   struct AnalysisGroupInfo {
@@ -147,19 +147,19 @@
 
 public:
   
-  const PassInfo *GetPassInfo(const std::type_info &TI) const {
-    std::map<TypeInfo, PassInfo*>::const_iterator I = PassInfoMap.find(TI);
+  const PassInfo *GetPassInfo(intptr_t TI) const {
+    std::map<intptr_t, PassInfo*>::const_iterator I = PassInfoMap.find(TI);
     return I != PassInfoMap.end() ? I->second : 0;
   }
   
   void RegisterPass(PassInfo &PI) {
     bool Inserted =
-      PassInfoMap.insert(std::make_pair(TypeInfo(PI.getTypeInfo()),&PI)).second;
+      PassInfoMap.insert(std::make_pair(PI.getTypeInfo(),&PI)).second;
     assert(Inserted && "Pass registered multiple times!");
   }
   
   void UnregisterPass(PassInfo &PI) {
-    std::map<TypeInfo, PassInfo*>::iterator I =
+    std::map<intptr_t, PassInfo*>::iterator I =
       PassInfoMap.find(PI.getTypeInfo());
     assert(I != PassInfoMap.end() && "Pass registered but not in map!");
     
@@ -168,7 +168,7 @@
   }
   
   void EnumerateWith(PassRegistrationListener *L) {
-    for (std::map<TypeInfo, PassInfo*>::const_iterator I = PassInfoMap.begin(),
+    for (std::map<intptr_t, PassInfo*>::const_iterator I = PassInfoMap.begin(),
          E = PassInfoMap.end(); I != E; ++I)
       L->passEnumerate(I->second);
   }
@@ -210,11 +210,10 @@
 // getPassInfo - Return the PassInfo data structure that corresponds to this
 // pass...
 const PassInfo *Pass::getPassInfo() const {
-  if (PassInfoCache) return PassInfoCache;
-  return lookupPassInfo(typeid(*this));
+  return lookupPassInfo(PassID);
 }
 
-const PassInfo *Pass::lookupPassInfo(const std::type_info &TI) {
+const PassInfo *Pass::lookupPassInfo(intptr_t TI) {
   return getPassRegistrar()->GetPassInfo(TI);
 }
 
@@ -238,12 +237,12 @@
 
 // RegisterAGBase implementation
 //
-RegisterAGBase::RegisterAGBase(const std::type_info &Interface,
-                               const std::type_info *Pass, bool isDefault)
-  : RegisterPassBase(Interface),
+RegisterAGBase::RegisterAGBase(intptr_t InterfaceID,
+                               intptr_t PassID, bool isDefault)
+  : RegisterPassBase(InterfaceID),
     ImplementationInfo(0), isDefaultImplementation(isDefault) {
 
-  InterfaceInfo = const_cast<PassInfo*>(Pass::lookupPassInfo(Interface));
+  InterfaceInfo = const_cast<PassInfo*>(Pass::lookupPassInfo(InterfaceID));
   if (InterfaceInfo == 0) {
     // First reference to Interface, register it now.
     registerPass();
@@ -252,8 +251,8 @@
   assert(PIObj.isAnalysisGroup() &&
          "Trying to join an analysis group that is a normal pass!");
 
-  if (Pass) {
-    ImplementationInfo = Pass::lookupPassInfo(*Pass);
+  if (PassID) {
+    ImplementationInfo = Pass::lookupPassInfo(PassID);
     assert(ImplementationInfo &&
            "Must register pass before adding to AnalysisGroup!");
 


Index: llvm/lib/VMCore/PassManager.cpp
diff -u llvm/lib/VMCore/PassManager.cpp:1.153 llvm/lib/VMCore/PassManager.cpp:1.154
--- llvm/lib/VMCore/PassManager.cpp:1.153	Thu Apr 26 12:50:19 2007
+++ llvm/lib/VMCore/PassManager.cpp	Tue May  1 16:15:47 2007
@@ -63,7 +63,9 @@
                                         public FunctionPass {
 
 public:
-  BBPassManager(int Depth) : PMDataManager(Depth) { }
+  static const int ID;
+  BBPassManager(int Depth) 
+    : PMDataManager(Depth), FunctionPass((intptr_t)&ID) {}
 
   /// Execute all of the passes scheduled for execution.  Keep track of
   /// whether any of the passes modifies the function, and if so, return true.
@@ -104,6 +106,7 @@
   }
 };
 
+const int BBPassManager::ID = 0;
 }
 
 namespace llvm {
@@ -116,9 +119,10 @@
                                 public PMDataManager,
                                 public PMTopLevelManager {
 public:
-
-  FunctionPassManagerImpl(int Depth) : PMDataManager(Depth),
-                                       PMTopLevelManager(TLM_Function) { }
+  static const int ID;
+  FunctionPassManagerImpl(int Depth) : 
+    Pass((intptr_t)&ID), PMDataManager(Depth), 
+    PMTopLevelManager(TLM_Function) { }
 
   /// add - Add a pass to the queue of passes to run.  This passes ownership of
   /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
@@ -167,9 +171,9 @@
     FPPassManager *FP = static_cast<FPPassManager *>(PassManagers[N]);
     return FP;
   }
-
 };
 
+const int FunctionPassManagerImpl::ID = 0;
 //===----------------------------------------------------------------------===//
 // MPPassManager
 //
@@ -179,7 +183,8 @@
 class MPPassManager : public Pass, public PMDataManager {
  
 public:
-  MPPassManager(int Depth) : PMDataManager(Depth) { }
+  static const int ID;
+  MPPassManager(int Depth) : Pass((intptr_t)&ID), PMDataManager(Depth) { }
 
   // Delete on the fly managers.
   virtual ~MPPassManager() {
@@ -242,17 +247,19 @@
   std::map<Pass *, FunctionPassManagerImpl *> OnTheFlyManagers;
 };
 
+const int MPPassManager::ID = 0;
 //===----------------------------------------------------------------------===//
 // PassManagerImpl
 //
+
 /// PassManagerImpl manages MPPassManagers
 class PassManagerImpl : public Pass,
                         public PMDataManager,
                         public PMTopLevelManager {
 
 public:
-
-  PassManagerImpl(int Depth) : PMDataManager(Depth),
+  static const int ID;
+  PassManagerImpl(int Depth) : Pass((intptr_t)&ID), PMDataManager(Depth),
                                PMTopLevelManager(TLM_Pass) { }
 
   /// add - Add a pass to the queue of passes to run.  This passes ownership of
@@ -297,6 +304,7 @@
 
 };
 
+const int PassManagerImpl::ID = 0;
 } // End of llvm namespace
 
 namespace {
@@ -1100,6 +1108,7 @@
 //===----------------------------------------------------------------------===//
 // FPPassManager implementation
 
+const int FPPassManager::ID = 0;
 /// Print passes managed by this manager
 void FPPassManager::dumpPassStructure(unsigned Offset) {
   llvm::cerr << std::string(Offset*2, ' ') << "FunctionPass Manager\n";


Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.209 llvm/lib/VMCore/Verifier.cpp:1.210
--- llvm/lib/VMCore/Verifier.cpp:1.209	Sun Apr 29 13:02:48 2007
+++ llvm/lib/VMCore/Verifier.cpp	Tue May  1 16:15:47 2007
@@ -69,6 +69,7 @@
 
   struct VISIBILITY_HIDDEN
      Verifier : public FunctionPass, InstVisitor<Verifier> {
+    static const int ID; // Pass ID, replacement for typeid
     bool Broken;          // Is this module found to be broken?
     bool RealPass;        // Are we not being run by a PassManager?
     VerifierFailureAction action;
@@ -84,18 +85,22 @@
     SmallPtrSet<Instruction*, 16> InstsInThisBlock;
 
     Verifier()
-        : Broken(false), RealPass(true), action(AbortProcessAction),
-          EF(0), msgs( std::ios::app | std::ios::out ) {}
+      : FunctionPass((intptr_t)&ID), 
+      Broken(false), RealPass(true), action(AbortProcessAction),
+      EF(0), msgs( std::ios::app | std::ios::out ) {}
     Verifier( VerifierFailureAction ctn )
-        : Broken(false), RealPass(true), action(ctn), EF(0),
-          msgs( std::ios::app | std::ios::out ) {}
+      : FunctionPass((intptr_t)&ID), 
+      Broken(false), RealPass(true), action(ctn), EF(0),
+      msgs( std::ios::app | std::ios::out ) {}
     Verifier(bool AB )
-        : Broken(false), RealPass(true),
-          action( AB ? AbortProcessAction : PrintMessageAction), EF(0),
-          msgs( std::ios::app | std::ios::out ) {}
+      : FunctionPass((intptr_t)&ID), 
+      Broken(false), RealPass(true),
+      action( AB ? AbortProcessAction : PrintMessageAction), EF(0),
+      msgs( std::ios::app | std::ios::out ) {}
     Verifier(ETForest &ef)
-      : Broken(false), RealPass(false), action(PrintMessageAction),
-        EF(&ef), msgs( std::ios::app | std::ios::out ) {}
+      : FunctionPass((intptr_t)&ID), 
+      Broken(false), RealPass(false), action(PrintMessageAction),
+      EF(&ef), msgs( std::ios::app | std::ios::out ) {}
 
 
     bool doInitialization(Module &M) {
@@ -261,6 +266,7 @@
     }
   };
 
+  const int Verifier::ID = 0;
   RegisterPass<Verifier> X("verify", "Module Verifier");
 } // End anonymous namespace
 






More information about the llvm-commits mailing list