llvm.org GIT mirror llvm / 081c34b
Get rid of static constructors for pass registration. Instead, every pass exposes an initializeMyPassFunction(), which must be called in the pass's constructor. This function uses static dependency declarations to recursively initialize the pass's dependencies. Clients that only create passes through the createFooPass() APIs will require no changes. Clients that want to use the CommandLine options for passes will need to manually call the appropriate initialization functions in PassInitialization.h before parsing commandline arguments. I have tested this with all standard configurations of clang and llvm-gcc on Darwin. It is possible that there are problems with the static dependencies that will only be visible with non-standard options. If you encounter any crash in pass registration/creation, please send the testcase to me directly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116820 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 9 years ago
140 changed file(s) with 561 addition(s) and 177 deletion(s). Raw diff Collapse all Expand all
716716 DominatorTreeBase* DT;
717717
718718 DominatorTree() : FunctionPass(ID) {
719 initializeDominatorTreePass(*PassRegistry::getPassRegistry());
719720 DT = new DominatorTreeBase(false);
720721 }
721722
10271028 public:
10281029 static char ID; // Pass ID, replacement for typeid
10291030 DominanceFrontier() :
1030 DominanceFrontierBase(ID, false) {}
1031 DominanceFrontierBase(ID, false) {
1032 initializeDominanceFrontierPass(*PassRegistry::getPassRegistry());
1033 }
10311034
10321035 BasicBlock *getRoot() const {
10331036 assert(Roots.size() == 1 && "Should always have entry node!");
2525 std::set UsedTypes;
2626 public:
2727 static char ID; // Pass identification, replacement for typeid
28 FindUsedTypes() : ModulePass(ID) {}
28 FindUsedTypes() : ModulePass(ID) {
29 initializeFindUsedTypesPass(*PassRegistry::getPassRegistry());
30 }
2931
3032 /// getTypes - After the pass has been run, return the set containing all of
3133 /// the types used in the module.
4747 public:
4848 static char ID; // Pass identification, replacement for typeid
4949
50 IntervalPartition() : FunctionPass(ID), RootInterval(0) {}
50 IntervalPartition() : FunctionPass(ID), RootInterval(0) {
51 initializeIntervalPartitionPass(*PassRegistry::getPassRegistry());
52 }
5153
5254 // run - Calculate the interval partition for this function
5355 virtual bool runOnFunction(Function &F);
3030 void operator=(const LazyValueInfo&); // DO NOT IMPLEMENT.
3131 public:
3232 static char ID;
33 LazyValueInfo() : FunctionPass(ID), PImpl(0) {}
33 LazyValueInfo() : FunctionPass(ID), PImpl(0) {
34 initializeLazyValueInfoPass(*PassRegistry::getPassRegistry());
35 }
3436 ~LazyValueInfo() { assert(PImpl == 0 && "releaseMemory not called"); }
3537
3638 /// Tristate - This is used to return true/false/dunno results.
2727 LibCallInfo *LCI;
2828
2929 explicit LibCallAliasAnalysis(LibCallInfo *LC = 0)
30 : FunctionPass(ID), LCI(LC) {
30 : FunctionPass(ID), LCI(LC) {
31 initializeLibCallAliasAnalysisPass(*PassRegistry::getPassRegistry());
3132 }
3233 explicit LibCallAliasAnalysis(char &ID, LibCallInfo *LC)
33 : FunctionPass(ID), LCI(LC) {
34 : FunctionPass(ID), LCI(LC) {
35 initializeLibCallAliasAnalysisPass(*PassRegistry::getPassRegistry());
3436 }
3537 ~LibCallAliasAnalysis();
3638
9090
9191 public:
9292 static char ID; // Class identification, replacement for typeinfo
93 LoopDependenceAnalysis() : LoopPass(ID) {}
93 LoopDependenceAnalysis() : LoopPass(ID) {
94 initializeLoopDependenceAnalysisPass(*PassRegistry::getPassRegistry());
95 }
9496
9597 /// isDependencePair - Check whether two values can possibly give rise to
9698 /// a data dependence: that is the case if both are instructions accessing
938938 public:
939939 static char ID; // Pass identification, replacement for typeid
940940
941 LoopInfo() : FunctionPass(ID) {}
941 LoopInfo() : FunctionPass(ID) {
942 initializeLoopInfoPass(*PassRegistry::getPassRegistry());
943 }
942944
943945 LoopInfoBase& getBase() { return LI; }
944946
2525 DominatorTreeBase* DT;
2626
2727 PostDominatorTree() : FunctionPass(ID) {
28 initializePostDominatorTreePass(*PassRegistry::getPassRegistry());
2829 DT = new DominatorTreeBase(true);
2930 }
3031
105106 struct PostDominanceFrontier : public DominanceFrontierBase {
106107 static char ID;
107108 PostDominanceFrontier()
108 : DominanceFrontierBase(ID, true) {}
109 : DominanceFrontierBase(ID, true) {
110 initializePostDominanceFrontierPass(*PassRegistry::getPassRegistry());
111 }
109112
110113 virtual bool runOnFunction(Function &) {
111114 Frontiers.clear();
4747 public:
4848 static char ID;
4949
50 CalculateSpillWeights() : MachineFunctionPass(ID) {}
50 CalculateSpillWeights() : MachineFunctionPass(ID) {
51 initializeCalculateSpillWeightsPass(*PassRegistry::getPassRegistry());
52 }
5153
5254 virtual void getAnalysisUsage(AnalysisUsage &au) const;
5355
6767
6868 public:
6969 static char ID; // Pass identification, replacement for typeid
70 LiveIntervals() : MachineFunctionPass(ID) {}
70 LiveIntervals() : MachineFunctionPass(ID) {
71 initializeLiveIntervalsPass(*PassRegistry::getPassRegistry());
72 }
7173
7274 // Calculate the spill weight to assign to a single instruction.
7375 static float getSpillWeight(bool isDef, bool isUse, unsigned loopDepth);
3838
3939 public:
4040 static char ID; // Pass identification, replacement for typeid
41 LiveStacks() : MachineFunctionPass(ID) {}
41 LiveStacks() : MachineFunctionPass(ID) {
42 initializeLiveStacksPass(*PassRegistry::getPassRegistry());
43 }
4244
4345 typedef SS2IntervalMap::iterator iterator;
4446 typedef SS2IntervalMap::const_iterator const_iterator;
4545 class LiveVariables : public MachineFunctionPass {
4646 public:
4747 static char ID; // Pass identification, replacement for typeid
48 LiveVariables() : MachineFunctionPass(ID) {}
48 LiveVariables() : MachineFunctionPass(ID) {
49 initializeLiveVariablesPass(*PassRegistry::getPassRegistry());
50 }
4951
5052 /// VarInfo - This represents the regions where a virtual register is live in
5153 /// the program. We represent this with three different pieces of
6666 public:
6767 static char ID; // Pass identification, replacement for typeid
6868
69 MachineLoopInfo() : MachineFunctionPass(ID) {}
69 MachineLoopInfo() : MachineFunctionPass(ID) {
70 initializeMachineLoopInfoPass(*PassRegistry::getPassRegistry());
71 }
7072
7173 LoopInfoBase& getBase() { return LI; }
7274
3030 public:
3131 static char ID;
3232
33 ProcessImplicitDefs() : MachineFunctionPass(ID) {}
33 ProcessImplicitDefs() : MachineFunctionPass(ID) {
34 initializeProcessImplicitDefsPass(*PassRegistry::getPassRegistry());
35 }
3436
3537 virtual void getAnalysisUsage(AnalysisUsage &au) const;
3638
468468 public:
469469 static char ID;
470470
471 SlotIndexes() : MachineFunctionPass(ID), indexListHead(0) {}
471 SlotIndexes() : MachineFunctionPass(ID), indexListHead(0) {
472 initializeSlotIndexesPass(*PassRegistry::getPassRegistry());
473 }
472474
473475 virtual void getAnalysisUsage(AnalysisUsage &au) const;
474476 virtual void releaseMemory();
131131 void initializeLoopUnrollPass(PassRegistry&);
132132 void initializeLoopUnswitchPass(PassRegistry&);
133133 void initializeLowerAtomicPass(PassRegistry&);
134 void initializeLowerIntrinsicsPass(PassRegistry&);
134135 void initializeLowerInvokePass(PassRegistry&);
135136 void initializeLowerSetJmpPass(PassRegistry&);
136137 void initializeLowerSwitchPass(PassRegistry&);
150150 sys::MemoryFence(); \
151151 } \
152152 } \
153 } \
154 static RegisterPass passName ## _info(arg, name, cfg, analysis);
153 }
155154
156155 #define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis) \
157156 static void* initialize##passName##PassOnce(PassRegistry &Registry) {
182181 sys::MemoryFence(); \
183182 } \
184183 } \
185 } \
186 static RegisterPass passName ## _info(arg, name, cfg, analysis);
184 }
187185
188186 template
189187 Pass *callDefaultCtor() { return new PassName(); }
281279 sys::MemoryFence(); \
282280 } \
283281 } \
284 } \
285 static RegisterAnalysisGroup agName##_info (name);
282 }
286283
287284
288285 #define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \
289286 static void* initialize##passName##PassOnce(PassRegistry &Registry) { \
287 if (!def) initialize##agName##AnalysisGroup(Registry); \
290288 PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \
291289 PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
292290 Registry.registerPass(*PI); \
310308 sys::MemoryFence(); \
311309 } \
312310 } \
313 } \
314 static RegisterPass passName ## _info(arg, name, cfg, analysis); \
315 static RegisterAnalysisGroup passName ## _ag(passName ## _info);
311 }
316312
317313
318314 #define INITIALIZE_AG_PASS_BEGIN(passName, agName, arg, n, cfg, analysis, def) \
319 static void* initialize##passName##PassOnce(PassRegistry &Registry) {
315 static void* initialize##passName##PassOnce(PassRegistry &Registry) { \
316 if (!def) initialize##agName##AnalysisGroup(Registry);
320317
321318 #define INITIALIZE_AG_PASS_END(passName, agName, arg, n, cfg, analysis, def) \
322319 PassInfo *PI = new PassInfo(n, arg, & passName ::ID, \
342339 sys::MemoryFence(); \
343340 } \
344341 } \
345 } \
346 static RegisterPass passName ## _info(arg, n, cfg, analysis); \
347 static RegisterAnalysisGroup passName ## _ag(passName ## _info);
342 }
348343
349344 //===---------------------------------------------------------------------------
350345 /// PassRegistrationListener class - This class is meant to be derived from by
2626 public:
2727 static char ID; // Pass identification, replacement for typeid
2828 UnifyFunctionExitNodes() : FunctionPass(ID),
29 ReturnBlock(0), UnwindBlock(0) {}
29 ReturnBlock(0), UnwindBlock(0) {
30 initializeUnifyFunctionExitNodesPass(*PassRegistry::getPassRegistry());
31 }
3032
3133 // We can preserve non-critical-edgeness when we unify function exit nodes
3234 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
3535 using namespace llvm;
3636
3737 // Register the AliasAnalysis interface, providing a nice name to refer to.
38 INITIALIZE_ANALYSIS_GROUP(AliasAnalysis, "Alias Analysis", BasicAliasAnalysis)
38 INITIALIZE_ANALYSIS_GROUP(AliasAnalysis, "Alias Analysis", NoAA)
3939 char AliasAnalysis::ID = 0;
4040
4141 //===----------------------------------------------------------------------===//
3434 public:
3535 static char ID; // Class identification, replacement for typeinfo
3636 AliasAnalysisCounter() : ModulePass(ID) {
37 initializeAliasAnalysisCounterPass(*PassRegistry::getPassRegistry());
3738 No = May = Must = 0;
3839 NoMR = JustRef = JustMod = MR = 0;
3940 }
4949
5050 public:
5151 static char ID; // Pass identification, replacement for typeid
52 AAEval() : FunctionPass(ID) {}
52 AAEval() : FunctionPass(ID) {
53 initializeAAEvalPass(*PassRegistry::getPassRegistry());
54 }
5355
5456 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
5557 AU.addRequired();
3838
3939 public:
4040 static char ID; // Class identification, replacement for typeinfo
41 AliasDebugger() : ModulePass(ID) {}
41 AliasDebugger() : ModulePass(ID) {
42 initializeAliasDebuggerPass(*PassRegistry::getPassRegistry());
43 }
4244
4345 bool runOnModule(Module &M) {
4446 InitializeAliasAnalysis(this); // set up super class
613613 AliasSetTracker *Tracker;
614614 public:
615615 static char ID; // Pass identification, replacement for typeid
616 AliasSetPrinter() : FunctionPass(ID) {}
616 AliasSetPrinter() : FunctionPass(ID) {
617 initializeAliasSetPrinterPass(*PassRegistry::getPassRegistry());
618 }
617619
618620 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
619621 AU.setPreservesAll();
139139 ///
140140 struct NoAA : public ImmutablePass, public AliasAnalysis {
141141 static char ID; // Class identification, replacement for typeinfo
142 NoAA() : ImmutablePass(ID) {}
143 explicit NoAA(char &PID) : ImmutablePass(PID) { }
142 NoAA() : ImmutablePass(ID) {
143 initializeNoAAPass(*PassRegistry::getPassRegistry());
144 }
145 explicit NoAA(char &PID) : ImmutablePass(PID) {}
144146
145147 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
146148 }
489491 /// derives from the NoAA class.
490492 struct BasicAliasAnalysis : public NoAA {
491493 static char ID; // Class identification, replacement for typeinfo
492 BasicAliasAnalysis() : NoAA(ID) {}
494 BasicAliasAnalysis() : NoAA(ID) {
495 initializeBasicAliasAnalysisPass(*PassRegistry::getPassRegistry());
496 }
493497
494498 virtual void initializePass() {
495499 InitializeAliasAnalysis(this);
2424 namespace {
2525 struct CFGViewer : public FunctionPass {
2626 static char ID; // Pass identifcation, replacement for typeid
27 CFGViewer() : FunctionPass(ID) {}
27 CFGViewer() : FunctionPass(ID) {
28 initializeCFGOnlyViewerPass(*PassRegistry::getPassRegistry());
29 }
2830
2931 virtual bool runOnFunction(Function &F) {
3032 F.viewCFG();
4547 namespace {
4648 struct CFGOnlyViewer : public FunctionPass {
4749 static char ID; // Pass identifcation, replacement for typeid
48 CFGOnlyViewer() : FunctionPass(ID) {}
50 CFGOnlyViewer() : FunctionPass(ID) {
51 initializeCFGOnlyViewerPass(*PassRegistry::getPassRegistry());
52 }
4953
5054 virtual bool runOnFunction(Function &F) {
5155 F.viewCFGOnly();
6771 namespace {
6872 struct CFGPrinter : public FunctionPass {
6973 static char ID; // Pass identification, replacement for typeid
70 CFGPrinter() : FunctionPass(ID) {}
74 CFGPrinter() : FunctionPass(ID) {
75 initializeCFGPrinterPass(*PassRegistry::getPassRegistry());
76 }
7177
7278 virtual bool runOnFunction(Function &F) {
7379 std::string Filename = "cfg." + F.getNameStr() + ".dot";
99105 namespace {
100106 struct CFGOnlyPrinter : public FunctionPass {
101107 static char ID; // Pass identification, replacement for typeid
102 CFGOnlyPrinter() : FunctionPass(ID) {}
108 CFGOnlyPrinter() : FunctionPass(ID) {
109 initializeCFGOnlyPrinterPass(*PassRegistry::getPassRegistry());
110 }
111
103112 virtual bool runOnFunction(Function &F) {
104113 std::string Filename = "cfg." + F.getNameStr() + ".dot";
105114 errs() << "Writing '" << Filename << "'...";
3939 void printVariableDeclaration(const Value *V);
4040 public:
4141 static char ID; // Pass identification
42 PrintDbgInfo() : FunctionPass(ID), Out(errs()) {}
42 PrintDbgInfo() : FunctionPass(ID), Out(errs()) {
43 initializePrintDbgInfoPass(*PassRegistry::getPassRegistry());
44 }
4345
4446 virtual bool runOnFunction(Function &F);
4547 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
8585 struct DomViewer
8686 : public DOTGraphTraitsViewer {
8787 static char ID;
88 DomViewer() : DOTGraphTraitsViewer("dom", ID){}
88 DomViewer() : DOTGraphTraitsViewer("dom", ID){
89 initializeDomViewerPass(*PassRegistry::getPassRegistry());
90 }
8991 };
9092
9193 struct DomOnlyViewer
9294 : public DOTGraphTraitsViewer {
9395 static char ID;
94 DomOnlyViewer() : DOTGraphTraitsViewer("domonly", ID){}
96 DomOnlyViewer() : DOTGraphTraitsViewer("domonly", ID){
97 initializeDomOnlyViewerPass(*PassRegistry::getPassRegistry());
98 }
9599 };
96100
97101 struct PostDomViewer
98102 : public DOTGraphTraitsViewer {
99103 static char ID;
100104 PostDomViewer() :
101 DOTGraphTraitsViewer("postdom", ID){}
105 DOTGraphTraitsViewer("postdom", ID){
106 initializePostDomViewerPass(*PassRegistry::getPassRegistry());
107 }
102108 };
103109
104110 struct PostDomOnlyViewer
105111 : public DOTGraphTraitsViewer {
106112 static char ID;
107113 PostDomOnlyViewer() :
108 DOTGraphTraitsViewer("postdomonly", ID){}
114 DOTGraphTraitsViewer("postdomonly", ID){
115 initializePostDomOnlyViewerPass(*PassRegistry::getPassRegistry());
116 }
109117 };
110118 } // end anonymous namespace
111119
132140 struct DomPrinter
133141 : public DOTGraphTraitsPrinter {
134142 static char ID;
135 DomPrinter() : DOTGraphTraitsPrinter("dom", ID) {}
143 DomPrinter() : DOTGraphTraitsPrinter("dom", ID) {
144 initializeDomPrinterPass(*PassRegistry::getPassRegistry());
145 }
136146 };
137147
138148 struct DomOnlyPrinter
139149 : public DOTGraphTraitsPrinter {
140150 static char ID;
141 DomOnlyPrinter() : DOTGraphTraitsPrinter("domonly", ID) {}
151 DomOnlyPrinter() : DOTGraphTraitsPrinter("domonly", ID) {
152 initializeDomOnlyPrinterPass(*PassRegistry::getPassRegistry());
153 }
142154 };
143155
144156 struct PostDomPrinter
145157 : public DOTGraphTraitsPrinter {
146158 static char ID;
147159 PostDomPrinter() :
148 DOTGraphTraitsPrinter("postdom", ID) {}
160 DOTGraphTraitsPrinter("postdom", ID) {
161 initializePostDomPrinterPass(*PassRegistry::getPassRegistry());
162 }
149163 };
150164
151165 struct PostDomOnlyPrinter
152166 : public DOTGraphTraitsPrinter {
153167 static char ID;
154168 PostDomOnlyPrinter() :
155 DOTGraphTraitsPrinter("postdomonly", ID) {}
169 DOTGraphTraitsPrinter("postdomonly", ID) {
170 initializePostDomOnlyPrinterPass(*PassRegistry::getPassRegistry());
171 }
156172 };
157173 } // end anonymous namespace
158174
4242 public:
4343 static char ID; // Class identification, replacement for typeinfo
4444 BasicCallGraph() : ModulePass(ID), Root(0),
45 ExternalCallingNode(0), CallsExternalNode(0) {}
45 ExternalCallingNode(0), CallsExternalNode(0) {
46 initializeBasicCallGraphPass(*PassRegistry::getPassRegistry());
47 }
4648
4749 // runOnModule - Compute the call graph for the specified module.
4850 virtual bool runOnModule(Module &M) {
8787
8888 public:
8989 static char ID;
90 GlobalsModRef() : ModulePass(ID) {}
90 GlobalsModRef() : ModulePass(ID) {
91 initializeGlobalsModRefPass(*PassRegistry::getPassRegistry());
92 }
9193
9294 bool runOnModule(Module &M) {
9395 InitializeAliasAnalysis(this); // set up super class
148148 }
149149
150150 IVUsers::IVUsers()
151 : LoopPass(ID) {
151 : LoopPass(ID) {
152 initializeIVUsersPass(*PassRegistry::getPassRegistry());
152153 }
153154
154155 void IVUsers::getAnalysisUsage(AnalysisUsage &AU) const {
5050 }
5151 public:
5252 static char ID; // Pass identification, replacement for typeid
53 InstCount() : FunctionPass(ID) {}
53 InstCount() : FunctionPass(ID) {
54 initializeInstCountPass(*PassRegistry::getPassRegistry());
55 }
5456
5557 virtual bool runOnFunction(Function &F);
5658
107107 raw_string_ostream MessagesStr;
108108
109109 static char ID; // Pass identification, replacement for typeid
110 Lint() : FunctionPass(ID), MessagesStr(Messages) {}
110 Lint() : FunctionPass(ID), MessagesStr(Messages) {
111 initializeLintPass(*PassRegistry::getPassRegistry());
112 }
111113
112114 virtual bool runOnFunction(Function &F);
113115
2828 INITIALIZE_PASS_END(LiveValues, "live-values",
2929 "Value Liveness Analysis", false, true)
3030
31 LiveValues::LiveValues() : FunctionPass(ID) {}
31 LiveValues::LiveValues() : FunctionPass(ID) {
32 initializeLiveValuesPass(*PassRegistry::getPassRegistry());
33 }
3234
3335 void LiveValues::getAnalysisUsage(AnalysisUsage &AU) const {
3436 AU.addRequired();
3030 DepSetMap Deps;
3131
3232 static char ID; // Pass identifcation, replacement for typeid
33 MemDepPrinter() : FunctionPass(ID) {}
33 MemDepPrinter() : FunctionPass(ID) {
34 initializeMemDepPrinterPass(*PassRegistry::getPassRegistry());
35 }
3436
3537 virtual bool runOnFunction(Function &F);
3638
5454
5555 MemoryDependenceAnalysis::MemoryDependenceAnalysis()
5656 : FunctionPass(ID), PredCache(0) {
57 initializeMemoryDependenceAnalysisPass(*PassRegistry::getPassRegistry());
5758 }
5859 MemoryDependenceAnalysis::~MemoryDependenceAnalysis() {
5960 }
2929 DebugInfoFinder Finder;
3030 public:
3131 static char ID; // Pass identification, replacement for typeid
32 ModuleDebugInfoPrinter() : ModulePass(ID) {}
32 ModuleDebugInfoPrinter() : ModulePass(ID) {
33 initializeModuleDebugInfoPrinterPass(*PassRegistry::getPassRegistry());
34 }
3335
3436 virtual bool runOnModule(Module &M);
3537
3838 public:
3939 static char ID; // Class identification, replacement for typeinfo
4040 explicit ProfileEstimatorPass(const double execcount = 0)
41 : FunctionPass(ID), ExecCount(execcount) {
41 : FunctionPass(ID), ExecCount(execcount) {
42 initializeProfileEstimatorPassPass(*PassRegistry::getPassRegistry());
4243 if (execcount == 0) ExecCount = LoopWeight;
4344 }
4445
10761076 namespace {
10771077 struct NoProfileInfo : public ImmutablePass, public ProfileInfo {
10781078 static char ID; // Class identification, replacement for typeinfo
1079 NoProfileInfo() : ImmutablePass(ID) {}
1079 NoProfileInfo() : ImmutablePass(ID) {
1080 initializeNoProfileInfoPass(*PassRegistry::getPassRegistry());
1081 }
10801082
10811083 /// getAdjustedAnalysisPointer - This method is used when a pass implements
10821084 /// an analysis interface through multiple inheritance. If needed, it
4545 static char ID; // Class identification, replacement for typeinfo
4646 explicit LoaderPass(const std::string &filename = "")
4747 : ModulePass(ID), Filename(filename) {
48 initializeLoaderPassPass(*PassRegistry::getPassRegistry());
4849 if (filename.empty()) Filename = ProfileInfoFilename;
4950 }
5051
5959 static char ID; // Class identification, replacement for typeinfo
6060
6161 explicit ProfileVerifierPassT () : FunctionPass(ID) {
62 initializeProfileVerifierPassPass(*PassRegistry::getPassRegistry());
6263 DisableAssertions = ProfileVerifierDisableAssertions;
6364 }
6465 explicit ProfileVerifierPassT (bool da) : FunctionPass(ID),
6566 DisableAssertions(da) {
67 initializeProfileVerifierPassPass(*PassRegistry::getPassRegistry());
6668 }
6769
6870 void getAnalysisUsage(AnalysisUsage &AU) const {
661661 }
662662
663663 RegionInfo::RegionInfo() : FunctionPass(ID) {
664 initializeRegionInfoPass(*PassRegistry::getPassRegistry());
664665 TopLevelRegion = 0;
665666 }
666667
120120 struct RegionViewer
121121 : public DOTGraphTraitsViewer {
122122 static char ID;
123 RegionViewer() : DOTGraphTraitsViewer("reg", ID){}
123 RegionViewer() : DOTGraphTraitsViewer("reg", ID){
124 initializeRegionViewerPass(*PassRegistry::getPassRegistry());
125 }
124126 };
125127 char RegionViewer::ID = 0;
126128
127129 struct RegionOnlyViewer
128130 : public DOTGraphTraitsViewer {
129131 static char ID;
130 RegionOnlyViewer() : DOTGraphTraitsViewer("regonly", ID){}
132 RegionOnlyViewer() : DOTGraphTraitsViewer("regonly", ID) {
133 initializeRegionOnlyViewerPass(*PassRegistry::getPassRegistry());
134 }
131135 };
132136 char RegionOnlyViewer::ID = 0;
133137
135139 : public DOTGraphTraitsPrinter {
136140 static char ID;
137141 RegionPrinter() :
138 DOTGraphTraitsPrinter("reg", ID) {}
142 DOTGraphTraitsPrinter("reg", ID) {
143 initializeRegionPrinterPass(*PassRegistry::getPassRegistry());
144 }
139145 };
140146 char RegionPrinter::ID = 0;
141147 } //end anonymous namespace
156162 : public DOTGraphTraitsPrinter {
157163 static char ID;
158164 RegionOnlyPrinter() :
159 DOTGraphTraitsPrinter("reg", ID) {}
165 DOTGraphTraitsPrinter("reg", ID) {
166 initializeRegionOnlyPrinterPass(*PassRegistry::getPassRegistry());
167 }
160168 };
161169
162170 }
58345834
58355835 ScalarEvolution::ScalarEvolution()
58365836 : FunctionPass(ID), FirstUnknown(0) {
5837 initializeScalarEvolutionPass(*PassRegistry::getPassRegistry());
58375838 }
58385839
58395840 bool ScalarEvolution::runOnFunction(Function &F) {
3333
3434 public:
3535 static char ID; // Class identification, replacement for typeinfo
36 ScalarEvolutionAliasAnalysis() : FunctionPass(ID), SE(0) {}
36 ScalarEvolutionAliasAnalysis() : FunctionPass(ID), SE(0) {
37 initializeScalarEvolutionAliasAnalysisPass(
38 *PassRegistry::getPassRegistry());
39 }
3740
3841 /// getAdjustedAnalysisPointer - This method is used when a pass implements
3942 /// an analysis interface through multiple inheritance. If needed, it
8484 public AliasAnalysis {
8585 public:
8686 static char ID; // Class identification, replacement for typeinfo
87 TypeBasedAliasAnalysis() : ImmutablePass(ID) {}
87 TypeBasedAliasAnalysis() : ImmutablePass(ID) {
88 initializeTypeBasedAliasAnalysisPass(*PassRegistry::getPassRegistry());
89 }
8890
8991 virtual void initializePass() {
9092 InitializeAliasAnalysis(this);
5151 initializeUnreachableBlockElimPass(Registry);
5252 initializeUnreachableMachineBlockElimPass(Registry);
5353 initializeVirtRegMapPass(Registry);
54 initializeLowerIntrinsicsPass(Registry);
5455 }
5556
5657 void LLVMInitializeCodeGen(LLVMPassRegistryRef R) {
3535
3636 public:
3737 static char ID; // Pass identification, replacement for typeid
38 DeadMachineInstructionElim() : MachineFunctionPass(ID) {}
38 DeadMachineInstructionElim() : MachineFunctionPass(ID) {
39 initializeDeadMachineInstructionElimPass(*PassRegistry::getPassRegistry());
40 }
3941
4042 private:
4143 bool isDead(const MachineInstr *MI) const;
9999 DwarfEHPrepare(const TargetMachine *tm) :
100100 FunctionPass(ID), TM(tm), TLI(TM->getTargetLowering()),
101101 ExceptionValueIntrinsic(0), SelectorIntrinsic(0),
102 URoR(0), EHCatchAllValue(0), RewindFunction(0) {}
102 URoR(0), EHCatchAllValue(0), RewindFunction(0) {
103 initializeDominatorTreePass(*PassRegistry::getPassRegistry());
104 }
103105
104106 virtual bool runOnFunction(Function &Fn);
105107
6868 char GCModuleInfo::ID = 0;
6969
7070 GCModuleInfo::GCModuleInfo()
71 : ImmutablePass(ID) {}
71 : ImmutablePass(ID) {
72 initializeGCModuleInfoPass(*PassRegistry::getPassRegistry());
73 }
7274
7375 GCModuleInfo::~GCModuleInfo() {
7476 clear();
122122
123123 // -----------------------------------------------------------------------------
124124
125 INITIALIZE_PASS_BEGIN(LowerIntrinsics, "gc-lowering", "GC Lowering",
126 false, false)
127 INITIALIZE_PASS_DEPENDENCY(GCModuleInfo)
128 INITIALIZE_PASS_END(LowerIntrinsics, "gc-lowering", "GC Lowering", false, false)
129
125130 FunctionPass *llvm::createGCLoweringPass() {
126131 return new LowerIntrinsics();
127132 }
129134 char LowerIntrinsics::ID = 0;
130135
131136 LowerIntrinsics::LowerIntrinsics()
132 : FunctionPass(ID) {}
137 : FunctionPass(ID) {
138 initializeLowerIntrinsicsPass(*PassRegistry::getPassRegistry());
139 }
133140
134141 const char *LowerIntrinsics::getPassName() const {
135142 return "Lower Garbage Collection Instructions";
157157 int FnNum;
158158 public:
159159 static char ID;
160 IfConverter() : MachineFunctionPass(ID), FnNum(-1) {}
160 IfConverter() : MachineFunctionPass(ID), FnNum(-1) {
161 initializeIfConverterPass(*PassRegistry::getPassRegistry());
162 }
161163
162164 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
163165 AU.addRequired();
4040 MachineRegisterInfo *MRI;
4141 public:
4242 static char ID; // Pass identification
43 MachineCSE() : MachineFunctionPass(ID), LookAheadLimit(5), CurrVN(0) {}
43 MachineCSE() : MachineFunctionPass(ID), LookAheadLimit(5), CurrVN(0) {
44 initializeMachineCSEPass(*PassRegistry::getPassRegistry());
45 }
4446
4547 virtual bool runOnMachineFunction(MachineFunction &MF);
4648
4141
4242 MachineDominatorTree::MachineDominatorTree()
4343 : MachineFunctionPass(ID) {
44 initializeMachineDominatorTreePass(*PassRegistry::getPassRegistry());
4445 DT = new DominatorTreeBase(false);
4546 }
4647
100100 public:
101101 static char ID; // Pass identification, replacement for typeid
102102 MachineLICM() :
103 MachineFunctionPass(ID), PreRegAlloc(true) {}
103 MachineFunctionPass(ID), PreRegAlloc(true) {
104 initializeMachineLICMPass(*PassRegistry::getPassRegistry());
105 }
104106
105107 explicit MachineLICM(bool PreRA) :
106 MachineFunctionPass(ID), PreRegAlloc(PreRA) {}
108 MachineFunctionPass(ID), PreRegAlloc(PreRA) {
109 initializeMachineLICMPass(*PassRegistry::getPassRegistry());
110 }
107111
108112 virtual bool runOnMachineFunction(MachineFunction &MF);
109113
257257 ObjFileMMI(0),
258258 CurCallSite(0), CallsEHReturn(0), CallsUnwindInit(0), DbgInfoAvailable(false),
259259 CallsExternalFunctionWithFloatingPointArguments(false) {
260 initializeMachineModuleInfoPass(*PassRegistry::getPassRegistry());
260261 // Always emit some info, by default "no personality" info.
261262 Personalities.push_back(NULL);
262263 AddrLabelSymbols = 0;
5656
5757 public:
5858 static char ID; // Pass identification
59 MachineSinking() : MachineFunctionPass(ID) {}
59 MachineSinking() : MachineFunctionPass(ID) {
60 initializeMachineSinkingPass(*PassRegistry::getPassRegistry());
61 }
6062
6163 virtual bool runOnMachineFunction(MachineFunction &MF);
6264
194194 static char ID; // Pass ID, replacement for typeid
195195
196196 MachineVerifierPass()
197 : MachineFunctionPass(ID) {}
197 : MachineFunctionPass(ID) {
198 initializeMachineVerifierPassPass(*PassRegistry::getPassRegistry());
199 }
198200
199201 void getAnalysisUsage(AnalysisUsage &AU) const {
200202 AU.setPreservesAll();
3232
3333 public:
3434 static char ID; // Pass identification
35 OptimizePHIs() : MachineFunctionPass(ID) {}
35 OptimizePHIs() : MachineFunctionPass(ID) {
36 initializeOptimizePHIsPass(*PassRegistry::getPassRegistry());
37 }
3638
3739 virtual bool runOnMachineFunction(MachineFunction &MF);
3840
2626
2727 public:
2828 static char ID; // Pass identification, replacement for typeid
29 PHIElimination() : MachineFunctionPass(ID) {}
29 PHIElimination() : MachineFunctionPass(ID) {
30 initializePHIEliminationPass(*PassRegistry::getPassRegistry());
31 }
3032
3133 virtual bool runOnMachineFunction(MachineFunction &Fn);
3234
6161
6262 public:
6363 static char ID; // Pass identification
64 PeepholeOptimizer() : MachineFunctionPass(ID) {}
64 PeepholeOptimizer() : MachineFunctionPass(ID) {
65 initializePeepholeOptimizerPass(*PassRegistry::getPassRegistry());
66 }
6567
6668 virtual bool runOnMachineFunction(MachineFunction &MF);
6769
9090
9191 public:
9292 static char ID;
93 PreAllocSplitting()
94 : MachineFunctionPass(ID) {}
93 PreAllocSplitting() : MachineFunctionPass(ID) {
94 initializePreAllocSplittingPass(*PassRegistry::getPassRegistry());
95 }
9596
9697 virtual bool runOnMachineFunction(MachineFunction &MF);
9798
3535 class PEI : public MachineFunctionPass {
3636 public:
3737 static char ID;
38 PEI() : MachineFunctionPass(ID) {}
38 PEI() : MachineFunctionPass(ID) {
39 initializePEIPass(*PassRegistry::getPassRegistry());
40 }
3941
4042 const char *getPassName() const {
4143 return "Prolog/Epilog Insertion & Frame Finalization";
4747 public:
4848 static char ID;
4949 RAFast() : MachineFunctionPass(ID), StackSlotForVirtReg(-1),
50 isBulkSpilling(false) {}
50 isBulkSpilling(false) {
51 initializePHIEliminationPass(*PassRegistry::getPassRegistry());
52 initializeTwoAddressInstructionPassPass(*PassRegistry::getPassRegistry());
53 }
5154 private:
5255 const TargetMachine *TM;
5356 MachineFunction *MF;
9090 struct RALinScan : public MachineFunctionPass {
9191 static char ID;
9292 RALinScan() : MachineFunctionPass(ID) {
93 initializeLiveIntervalsPass(*PassRegistry::getPassRegistry());
94 initializeStrongPHIEliminationPass(*PassRegistry::getPassRegistry());
95 initializeRegisterCoalescerAnalysisGroup(
96 *PassRegistry::getPassRegistry());
97 initializeCalculateSpillWeightsPass(*PassRegistry::getPassRegistry());
98 initializePreAllocSplittingPass(*PassRegistry::getPassRegistry());
99 initializeLiveStacksPass(*PassRegistry::getPassRegistry());
100 initializeMachineLoopInfoPass(*PassRegistry::getPassRegistry());
101 initializeVirtRegMapPass(*PassRegistry::getPassRegistry());
102 initializeMachineDominatorTreePass(*PassRegistry::getPassRegistry());
103
93104 // Initialize the queue to record recently-used registers.
94105 if (NumRecentlyUsedRegs > 0)
95106 RecentRegs.resize(NumRecentlyUsedRegs, 0);
8383 static char ID;
8484
8585 /// Construct a PBQP register allocator.
86 RegAllocPBQP(std::auto_ptr b) : MachineFunctionPass(ID), builder(b) {}
86 RegAllocPBQP(std::auto_ptr b)
87 : MachineFunctionPass(ID), builder(b) {
88 initializeSlotIndexesPass(*PassRegistry::getPassRegistry());
89 initializeLiveIntervalsPass(*PassRegistry::getPassRegistry());
90 initializeRegisterCoalescerAnalysisGroup(*PassRegistry::getPassRegistry());
91 initializeCalculateSpillWeightsPass(*PassRegistry::getPassRegistry());
92 initializeLiveStacksPass(*PassRegistry::getPassRegistry());
93 initializeMachineLoopInfoPass(*PassRegistry::getPassRegistry());
94 initializeLoopSplitterPass(*PassRegistry::getPassRegistry());
95 initializeVirtRegMapPass(*PassRegistry::getPassRegistry());
96 initializeRenderMachineFunctionPass(*PassRegistry::getPassRegistry());
97 }
8798
8899 /// Return the pass name.
89100 virtual const char* getPassName() const {
201201 public:
202202 static char ID;
203203
204 RenderMachineFunction() : MachineFunctionPass(ID) {}
204 RenderMachineFunction() : MachineFunctionPass(ID) {
205 initializeRenderMachineFunctionPass(*PassRegistry::getPassRegistry());
206 }
205207
206208 virtual void getAnalysisUsage(AnalysisUsage &au) const;
207209
176176 SDB(new SelectionDAGBuilder(*CurDAG, *FuncInfo, OL)),
177177 GFI(),
178178 OptLevel(OL),
179 DAGSize(0)
180 {}
179 DAGSize(0) {
180 initializeGCModuleInfoPass(*PassRegistry::getPassRegistry());
181 initializeAliasAnalysisAnalysisGroup(*PassRegistry::getPassRegistry());
182 }
181183
182184 SelectionDAGISel::~SelectionDAGISel() {
183185 delete SDB;
6262
6363 public:
6464 static char ID; // Pass identifcation, replacement for typeid
65 SimpleRegisterCoalescing() : MachineFunctionPass(ID) {}
65 SimpleRegisterCoalescing() : MachineFunctionPass(ID) {
66 initializeSimpleRegisterCoalescingPass(*PassRegistry::getPassRegistry());
67 }
6668
6769 struct InstrSlots {
6870 enum {
3535 public:
3636 static char ID;
3737
38 LoopSplitter() : MachineFunctionPass(ID) {}
38 LoopSplitter() : MachineFunctionPass(ID) {
39 initializeLoopSplitterPass(*PassRegistry::getPassRegistry());
40 }
3941
4042 virtual void getAnalysisUsage(AnalysisUsage &au) const;
4143
6161 bool RequiresStackProtector() const;
6262 public:
6363 static char ID; // Pass identification, replacement for typeid.
64 StackProtector() : FunctionPass(ID), TLI(0) {}
64 StackProtector() : FunctionPass(ID), TLI(0) {
65 initializeStackProtectorPass(*PassRegistry::getPassRegistry());
66 }
6567 StackProtector(const TargetLowering *tli)
66 : FunctionPass(ID), TLI(tli) {}
68 : FunctionPass(ID), TLI(tli) {
69 initializeStackProtectorPass(*PassRegistry::getPassRegistry());
70 }
6771
6872 virtual bool runOnFunction(Function &Fn);
6973 };
9494 public:
9595 static char ID; // Pass identification
9696 StackSlotColoring() :
97 MachineFunctionPass(ID), ColorWithRegs(false), NextColor(-1) {}
97 MachineFunctionPass(ID), ColorWithRegs(false), NextColor(-1) {
98 initializeStackSlotColoringPass(*PassRegistry::getPassRegistry());
99 }
98100 StackSlotColoring(bool RegColor) :
99 MachineFunctionPass(ID), ColorWithRegs(RegColor), NextColor(-1) {}
101 MachineFunctionPass(ID), ColorWithRegs(RegColor), NextColor(-1) {
102 initializeStackSlotColoringPass(*PassRegistry::getPassRegistry());
103 }
100104
101105 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
102106 AU.setPreservesCFG();
3838 namespace {
3939 struct StrongPHIElimination : public MachineFunctionPass {
4040 static char ID; // Pass identification, replacement for typeid
41 StrongPHIElimination() : MachineFunctionPass(ID) {}
41 StrongPHIElimination() : MachineFunctionPass(ID) {
42 initializeStrongPHIEliminationPass(*PassRegistry::getPassRegistry());
43 }
4244
4345 // Waiting stores, for each MBB, the set of copies that need to
4446 // be inserted into that MBB
137137
138138 public:
139139 static char ID; // Pass identification, replacement for typeid
140 TwoAddressInstructionPass() : MachineFunctionPass(ID) {}
140 TwoAddressInstructionPass() : MachineFunctionPass(ID) {
141 initializeTwoAddressInstructionPassPass(*PassRegistry::getPassRegistry());
142 }
141143
142144 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
143145 AU.setPreservesCFG();
4242 virtual bool runOnFunction(Function &F);
4343 public:
4444 static char ID; // Pass identification, replacement for typeid
45 UnreachableBlockElim() : FunctionPass(ID) {}
45 UnreachableBlockElim() : FunctionPass(ID) {
46 initializeUnreachableBlockElimPass(*PassRegistry::getPassRegistry());
47 }
4648
4749 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
4850 AU.addPreserved();
7676 public:
7777 static char ID;
7878 CBackendNameAllUsedStructsAndMergeFunctions()
79 : ModulePass(ID) {}
79 : ModulePass(ID) {
80 initializeFindUsedTypesPass(*PassRegistry::getPassRegistry());
81 }
8082 void getAnalysisUsage(AnalysisUsage &AU) const {
8183 AU.addRequired();
8284 }
116118 : FunctionPass(ID), Out(o), IL(0), Mang(0), LI(0),
117119 TheModule(0), TAsm(0), TCtx(0), TD(0), OpaqueCounter(0),
118120 NextAnonValueNumber(0) {
121 initializeLoopInfoPass(*PassRegistry::getPassRegistry());
119122 FPCounter = 0;
120123 }
121124
130130 }
131131
132132 void TargetData::init(StringRef Desc) {
133 initializeTargetDataPass(*PassRegistry::getPassRegistry());
134
133135 LayoutMap = 0;
134136 LittleEndian = false;
135137 PointerMemSize = 8;
6666 virtual bool runOnSCC(CallGraphSCC &SCC);
6767 static char ID; // Pass identification, replacement for typeid
6868 explicit ArgPromotion(unsigned maxElements = 3)
69 : CallGraphSCCPass(ID), maxElements(maxElements) {}
69 : CallGraphSCCPass(ID), maxElements(maxElements) {
70 initializeArgPromotionPass(*PassRegistry::getPassRegistry());
71 }
7072
7173 /// A vector used to hold the indices of a single GEP instruction
7274 typedef std::vector IndicesVector;
3232 namespace {
3333 struct ConstantMerge : public ModulePass {
3434 static char ID; // Pass identification, replacement for typeid
35 ConstantMerge() : ModulePass(ID) {}
35 ConstantMerge() : ModulePass(ID) {
36 initializeConstantMergePass(*PassRegistry::getPassRegistry());
37 }
3638
3739 // run - For this pass, process all of the globals in the module,
3840 // eliminating duplicate constants.
125125
126126 public:
127127 static char ID; // Pass identification, replacement for typeid
128 DAE() : ModulePass(ID) {}
128 DAE() : ModulePass(ID) {
129 initializeDAEPass(*PassRegistry::getPassRegistry());
130 }
129131
130132 bool runOnModule(Module &M);
131133
2525 namespace {
2626 struct DTE : public ModulePass {
2727 static char ID; // Pass identification, replacement for typeid
28 DTE() : ModulePass(ID) {}
28 DTE() : ModulePass(ID) {
29 initializeDTEPass(*PassRegistry::getPassRegistry());
30 }
2931
3032 // doPassInitialization - For this pass, it removes global symbol table
3133 // entries for primitive types. These are never used for linking in GCC and
4040 namespace {
4141 struct FunctionAttrs : public CallGraphSCCPass {
4242 static char ID; // Pass identification, replacement for typeid
43 FunctionAttrs() : CallGraphSCCPass(ID) {}
43 FunctionAttrs() : CallGraphSCCPass(ID) {
44 initializeFunctionAttrsPass(*PassRegistry::getPassRegistry());
45 }
4446
4547 // runOnSCC - Analyze the SCC, performing the transformation if possible.
4648 bool runOnSCC(CallGraphSCC &SCC);
3030 namespace {
3131 struct GlobalDCE : public ModulePass {
3232 static char ID; // Pass identification, replacement for typeid
33 GlobalDCE() : ModulePass(ID) {}
33 GlobalDCE() : ModulePass(ID) {
34 initializeGlobalDCEPass(*PassRegistry::getPassRegistry());
35 }
3436
3537 // run - Do the GlobalDCE pass on the specified module, optionally updating
3638 // the specified callgraph to reflect the changes.
5858 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
5959 }
6060 static char ID; // Pass identification, replacement for typeid
61 GlobalOpt() : ModulePass(ID) {}
61 GlobalOpt() : ModulePass(ID) {
62 initializeGlobalOptPass(*PassRegistry::getPassRegistry());
63 }
6264
6365 bool runOnModule(Module &M);
6466
3434 ///
3535 struct IPCP : public ModulePass {
3636 static char ID; // Pass identification, replacement for typeid
37 IPCP() : ModulePass(ID) {}
37 IPCP() : ModulePass(ID) {
38 initializeIPCPPass(*PassRegistry::getPassRegistry());
39 }
3840
3941 bool runOnModule(Module &M);
4042 private:
3535 InlineCostAnalyzer CA;
3636 public:
3737 // Use extremely low threshold.
38 AlwaysInliner() : Inliner(ID, -2000000000) {}
38 AlwaysInliner() : Inliner(ID, -2000000000) {
39 initializeAlwaysInlinerPass(*PassRegistry::getPassRegistry());
40 }
3941 static char ID; // Pass identification, replacement for typeid
4042 InlineCost getInlineCost(CallSite CS) {
4143 return CA.getInlineCost(CS, NeverInline);
6062 }
6163
6264 char AlwaysInliner::ID = 0;
63 INITIALIZE_PASS(AlwaysInliner, "always-inline",
65 INITIALIZE_PASS_BEGIN(AlwaysInliner, "always-inline",
66 "Inliner for always_inline functions", false, false)
67 INITIALIZE_AG_DEPENDENCY(CallGraph)
68 INITIALIZE_PASS_END(AlwaysInliner, "always-inline",
6469 "Inliner for always_inline functions", false, false)
6570
6671 Pass *llvm::createAlwaysInlinerPass() { return new AlwaysInliner(); }
3232 SmallPtrSet NeverInline;
3333 InlineCostAnalyzer CA;
3434 public:
35 SimpleInliner() : Inliner(ID) {}
36 SimpleInliner(int Threshold) : Inliner(ID, Threshold) {}
35 SimpleInliner() : Inliner(ID) {
36 initializeSimpleInlinerPass(*PassRegistry::getPassRegistry());
37 }
38 SimpleInliner(int Threshold) : Inliner(ID, Threshold) {
39 initializeSimpleInlinerPass(*PassRegistry::getPassRegistry());
40 }
3741 static char ID; // Pass identification, replacement for typeid
3842 InlineCost getInlineCost(CallSite CS) {
3943 return CA.getInlineCost(CS, NeverInline);
6767
6868 InternalizePass::InternalizePass(bool AllButMain)
6969 : ModulePass(ID), AllButMain(AllButMain){
70 initializeInternalizePassPass(*PassRegistry::getPassRegistry());
7071 if (!APIFile.empty()) // If a filename is specified, use it.
7172 LoadFile(APIFile.c_str());
7273 if (!APIList.empty()) // If a list is specified, use it as well.
7576
7677 InternalizePass::InternalizePass(const std::vector&exportList)
7778 : ModulePass(ID), AllButMain(false){
79 initializeInternalizePassPass(*PassRegistry::getPassRegistry());
7880 for(std::vector::const_iterator itr = exportList.begin();
7981 itr != exportList.end(); itr++) {
8082 ExternalNames.insert(*itr);
3636 unsigned NumLoops;
3737
3838 explicit LoopExtractor(unsigned numLoops = ~0)
39 : LoopPass(ID), NumLoops(numLoops) {}
39 : LoopPass(ID), NumLoops(numLoops) {
40 initializeLoopExtractorPass(*PassRegistry::getPassRegistry());
41 }
4042
4143 virtual bool runOnLoop(Loop *L, LPPassManager &LPM);
4244
108108 bool IsTransformableFunction(StringRef Name);
109109 public:
110110 static char ID; // Pass identification, replacement for typeid
111 LowerSetJmp() : ModulePass(ID) {}
111 LowerSetJmp() : ModulePass(ID) {
112 initializeLowerSetJmpPass(*PassRegistry::getPassRegistry());
113 }
112114
113115 void visitCallInst(CallInst& CI);
114116 void visitInvokeInst(InvokeInst& II);
150150 class MergeFunctions : public ModulePass {
151151 public:
152152 static char ID;
153 MergeFunctions() : ModulePass(ID) {}
153 MergeFunctions() : ModulePass(ID) {
154 initializeMergeFunctionsPass(*PassRegistry::getPassRegistry());
155 }
154156
155157 bool runOnModule(Module &M);
156158
2929 struct PartialInliner : public ModulePass {
3030 virtual void getAnalysisUsage(AnalysisUsage &AU) const { }
3131 static char ID; // Pass identification, replacement for typeid
32 PartialInliner() : ModulePass(ID) {}
32 PartialInliner() : ModulePass(ID) {
33 initializePartialInlinerPass(*PassRegistry::getPassRegistry());
34 }
3335
3436 bool runOnModule(Module& M);
3537
4545 InlineCostAnalyzer CA;
4646 public :
4747 static char ID; // Pass identification, replacement for typeid
48 PartSpec() : ModulePass(ID) {}
48 PartSpec() : ModulePass(ID) {
49 initializePartSpecPass(*PassRegistry::getPassRegistry());
50 }
4951 bool runOnModule(Module &M);
5052 };
5153 }
3636 namespace {
3737 struct PruneEH : public CallGraphSCCPass {
3838 static char ID; // Pass identification, replacement for typeid
39 PruneEH() : CallGraphSCCPass(ID) {}
39 PruneEH() : CallGraphSCCPass(ID) {
40 initializePruneEHPass(*PassRegistry::getPassRegistry());
41 }
4042
4143 // runOnSCC - Analyze the SCC, performing the transformation if possible.
4244 bool runOnSCC(CallGraphSCC &SCC);
2828 class StripDeadPrototypesPass : public ModulePass {
2929 public:
3030 static char ID; // Pass identification, replacement for typeid
31 StripDeadPrototypesPass() : ModulePass(ID) { }
31 StripDeadPrototypesPass() : ModulePass(ID) {
32 initializeStripDeadPrototypesPassPass(*PassRegistry::getPassRegistry());
33 }
3234 virtual bool runOnModule(Module &M);
3335 };
3436
3838 public:
3939 static char ID; // Pass identification, replacement for typeid
4040 explicit StripSymbols(bool ODI = false)
41 : ModulePass(ID), OnlyDebugInfo(ODI) {}
41 : ModulePass(ID), OnlyDebugInfo(ODI) {
42 initializeStripSymbolsPass(*PassRegistry::getPassRegistry());
43 }
4244
4345 virtual bool runOnModule(Module &M);
4446
5153 public:
5254 static char ID; // Pass identification, replacement for typeid
5355 explicit StripNonDebugSymbols()
54 : ModulePass(ID) {}
56 : ModulePass(ID) {
57 initializeStripNonDebugSymbolsPass(*PassRegistry::getPassRegistry());
58 }
5559
5660 virtual bool runOnModule(Module &M);
5761
6468 public:
6569 static char ID; // Pass identification, replacement for typeid
6670 explicit StripDebugDeclare()
67 : ModulePass(ID) {}
71 : ModulePass(ID) {
72 initializeStripDebugDeclarePass(*PassRegistry::getPassRegistry());
73 }
6874
6975 virtual bool runOnModule(Module &M);
7076
7783 public:
7884 static char ID; // Pass identification, replacement for typeid
7985 explicit StripDeadDebugInfo()
80 : ModulePass(ID) {}
86 : ModulePass(ID) {
87 initializeStripDeadDebugInfoPass(*PassRegistry::getPassRegistry());
88 }
8189
8290 virtual bool runOnModule(Module &M);
8391
4949
5050 virtual bool runOnSCC(CallGraphSCC &SCC);
5151 static char ID; // Pass identification, replacement for typeid
52 SRETPromotion() : CallGraphSCCPass(ID) {}
52 SRETPromotion() : CallGraphSCCPass(ID) {
53 initializeSRETPromotionPass(*PassRegistry::getPassRegistry());
54 }
5355
5456 private:
5557 CallGraphNode *PromoteReturn(CallGraphNode *CGN);
8080 BuilderTy *Builder;
8181
8282 static char ID; // Pass identification, replacement for typeid
83 InstCombiner() : FunctionPass(ID), TD(0), Builder(0) {}
83 InstCombiner() : FunctionPass(ID), TD(0), Builder(0) {
84 initializeInstCombinerPass(*PassRegistry::getPassRegistry());
85 }
8486
8587 public:
8688 virtual bool runOnFunction(Function &F);
3333 bool runOnModule(Module &M);
3434 public:
3535 static char ID; // Pass identification, replacement for typeid
36 EdgeProfiler() : ModulePass(ID) {}
36 EdgeProfiler() : ModulePass(ID) {
37 initializeEdgeProfilerPass(*PassRegistry::getPassRegistry());
38 }
3739
3840 virtual const char *getPassName() const {
3941 return "Edge Profiler";
3535 bool runOnModule(Module &M);
3636 public:
3737 static char ID; // Pass identification, replacement for typeid
38 OptimalEdgeProfiler() : ModulePass(ID) {}
38 OptimalEdgeProfiler() : ModulePass(ID) {
39 initializeOptimalEdgeProfilerPass(*PassRegistry::getPassRegistry());
40 }
3941
4042 void getAnalysisUsage(AnalysisUsage &AU) const {
4143 AU.addRequiredID(ProfileEstimatorPassID);
3232 namespace {
3333 struct ADCE : public FunctionPass {
3434 static char ID; // Pass identification, replacement for typeid
35 ADCE() : FunctionPass(ID) {}
35 ADCE() : FunctionPass(ID) {
36 initializeADCEPass(*PassRegistry::getPassRegistry());
37 }
3638
3739 virtual bool runOnFunction(Function& F);
3840
4040 namespace {
4141 struct BlockPlacement : public FunctionPass {
4242 static char ID; // Pass identification, replacement for typeid
43 BlockPlacement() : FunctionPass(ID) {}
43 BlockPlacement() : FunctionPass(ID) {
44 initializeBlockPlacementPass(*PassRegistry::getPassRegistry());
45 }
4446
4547 virtual bool runOnFunction(Function &F);
4648
6262 public:
6363 static char ID; // Pass identification, replacement for typeid
6464 explicit CodeGenPrepare(const TargetLowering *tli = 0)
65 : FunctionPass(ID), TLI(tli) {}
65 : FunctionPass(ID), TLI(tli) {
66 initializeCodeGenPreparePass(*PassRegistry::getPassRegistry());
67 }
6668 bool runOnFunction(Function &F);
6769
6870 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
3333 namespace {
3434 struct ConstantPropagation : public FunctionPass {
3535 static char ID; // Pass identification, replacement for typeid
36 ConstantPropagation() : FunctionPass(ID) {}
36 ConstantPropagation() : FunctionPass(ID) {
37 initializeConstantPropagationPass(*PassRegistry::getPassRegistry());
38 }
3739
3840 bool runOnFunction(Function &F);
3941
3838
3939 public:
4040 static char ID;
41 CorrelatedValuePropagation(): FunctionPass(ID) { }
41 CorrelatedValuePropagation(): FunctionPass(ID) {
42 initializeCorrelatedValuePropagationPass(*PassRegistry::getPassRegistry());
43 }
4244
4345 bool runOnFunction(Function &F);
4446
3434 //
3535 struct DeadInstElimination : public BasicBlockPass {
3636 static char ID; // Pass identification, replacement for typeid
37 DeadInstElimination() : BasicBlockPass(ID) {}
37 DeadInstElimination() : BasicBlockPass(ID) {
38 initializeDeadInstEliminationPass(*PassRegistry::getPassRegistry());
39 }
3840 virtual bool runOnBasicBlock(BasicBlock &BB) {
3941 bool Changed = false;
4042 for (BasicBlock::iterator DI = BB.begin(); DI != BB.end(); ) {
6971 //
7072 struct DCE : public FunctionPass {
7173 static char ID; // Pass identification, replacement for typeid
72 DCE() : FunctionPass(ID) {}
74 DCE() : FunctionPass(ID) {
75 initializeDCEPass(*PassRegistry::getPassRegistry());
76 }
7377
7478 virtual bool runOnFunction(Function &F);
7579
3939 TargetData *TD;
4040
4141 static char ID; // Pass identification, replacement for typeid
42 DSE() : FunctionPass(ID) {}
42 DSE() : FunctionPass(ID) {
43 initializeDSEPass(*PassRegistry::getPassRegistry());
44 }
4345
4446 virtual bool runOnFunction(Function &F) {
4547 bool Changed = false;
2626 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
2727 public:
2828 static char ID; // Pass identification, replacement for typeid
29 explicit GEPSplitter() : FunctionPass(ID) {}
29 explicit GEPSplitter() : FunctionPass(ID) {
30 initializeGEPSplitterPass(*PassRegistry::getPassRegistry());
31 }
3032 };
3133 }
3234
661661 public:
662662 static char ID; // Pass identification, replacement for typeid
663663 explicit GVN(bool noloads = false)
664 : FunctionPass(ID), NoLoads(noloads), MD(0) { }
664 : FunctionPass(ID), NoLoads(noloads), MD(0) {
665 initializeGVNPass(*PassRegistry::getPassRegistry());
666 }
665667
666668 private:
667669 bool NoLoads;
7676 public:
7777
7878 static char ID; // Pass identification, replacement for typeid
79 IndVarSimplify() : LoopPass(ID) {}
79 IndVarSimplify() : LoopPass(ID) {
80 initializeIndVarSimplifyPass(*PassRegistry::getPassRegistry());
81 }
8082
8183 virtual bool runOnLoop(Loop *L, LPPassManager &LPM);
8284
8585 };
8686 public:
8787 static char ID; // Pass identification
88 JumpThreading() : FunctionPass(ID) {}
88 JumpThreading() : FunctionPass(ID) {
89 initializeJumpThreadingPass(*PassRegistry::getPassRegistry());
90 }
8991
9092 bool runOnFunction(Function &F);
9193
6666 namespace {
6767 struct LICM : public LoopPass {
6868 static char ID; // Pass identification, replacement for typeid
69 LICM() : LoopPass(ID) {}
69 LICM() : LoopPass(ID) {
70 initializeLICMPass(*PassRegistry::getPassRegistry());
71 }
7072
7173 virtual bool runOnLoop(Loop *L, LPPassManager &LPM);
7274
2727 class LoopDeletion : public LoopPass {
2828 public:
2929 static char ID; // Pass ID, replacement for typeid
30 LoopDeletion() : LoopPass(ID) {}
30 LoopDeletion() : LoopPass(ID) {
31 initializeLoopDeletionPass(*PassRegistry::getPassRegistry());
32 }
3133
3234 // Possibly eliminate loop L if it is dead.
3335 bool runOnLoop(Loop* L, LPPassManager& LPM);
3434 class LoopRotate : public LoopPass {
3535 public:
3636 static char ID; // Pass ID, replacement for typeid
37 LoopRotate() : LoopPass(ID) {}
37 LoopRotate() : LoopPass(ID) {
38 initializeLoopRotatePass(*PassRegistry::getPassRegistry());
39 }
3840
3941 // Rotate Loop L as many times as possible. Return true if
4042 // loop is rotated at least once.
38063806 }
38073807
38083808 LoopStrengthReduce::LoopStrengthReduce(const TargetLowering *tli)
3809 : LoopPass(ID), TLI(tli) {}
3809 : LoopPass(ID), TLI(tli) {
3810 initializeLoopStrengthReducePass(*PassRegistry::getPassRegistry());
3811 }
38103812
38113813 void LoopStrengthReduce::getAnalysisUsage(AnalysisUsage &AU) const {
38123814 // We split critical edges, so we change the CFG. However, we do update
4242 class LoopUnroll : public LoopPass {
4343 public:
4444 static char ID; // Pass ID, replacement for typeid
45 LoopUnroll() : LoopPass(ID) {}
45 LoopUnroll() : LoopPass(ID) {
46 initializeLoopUnrollPass(*PassRegistry::getPassRegistry());
47 }
4648
4749 /// A magic value for use with the Threshold parameter to indicate
4850 /// that the loop unroll should be performed regardless of how much
9292 explicit LoopUnswitch(bool Os = false) :
9393 LoopPass(ID), OptimizeForSize(Os), redoLoop(false),
9494 currentLoop(NULL), DT(NULL), loopHeader(NULL),
95 loopPreheader(NULL) {}
95 loopPreheader(NULL) {
96 initializeLoopUnswitchPass(*PassRegistry::getPassRegistry());
97 }
9698
9799 bool runOnLoop(Loop *L, LPPassManager &LPM);
98100 bool processCurrentLoop();
117117 namespace {
118118 struct LowerAtomic : public BasicBlockPass {
119119 static char ID;
120 LowerAtomic() : BasicBlockPass(ID) {}
120 LowerAtomic() : BasicBlockPass(ID) {
121 initializeLowerAtomicPass(*PassRegistry::getPassRegistry());
122 }
121123 bool runOnBasicBlock(BasicBlock &BB) {
122124 bool Changed = false;
123125 for (BasicBlock::iterator DI = BB.begin(), DE = BB.end(); DI != DE; )
303303 bool runOnFunction(Function &F);
304304 public:
305305 static char ID; // Pass identification, replacement for typeid
306 MemCpyOpt() : FunctionPass(ID) {}
306 MemCpyOpt() : FunctionPass(ID) {
307 initializeMemCpyOptPass(*PassRegistry::getPassRegistry());
308 }
307309
308310 private:
309311 // This transformation requires dominator postdominator info
7676 bool MadeChange;
7777 public:
7878 static char ID; // Pass identification, replacement for typeid
79 Reassociate() : FunctionPass(ID) {}
79 Reassociate() : FunctionPass(ID) {
80 initializeReassociatePass(*PassRegistry::getPassRegistry());
81 }
8082
8183 bool runOnFunction(Function &F);
8284
3535 namespace {
3636 struct RegToMem : public FunctionPass {
3737 static char ID; // Pass identification, replacement for typeid
38 RegToMem() : FunctionPass(ID) {}
38 RegToMem() : FunctionPass(ID) {
39 initializeRegToMemPass(*PassRegistry::getPassRegistry());
40 }
3941
4042 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
4143 AU.addRequiredID(BreakCriticalEdgesID);
15841584 ///
15851585 struct SCCP : public FunctionPass {
15861586 static char ID; // Pass identification, replacement for typeid
1587 SCCP() : FunctionPass(ID) {}
1587 SCCP() : FunctionPass(ID) {
1588 initializeSCCPPass(*PassRegistry::getPassRegistry());
1589 }
15881590
15891591 // runOnFunction - Run the Sparse Conditional Constant Propagation
15901592 // algorithm, and return true if the function was modified.
17001702 ///
17011703 struct IPSCCP : public ModulePass {
17021704 static char ID;
1703 IPSCCP() : ModulePass(ID) {}
1705 IPSCCP() : ModulePass(ID) {
1706 initializeIPSCCPPass(*PassRegistry::getPassRegistry());
1707 }
17041708 bool runOnModule(Module &M);
17051709 };
17061710 } // end anonymous namespace
5252 struct SROA : public FunctionPass {
5353 static char ID; // Pass identification, replacement for typeid
5454 explicit SROA(signed T = -1) : FunctionPass(ID) {
55 initializeSROAPass(*PassRegistry::getPassRegistry());
5556 if (T == -1)
5657 SRThreshold = 128;
5758 else
4141 namespace {
4242 struct CFGSimplifyPass : public FunctionPass {
4343 static char ID; // Pass identification, replacement for typeid
44 CFGSimplifyPass() : FunctionPass(ID) {}
44 CFGSimplifyPass() : FunctionPass(ID) {
45 initializeCFGSimplifyPassPass(*PassRegistry::getPassRegistry());
46 }
4547
4648 virtual bool runOnFunction(Function &F);
4749 };
3131 const TargetData *TD;
3232 public:
3333 static char ID; // Pass identification
34 SimplifyHalfPowrLibCalls() : FunctionPass(ID) {}
34 SimplifyHalfPowrLibCalls() : FunctionPass(ID) {
35 initializeSimplifyHalfPowrLibCallsPass(*PassRegistry::getPassRegistry());
36 }
3537
3638 bool runOnFunction(Function &F);
3739
13731373 bool Modified; // This is only used by doInitialization.
13741374 public:
13751375 static char ID; // Pass identification
1376 SimplifyLibCalls() : FunctionPass(ID), StrCpy(false), StrCpyChk(true) {}
1376 SimplifyLibCalls() : FunctionPass(ID), StrCpy(false), StrCpyChk(true) {
1377 initializeSimplifyLibCallsPass(*PassRegistry::getPassRegistry());
1378 }
13771379 void InitOptimizations();
13781380 bool runOnFunction(Function &F);
13791381
3434
3535 public:
3636 static char ID; // Pass identification
37 Sinking() : FunctionPass(ID) {}
37 Sinking() : FunctionPass(ID) {
38 initializeSinkingPass(*PassRegistry::getPassRegistry());
39 }
3840
3941 virtual bool runOnFunction(Function &F);
4042
4848 bool runOnFunction(Function &F);
4949 public:
5050 static char ID; // Pass identification, replacement for typeid
51 TailDup() : FunctionPass(ID) {}
51 TailDup() : FunctionPass(ID) {
52 initializeTailDupPass(*PassRegistry::getPassRegistry());
53 }
5254
5355 private:
5456 inline bool shouldEliminateUnconditionalBranch(TerminatorInst *, unsigned);
7171 namespace {
7272 struct TailCallElim : public FunctionPass {
7373 static char ID; // Pass identification, replacement for typeid
74 TailCallElim() : FunctionPass(ID) {}
74 TailCallElim() : FunctionPass(ID) {
75 initializeTailCallElimPass(*PassRegistry::getPassRegistry());
76 }
7577
7678 virtual bool runOnFunction(Function &F);
7779
3535 namespace {
3636 struct BreakCriticalEdges : public FunctionPass {
3737 static char ID; // Pass identification, replacement for typeid
38 BreakCriticalEdges() : FunctionPass(ID) {}
38 BreakCriticalEdges() : FunctionPass(ID) {
39 initializeBreakCriticalEdgesPass(*PassRegistry::getPassRegistry());
40 }
3941
4042 virtual bool runOnFunction(Function &F);
4143
2222 namespace {
2323 struct InstNamer : public FunctionPass {
2424 static char ID; // Pass identification, replacement for typeid
25 InstNamer() : FunctionPass(ID) {}
25 InstNamer() : FunctionPass(ID) {
26 initializeInstNamerPass(*PassRegistry::getPassRegistry());
27 }
2628
2729 void getAnalysisUsage(AnalysisUsage &Info) const {
2830 Info.setPreservesAll();
4646 namespace {
4747 struct LCSSA : public LoopPass {
4848 static char ID; // Pass identification, replacement for typeid
49 LCSSA() : LoopPass(ID) {}
49 LCSSA() : LoopPass(ID) {
50 initializeLCSSAPass(*PassRegistry::getPassRegistry());
51 }
5052
5153 // Cached analysis information for the current function.
5254 DominatorTree *DT;
6464 namespace {
6565 struct LoopSimplify : public LoopPass {
6666 static char ID; // Pass identification, replacement for typeid
67 LoopSimplify() : LoopPass(ID) {}
67 LoopSimplify() : LoopPass(ID) {
68 initializeLoopSimplifyPass(*PassRegistry::getPassRegistry());
69 }
6870
6971 // AA - If we have an alias analysis object to update, this is it, otherwise
7072 // this is null.
110112 "Canonicalize natural loops", true, false)
111113 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
112114 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
113 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
114 INITIALIZE_PASS_DEPENDENCY(BreakCriticalEdges)
115 INITIALIZE_PASS_DEPENDENCY(DominanceFrontier)
116 INITIALIZE_PASS_DEPENDENCY(LCSSA)
117 INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
118115 INITIALIZE_PASS_END(LoopSimplify, "loopsimplify",
119116 "Canonicalize natural loops", true, false)
120117
7878 explicit LowerInvoke(const TargetLowering *tli = NULL,
7979 bool useExpensiveEHSupport = ExpensiveEHSupport)
8080 : FunctionPass(ID), useExpensiveEHSupport(useExpensiveEHSupport),
81 TLI(tli) { }
81 TLI(tli) {
82 initializeLowerInvokePass(*PassRegistry::getPassRegistry());
83 }
8284 bool doInitialization(Module &M);
8385 bool runOnFunction(Function &F);
8486
3232 class LowerSwitch : public FunctionPass {
3333 public:
3434 static char ID; // Pass identification, replacement for typeid
35 LowerSwitch() : FunctionPass(ID) {}
35 LowerSwitch() : FunctionPass(ID) {
36 initializeLowerSwitchPass(*PassRegistry::getPassRegistry());
37 }
3638
3739 virtual bool runOnFunction(Function &F);
3840
2626 namespace {
2727 struct PromotePass : public FunctionPass {
2828 static char ID; // Pass identification, replacement for typeid
29 PromotePass() : FunctionPass(ID) {}
29 PromotePass() : FunctionPass(ID) {
30 initializePromotePassPass(*PassRegistry::getPassRegistry());
31 }
3032
3133 // runOnFunction - To run this pass, first we calculate the alloca
3234 // instructions that are safe for promotion, then we promote each one.
7171 struct PreVerifier : public FunctionPass {
7272 static char ID; // Pass ID, replacement for typeid
7373
74 PreVerifier() : FunctionPass(ID) { }
74 PreVerifier() : FunctionPass(ID) {
75 initializePreVerifierPass(*PassRegistry::getPassRegistry());
76 }
7577
7678 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
7779 AU.setPreservesAll();
183185 Verifier()
184186 : FunctionPass(ID),
185187 Broken(false), RealPass(true), action(AbortProcessAction),
186 Mod(0), Context(0), DT(0), MessagesStr(Messages) {}
188 Mod(0), Context(0), DT(0), MessagesStr(Messages) {
189 initializeVerifierPass(*PassRegistry::getPassRegistry());
190 }
187191 explicit Verifier(VerifierFailureAction ctn)
188192 : FunctionPass(ID),
189193 Broken(false), RealPass(true), action(ctn), Mod(0), Context(0), DT(0),
190 MessagesStr(Messages) {}
194 MessagesStr(Messages) {
195 initializeVerifierPass(*PassRegistry::getPassRegistry());
196 }
191197
192198 bool doInitialization(Module &M) {
193199 Mod = &M;
9393 llvm::sys::PrintStackTraceOnErrorSignal();
9494 llvm::PrettyStackTraceProgram X(argc, argv);
9595 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
96
97 // Initialize passes
98 PassRegistry &Registry = *PassRegistry::getPassRegistry();
99 initializeCore(Registry);
100 initializeScalarOpts(Registry);
101 initializeIPO(Registry);
102 initializeAnalysis(Registry);
103 initializeIPA(Registry);
104 initializeTransformUtils(Registry);
105 initializeInstCombine(Registry);
106 initializeInstrumentation(Registry);
107 initializeTarget(Registry);
108
96109 cl::ParseCommandLineOptions(argc, argv,
97110 "LLVM automatic testcase reducer. See\nhttp://"
98111 "llvm.org/cmds/bugpoint.html"
513513 LLVMContext &Context = getGlobalContext();
514514 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
515515
516 // Initialize passes
517 PassRegistry &Registry = *PassRegistry::getPassRegistry();
518 initializeCore(Registry);
519 initializeScalarOpts(Registry);
520 initializeIPO(Registry);
521 initializeAnalysis(Registry);
522 initializeIPA(Registry);
523 initializeTransformUtils(Registry);
524 initializeInstCombine(Registry);
525 initializeTarget(Registry);
526
516527 // Initial global variable above for convenience printing of program name.
517528 progname = sys::Path(argv[0]).getBasename();
518529
393393 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
394394 LLVMContext &Context = getGlobalContext();
395395
396 // Initialize passes
397 PassRegistry &Registry = *PassRegistry::getPassRegistry();
398 initializeCore(Registry);
399 initializeScalarOpts(Registry);
400 initializeIPO(Registry);
401 initializeAnalysis(Registry);
402 initializeIPA(Registry);
403 initializeTransformUtils(Registry);
404 initializeInstCombine(Registry);
405 initializeInstrumentation(Registry);
406 initializeTarget(Registry);
407
396408 cl::ParseCommandLineOptions(argc, argv,
397409 "llvm .bc -> .bc modular optimizer and analysis printer\n");
398410
3131 #include "llvm/Assembly/PrintModulePass.h"
3232 #include "gtest/gtest.h"
3333
34 using namespace llvm;
35
3436 namespace llvm {
37 void initializeModuleNDMPass(PassRegistry&);
38 void initializeFPassPass(PassRegistry&);
39 void initializeCGPassPass(PassRegistry&);
40 void initializeLPassPass(PassRegistry&);
41 void initializeBPassPass(PassRegistry&);
42
3543 namespace {
3644 // ND = no deps
3745 // NM = no modifications
3947 public:
4048 static char run;
4149 static char ID;
42 ModuleNDNM() : ModulePass(ID) {}
50 ModuleNDNM() : ModulePass(ID) { }
4351 virtual bool runOnModule(Module &M) {
4452 run++;
4553 return false;
6371 };
6472 char ModuleNDM::ID=0;
6573 char ModuleNDM::run=0;
66 RegisterPass X("mndm","mndm",false,false);
6774
6875 struct ModuleNDM2 : public ModulePass {
6976 public:
8289 public:
8390 static char run;
8491 static char ID;
85 ModuleDNM() : ModulePass(ID) {}
92 ModuleDNM() : ModulePass(ID) {
93 initializeModuleNDMPass(*PassRegistry::getPassRegistry());
94 }
8695 virtual bool runOnModule(Module &M) {
8796 EXPECT_TRUE(getAnalysisIfAvailable());
8897 run++;
153162
154163 struct CGPass : public PassTest {
155164 public:
165 CGPass() {
166 initializeCGPassPass(*PassRegistry::getPassRegistry());
167 }
156168 virtual bool runOnSCC(CallGraphSCC &SCMM) {
157169 EXPECT_TRUE(getAnalysisIfAvailable());
158170 run();
159171 return false;
160172 }
161173 };
162 RegisterPass X1("cgp","cgp");
163174
164175 struct FPass : public PassTest {
165176 public:
170181 return false;
171182 }
172183 };
173 RegisterPass X2("fp","fp");
174184
175185 struct LPass : public PassTestBase {
176186 private:
178188 static int fincount;
179189 public:
180190 LPass() {
191 initializeLPassPass(*PassRegistry::getPassRegistry());
181192 initcount = 0; fincount=0;
182193 EXPECT_FALSE(initialized);
183194 }
204215 };
205216 int LPass::initcount=0;
206217 int LPass::fincount=0;
207 RegisterPass X3("lp","lp");
208218
209219 struct BPass : public PassTestBase {
210220 private:
247257 };
248258 int BPass::inited=0;
249259 int BPass::fin=0;
250 RegisterPass X4("bp","bp");
251260
252261 struct OnTheFlyTest: public ModulePass {
253262 public:
254263 static char ID;
255 OnTheFlyTest() : ModulePass(ID) {}
264 OnTheFlyTest() : ModulePass(ID) {
265 initializeFPassPass(*PassRegistry::getPassRegistry());
266 }
256267 virtual bool runOnModule(Module &M) {
257268 EXPECT_TRUE(getAnalysisIfAvailable());
258269 for (Module::iterator I=M.begin(),E=M.end(); I != E; ++I) {
524535
525536 }
526537 }
538
539 INITIALIZE_PASS(ModuleNDM, "mndm", "mndm", false, false)
540 INITIALIZE_PASS_BEGIN(CGPass, "cgp","cgp", false, false)
541 INITIALIZE_AG_DEPENDENCY(CallGraph)
542 INITIALIZE_PASS_END(CGPass, "cgp","cgp", false, false)
543 INITIALIZE_PASS(FPass, "fp","fp", false, false)
544 INITIALIZE_PASS_BEGIN(LPass, "lp","lp", false, false)
545 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
546 INITIALIZE_PASS_END(LPass, "lp","lp", false, false)
547 INITIALIZE_PASS(BPass, "bp","bp", false, false)