llvm.org GIT mirror llvm / d8cc7be
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 Owen Anderson 9 years ago
12 changed file(s) with 50 addition(s) and 62 deletion(s). Raw diff Collapse all Expand all
12461246
12471247

Although Pass Registration is optional for normal

12481248 passes, all analysis group implementations must be registered, and must use the
1249 RegisterAnalysisGroup template to join the
1249 INITIALIZE_AG_PASS template to join the
12501250 implementation pool. Also, a default implementation of the interface
12511251 must be registered with
12521252 href="#registerag">RegisterAnalysisGroup.

12821282
12831283
12841284

The RegisterAnalysisGroup template is used to register the analysis

1285 group itself as well as add pass implementations to the analysis group. First,
1286 an analysis should be registered, with a human readable name provided for it.
1285 group itself, while the INITIALIZE_AG_PASS is used to add pass
1286 implementations to the analysis group. First,
1287 an analysis group should be registered, with a human readable name
1288 provided for it.
12871289 Unlike registration of passes, there is no command line argument to be specified
12881290 for the Analysis Group Interface itself, because it is "abstract":

12891291
12961298
12971299

                  
                
12981300 namespace {
1299 // Analysis Group implementations must be registered normally...
1300 RegisterPass<FancyAA>
1301 B("somefancyaa", "A more complex alias analysis implementation");
1302
13031301 // Declare that we implement the AliasAnalysis interface
1304 RegisterAnalysisGroup<AliasAnalysis> C(B);
1302 INITIALIZE_AG_PASS(FancyAA, AliasAnalysis, "somefancyaa",
1303 "A more complex alias analysis implementation",
1304 false, // Is CFG Only?
1305 true, // Is Analysis?
1306 false, // Is default Analysis Group implementation?
1307 );
13051308 }
13061309
13071310
1308

This just shows a class FancyAA that is registered normally, then

1309 uses the RegisterAnalysisGroup template to "join" the
1310 href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html">AliasAnalysis
1311

This just shows a class FancyAA that

1312 uses the INITIALIZE_AG_PASS macro both to register and
1313 to "join" the AliasAnalysis
13111314 analysis group. Every implementation of an analysis group should join using
1312 this template. A single pass may join multiple different analysis groups with
1313 no problem.

1315 this macro.

13141316
13151317

                  
                
13161318 namespace {
1317 // Analysis Group implementations must be registered normally...
1318 RegisterPass<BasicAliasAnalysis>
1319 D("basicaa", "Basic Alias Analysis (default AA impl)");
1320
13211319 // Declare that we implement the AliasAnalysis interface
1322 RegisterAnalysisGroup<AliasAnalysis, true> E(D);
1320 INITIALIZE_AG_PASS(BasicAA, AliasAnalysis, "basicaa",
1321 "Basic Alias Analysis (default AA impl)",
1322 false, // Is CFG Only?
1323 true, // Is Analysis?
1324 true, // Is default Analysis Group implementation?
1325 );
13231326 }
13241327
13251328
1326

Here we show how the default implementation is specified (using the extra

1327 argument to the RegisterAnalysisGroup template). There must be exactly
1329

