From: Owen Anderson Date: Wed, 21 Jul 2010 23:07:00 +0000 (+0000) Subject: Add INSTANTIATE_AG_PASS, which combines RegisterPass<> with RegisterAnalysisGroup... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=d8cc7be0262092882d848a1c7d8a4cb6752cce6f Add INSTANTIATE_AG_PASS, which combines RegisterPass<> with RegisterAnalysisGroup<> for pass registration. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109058 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/WritingAnLLVMPass.html b/docs/WritingAnLLVMPass.html index f6360a19c32..3cef2c93448 100644 --- a/docs/WritingAnLLVMPass.html +++ b/docs/WritingAnLLVMPass.html @@ -1247,7 +1247,7 @@ between passes still apply.

Although Pass Registration is optional for normal passes, all analysis group implementations must be registered, and must use the -RegisterAnalysisGroup template to join the +INITIALIZE_AG_PASS template to join the implementation pool. Also, a default implementation of the interface must be registered with RegisterAnalysisGroup.

@@ -1283,8 +1283,10 @@ hypothetical example) instead.

The RegisterAnalysisGroup template is used to register the analysis -group itself as well as add pass implementations to the analysis group. First, -an analysis should be registered, with a human readable name provided for it. +group itself, while the INITIALIZE_AG_PASS is used to add pass +implementations to the analysis group. First, +an analysis group should be registered, with a human readable name +provided for it. Unlike registration of passes, there is no command line argument to be specified for the Analysis Group Interface itself, because it is "abstract":

@@ -1297,35 +1299,36 @@ implementations of the interface by using the following code:

 namespace {
-  // Analysis Group implementations must be registered normally...
-  RegisterPass<FancyAA>
-  B("somefancyaa", "A more complex alias analysis implementation");
-
   // Declare that we implement the AliasAnalysis interface
-  RegisterAnalysisGroup<AliasAnalysis> C(B);
+  INITIALIZE_AG_PASS(FancyAA, AliasAnalysis, "somefancyaa",
+                     "A more complex alias analysis implementation",
+                     false, // Is CFG Only?
+                     true,  // Is Analysis?
+                     false, // Is default Analysis Group implementation?
+                    );
 }
 
-

This just shows a class FancyAA that is registered normally, then -uses the RegisterAnalysisGroup template to "join" the AliasAnalysis +

This just shows a class FancyAA that +uses the INITIALIZE_AG_PASS macro both to register and +to "join" the AliasAnalysis analysis group. Every implementation of an analysis group should join using -this template. A single pass may join multiple different analysis groups with -no problem.

+this macro.

 namespace {
-  // Analysis Group implementations must be registered normally...
-  RegisterPass<BasicAliasAnalysis>
-  D("basicaa", "Basic Alias Analysis (default AA impl)");
-
   // Declare that we implement the AliasAnalysis interface
-  RegisterAnalysisGroup<AliasAnalysis, true> E(D);
+  INITIALIZE_AG_PASS(BasicAA, AliasAnalysis, "basicaa",
+                     "Basic Alias Analysis (default AA impl)",
+                     false, // Is CFG Only?
+                     true,  // Is Analysis?
+                     true, // Is default Analysis Group implementation?
+                    );
 }
 
-

Here we show how the default implementation is specified (using the extra -argument to the RegisterAnalysisGroup template). There must be exactly +

