[llvm-commits] [llvm] r115703 - in /llvm/trunk: include/llvm/PassSupport.h lib/VMCore/Pass.cpp

Owen Anderson resistor at mac.com
Tue Oct 5 15:58:16 PDT 2010


Author: resistor
Date: Tue Oct  5 17:58:16 2010
New Revision: 115703

URL: http://llvm.org/viewvc/llvm-project?rev=115703&view=rev
Log:
Another step towards getting rid of static ctors for pass registration: have INITIALIZE_PASS AND INITIALIZE_AG_PASS
expand to an initializeMyPass() function (in additional to the extant static ctors).  Eventually, these will be called
from a big InitializeAllPasses() function, and the PassInfo's they create (which would be leaked if this code were used
at the moment) will be handed off to a PassRegistry for ownership.

Modified:
    llvm/trunk/include/llvm/PassSupport.h
    llvm/trunk/lib/VMCore/Pass.cpp

Modified: llvm/trunk/include/llvm/PassSupport.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassSupport.h?rev=115703&r1=115702&r2=115703&view=diff
==============================================================================
--- llvm/trunk/include/llvm/PassSupport.h (original)
+++ llvm/trunk/include/llvm/PassSupport.h Tue Oct  5 17:58:16 2010
@@ -55,17 +55,14 @@
            NormalCtor_t normal, bool isCFGOnly, bool is_analysis)
     : PassName(name), PassArgument(arg), PassID(pi), 
       IsCFGOnlyPass(isCFGOnly), 
-      IsAnalysis(is_analysis), IsAnalysisGroup(false), NormalCtor(normal) {
-    PassRegistry::getPassRegistry()->registerPass(*this);
-  }
+      IsAnalysis(is_analysis), IsAnalysisGroup(false), NormalCtor(normal) { }
   /// PassInfo ctor - Do not call this directly, this should only be invoked
   /// through RegisterPass. This version is for use by analysis groups; it
   /// does not auto-register the pass.
   PassInfo(const char *name, const void *pi)
     : PassName(name), PassArgument(""), PassID(pi), 
       IsCFGOnlyPass(false), 
-      IsAnalysis(false), IsAnalysisGroup(true), NormalCtor(0) {
-  }
+      IsAnalysis(false), IsAnalysisGroup(true), NormalCtor(0) { }
 
   /// getPassName - Return the friendly name for the pass, never returns null
   ///
@@ -131,7 +128,13 @@
 };
 
 #define INITIALIZE_PASS(passName, arg, name, cfg, analysis) \
+  void initialize##passName##Pass() { \
+    PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \
+      PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
+    PassRegistry::getPassRegistry()->registerPass(*PI); \
+  } \
   static RegisterPass<passName> passName ## _info(arg, name, cfg, analysis)
+    
 
 template<typename PassName>
 Pass *callDefaultCtor() { return new PassName(); }
@@ -162,7 +165,7 @@
     : PassInfo(Name, PassArg, &passName::ID,
                PassInfo::NormalCtor_t(callDefaultCtor<passName>),
                CFGOnly, is_analysis) {
-    
+    PassRegistry::getPassRegistry()->registerPass(*this);
   }
 };
 
@@ -187,7 +190,7 @@
 /// a nice name with the interface.
 ///
 class RegisterAGBase : public PassInfo {
-protected:
+public:
   RegisterAGBase(const char *Name,
                  const void *InterfaceID,
                  const void *PassID = 0,
@@ -208,6 +211,15 @@
 };
 
 #define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \
+  void initialize##passName##Pass() { \
+    PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \
+      PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
+    PassRegistry::getPassRegistry()->registerPass(*PI); \
+    \
+    PassInfo *AI = new PassInfo(name, & agName :: ID); \
+    PassRegistry::getPassRegistry()->registerAnalysisGroup( \
+      & agName ::ID, & passName ::ID, *AI, def); \
+  } \
   static RegisterPass<passName> passName ## _info(arg, name, cfg, analysis); \
   static RegisterAnalysisGroup<agName, def> passName ## _ag(passName ## _info)
 

Modified: llvm/trunk/lib/VMCore/Pass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=115703&r1=115702&r2=115703&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Pass.cpp (original)
+++ llvm/trunk/lib/VMCore/Pass.cpp Tue Oct  5 17:58:16 2010
@@ -213,7 +213,6 @@
                                                          *this, isDefault);
 }
 
-
 //===----------------------------------------------------------------------===//
 // PassRegistrationListener implementation
 //





More information about the llvm-commits mailing list