Here we show how the default implementation is specified (using the final

1330 argument to the INITIALIZE_AG_PASS template). There must be exactly
13281331 one default implementation available at all times for an Analysis Group to be
13291332 used. Only default implementation can derive from ImmutablePass.
13301333 Here we declare that the
208208 }
209209 };
210210
211
211 #define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \
212 static RegisterPass passName ## _info(arg, name, cfg, analysis); \
213 static RegisterAnalysisGroup passName ## _ag(passName ## _info)
212214
213215 //===---------------------------------------------------------------------------
214216 /// PassRegistrationListener class - This class is meant to be derived from by
110110 }
111111
112112 char AliasAnalysisCounter::ID = 0;
113 static RegisterPass
114 X("count-aa", "Count Alias Analysis Query Responses", false, true);
115 static RegisterAnalysisGroup Y(X);
113 INITIALIZE_AG_PASS(AliasAnalysisCounter, AliasAnalysis, "count-aa",
114 "Count Alias Analysis Query Responses", false, true, false);
116115
117116 ModulePass *llvm::createAliasAnalysisCounterPass() {
118117 return new AliasAnalysisCounter();
125125 }
126126
127127 char AliasDebugger::ID = 0;
128 static RegisterPass
129 X("debug-aa", "AA use debugger", false, true);
130 static RegisterAnalysisGroup Y(X);
128 INITIALIZE_AG_PASS(AliasDebugger, AliasAnalysis, "debug-aa",
129 "AA use debugger", false, true, false);
131130
132131 Pass *llvm::createAliasDebugger() { return new AliasDebugger(); }
133132
181181
182182 // Register this pass...
183183 char NoAA::ID = 0;
184 static RegisterPass
185 U("no-aa", "No Alias Analysis (always returns 'may' alias)", true, true);
186
187 // Declare that we implement the AliasAnalysis interface
188 static RegisterAnalysisGroup V(U);
184 INITIALIZE_AG_PASS(NoAA, AliasAnalysis, "no-aa",
185 "No Alias Analysis (always returns 'may' alias)",
186 true, true, false);
189187
190188 ImmutablePass *llvm::createNoAAPass() { return new NoAA(); }
191189
274272
275273 // Register this pass...
276274 char BasicAliasAnalysis::ID = 0;
277 static RegisterPass
278 X("basicaa", "Basic Alias Analysis (default AA impl)", false, true);
279
280 // Declare that we implement the AliasAnalysis interface
281 static RegisterAnalysisGroup Y(X);
275 INITIALIZE_AG_PASS(BasicAliasAnalysis, AliasAnalysis, "basicaa",
276 "Basic Alias Analysis (default AA impl)",
277 false, true, true);
282278
283279 ImmutablePass *llvm::createBasicAliasAnalysisPass() {
284280 return new BasicAliasAnalysis();
6161 }
6262
6363 char CFGOnlyViewer::ID = 0;
64 static RegisterPass
65 V1("view-cfg-only",
66 "View CFG of function (with no function bodies)", false, true);
64 INITIALIZE_PASS(CFGOnlyViewer, "view-cfg-only",
65 "View CFG of function (with no function bodies)", false, true);
6766
6867 namespace {
6968 struct CFGPrinter : public FunctionPass {
171171 } //End anonymous namespace
172172
173173 static RegisterAnalysisGroup X("Call Graph");
174 static RegisterPass
175 Y("basiccg", "Basic CallGraph Construction", false, true);
176 static RegisterAnalysisGroup Z(Y);
174 INITIALIZE_AG_PASS(BasicCallGraph, CallGraph, "basiccg",
175 "Basic CallGraph Construction", false, true, true);
177176
178177 char CallGraph::ID = 0;
179178 char BasicCallGraph::ID = 0;
2222 using namespace llvm;
2323
2424 char FindUsedTypes::ID = 0;
25 static RegisterPass
26 X("print-used-types", "Find Used Types", false, true);
25 INITIALIZE_PASS(FindUsedTypes, "print-used-types",
26 "Find Used Types", false, true);
2727
2828 // IncorporateType - Incorporate one type and all of its subtypes into the
2929 // collection of used types.
1919
2020 // Register this pass...
2121 char LibCallAliasAnalysis::ID = 0;
22 static RegisterPass
23 X("libcall-aa", "LibCall Alias Analysis", false, true);
24
25 // Declare that we implement the AliasAnalysis interface
26 static RegisterAnalysisGroup Y(X);
22 INITIALIZE_AG_PASS(LibCallAliasAnalysis, AliasAnalysis, "libcall-aa",
23 "LibCall Alias Analysis", false, true, false);
2724
2825 FunctionPass *llvm::createLibCallAliasAnalysisPass(LibCallInfo *LCI) {
2926 return new LibCallAliasAnalysis(LCI);
5252 // PostDominanceFrontier Implementation
5353 //===----------------------------------------------------------------------===//
5454
55 static RegisterPass
56 H("postdomfrontier", "Post-Dominance Frontier Construction", true, true);
55 INITIALIZE_PASS(PostDominanceFrontier, "postdomfrontier",
56 "Post-Dominance Frontier Construction", true, true);
5757
5858 const DominanceFrontier::DomSetType &
5959 PostDominanceFrontier::calculate(const PostDominatorTree &DT,
10951095
10961096 char NoProfileInfo::ID = 0;
10971097 // Register this pass...
1098 static RegisterPass
1099 X("no-profile", "No Profile Information", false, true);
1100
1101 // Declare that we implement the ProfileInfo interface
1102 static RegisterAnalysisGroup Y(X);
1098 INITIALIZE_AG_PASS(NoProfileInfo, ProfileInfo, "no-profile",
1099 "No Profile Information", false, true, true);
11031100
11041101 ImmutablePass *llvm::createNoProfileInfoPass() { return new NoProfileInfo(); }
5757
5858 // Register this pass...
5959 char ScalarEvolutionAliasAnalysis::ID = 0;
60 static RegisterPass
61 X("scev-aa", "ScalarEvolution-based Alias Analysis", false, true);
62
63 // Declare that we implement the AliasAnalysis interface
64 static RegisterAnalysisGroup Y(X);
60 INITIALIZE_AG_PASS(ScalarEvolutionAliasAnalysis, AliasAnalysis, "scev-aa",
61 "ScalarEvolution-based Alias Analysis", false, true, false);
6562
6663 FunctionPass *llvm::createScalarEvolutionAliasAnalysisPass() {
6764 return new ScalarEvolutionAliasAnalysis();