Here we show how the default implementation is specified (using the final +argument to the INITIALIZE_AG_PASS template). There must be exactly one default implementation available at all times for an Analysis Group to be used. Only default implementation can derive from ImmutablePass. Here we declare that the diff --git a/include/llvm/PassSupport.h b/include/llvm/PassSupport.h index 4e936c1b213..07dc7f1d15c 100644 --- a/include/llvm/PassSupport.h +++ b/include/llvm/PassSupport.h @@ -209,7 +209,9 @@ struct RegisterAnalysisGroup : public RegisterAGBase { } }; - +#define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \ + static RegisterPass passName ## _info(arg, name, cfg, analysis); \ + static RegisterAnalysisGroup passName ## _ag(passName ## _info) //===--------------------------------------------------------------------------- /// PassRegistrationListener class - This class is meant to be derived from by diff --git a/lib/Analysis/AliasAnalysisCounter.cpp b/lib/Analysis/AliasAnalysisCounter.cpp index 1053955ea23..25786c78637 100644 --- a/lib/Analysis/AliasAnalysisCounter.cpp +++ b/lib/Analysis/AliasAnalysisCounter.cpp @@ -111,9 +111,8 @@ namespace { } char AliasAnalysisCounter::ID = 0; -static RegisterPass -X("count-aa", "Count Alias Analysis Query Responses", false, true); -static RegisterAnalysisGroup Y(X); +INITIALIZE_AG_PASS(AliasAnalysisCounter, AliasAnalysis, "count-aa", + "Count Alias Analysis Query Responses", false, true, false); ModulePass *llvm::createAliasAnalysisCounterPass() { return new AliasAnalysisCounter(); diff --git a/lib/Analysis/AliasDebugger.cpp b/lib/Analysis/AliasDebugger.cpp index bc2d9c55d18..79bc99e2006 100644 --- a/lib/Analysis/AliasDebugger.cpp +++ b/lib/Analysis/AliasDebugger.cpp @@ -126,9 +126,8 @@ namespace { } char AliasDebugger::ID = 0; -static RegisterPass -X("debug-aa", "AA use debugger", false, true); -static RegisterAnalysisGroup Y(X); +INITIALIZE_AG_PASS(AliasDebugger, AliasAnalysis, "debug-aa", + "AA use debugger", false, true, false); Pass *llvm::createAliasDebugger() { return new AliasDebugger(); } diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 4f53a6d6255..b025ec623c3 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -182,11 +182,9 @@ namespace { // Register this pass... char NoAA::ID = 0; -static RegisterPass -U("no-aa", "No Alias Analysis (always returns 'may' alias)", true, true); - -// Declare that we implement the AliasAnalysis interface -static RegisterAnalysisGroup V(U); +INITIALIZE_AG_PASS(NoAA, AliasAnalysis, "no-aa", + "No Alias Analysis (always returns 'may' alias)", + true, true, false); ImmutablePass *llvm::createNoAAPass() { return new NoAA(); } @@ -275,11 +273,9 @@ namespace { // Register this pass... char BasicAliasAnalysis::ID = 0; -static RegisterPass -X("basicaa", "Basic Alias Analysis (default AA impl)", false, true); - -// Declare that we implement the AliasAnalysis interface -static RegisterAnalysisGroup Y(X); +INITIALIZE_AG_PASS(BasicAliasAnalysis, AliasAnalysis, "basicaa", + "Basic Alias Analysis (default AA impl)", + false, true, true); ImmutablePass *llvm::createBasicAliasAnalysisPass() { return new BasicAliasAnalysis(); diff --git a/lib/Analysis/CFGPrinter.cpp b/lib/Analysis/CFGPrinter.cpp index c16f3286df2..da2f0a6dbf0 100644 --- a/lib/Analysis/CFGPrinter.cpp +++ b/lib/Analysis/CFGPrinter.cpp @@ -62,9 +62,8 @@ namespace { } char CFGOnlyViewer::ID = 0; -static RegisterPass -V1("view-cfg-only", - "View CFG of function (with no function bodies)", false, true); +INITIALIZE_PASS(CFGOnlyViewer, "view-cfg-only", + "View CFG of function (with no function bodies)", false, true); namespace { struct CFGPrinter : public FunctionPass { diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index 65c7c6efd80..0e474e66682 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -172,9 +172,8 @@ private: } //End anonymous namespace static RegisterAnalysisGroup X("Call Graph"); -static RegisterPass -Y("basiccg", "Basic CallGraph Construction", false, true); -static RegisterAnalysisGroup Z(Y); +INITIALIZE_AG_PASS(BasicCallGraph, CallGraph, "basiccg", + "Basic CallGraph Construction", false, true, true); char CallGraph::ID = 0; char BasicCallGraph::ID = 0; diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index c4fb0b9a4e3..8eed9d6f68b 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -23,8 +23,8 @@ using namespace llvm; char FindUsedTypes::ID = 0; -static RegisterPass -X("print-used-types", "Find Used Types", false, true); +INITIALIZE_PASS(FindUsedTypes, "print-used-types", + "Find Used Types", false, true); // IncorporateType - Incorporate one type and all of its subtypes into the // collection of used types. diff --git a/lib/Analysis/LibCallAliasAnalysis.cpp b/lib/Analysis/LibCallAliasAnalysis.cpp index 74196592989..9dca93f9e76 100644 --- a/lib/Analysis/LibCallAliasAnalysis.cpp +++ b/lib/Analysis/LibCallAliasAnalysis.cpp @@ -20,11 +20,8 @@ using namespace llvm; // Register this pass... char LibCallAliasAnalysis::ID = 0; -static RegisterPass -X("libcall-aa", "LibCall Alias Analysis", false, true); - -// Declare that we implement the AliasAnalysis interface -static RegisterAnalysisGroup Y(X); +INITIALIZE_AG_PASS(LibCallAliasAnalysis, AliasAnalysis, "libcall-aa", + "LibCall Alias Analysis", false, true, false); FunctionPass *llvm::createLibCallAliasAnalysisPass(LibCallInfo *LCI) { return new LibCallAliasAnalysis(LCI); diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index 51eb1452580..cbe8d1867e4 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -53,8 +53,8 @@ FunctionPass* llvm::createPostDomTree() { // PostDominanceFrontier Implementation //===----------------------------------------------------------------------===// -static RegisterPass -H("postdomfrontier", "Post-Dominance Frontier Construction", true, true); +INITIALIZE_PASS(PostDominanceFrontier, "postdomfrontier", + "Post-Dominance Frontier Construction", true, true); const DominanceFrontier::DomSetType & PostDominanceFrontier::calculate(const PostDominatorTree &DT, diff --git a/lib/Analysis/ProfileInfo.cpp b/lib/Analysis/ProfileInfo.cpp index 8d2712fd6e0..eb33e78af78 100644 --- a/lib/Analysis/ProfileInfo.cpp +++ b/lib/Analysis/ProfileInfo.cpp @@ -1096,10 +1096,7 @@ namespace { char NoProfileInfo::ID = 0; // Register this pass... -static RegisterPass -X("no-profile", "No Profile Information", false, true); - -// Declare that we implement the ProfileInfo interface -static RegisterAnalysisGroup Y(X); +INITIALIZE_AG_PASS(NoProfileInfo, ProfileInfo, "no-profile", + "No Profile Information", false, true, true); ImmutablePass *llvm::createNoProfileInfoPass() { return new NoProfileInfo(); } diff --git a/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp b/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp index 58711b8be59..b3d90cb5c12 100644 --- a/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp +++ b/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp @@ -58,11 +58,8 @@ namespace { // Register this pass... char ScalarEvolutionAliasAnalysis::ID = 0; -static RegisterPass -X("scev-aa", "ScalarEvolution-based Alias Analysis", false, true); - -// Declare that we implement the AliasAnalysis interface -static RegisterAnalysisGroup Y(X); +INITIALIZE_AG_PASS(ScalarEvolutionAliasAnalysis, AliasAnalysis, "scev-aa", + "ScalarEvolution-based Alias Analysis", false, true, false); FunctionPass *llvm::createScalarEvolutionAliasAnalysisPass() { return new ScalarEvolutionAliasAnalysis();