llvm.org GIT mirror llvm / c7fe32e
Do not use virtual function to identify an analysis pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48520 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 12 years ago
21 changed file(s) with 39 addition(s) and 111 deletion(s). Raw diff Collapse all Expand all
299299 // FIXME: Should remove this
300300 virtual bool runOnFunction(Function &F) { return false; }
301301
302 /// isAnalysis - Return true if this pass is implementing an analysis pass.
303 virtual bool isAnalysis() const { return true; }
304
305302 virtual void releaseMemory() { reset(); }
306303
307304 /// getNode - return the (Post)DominatorTree node for the specified basic
666663 static char ID; // Pass ID, replacement for typeid
667664 DominatorTreeBase* DT;
668665
669 DominatorTree() : FunctionPass(intptr_t(&ID)) {
666 DominatorTree() : FunctionPass(intptr_t(&ID), true) {
670667 DT = new DominatorTreeBase(false);
671668 }
672669
693690 return DT->getRootNode();
694691 }
695692
696 /// isAnalysis - Return true if this pass is implementing an analysis pass.
697 virtual bool isAnalysis() const { return true; }
698
699693 virtual bool runOnFunction(Function &F);
700694
701695 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
842836
843837 public:
844838 DominanceFrontierBase(intptr_t ID, bool isPostDom)
845 : FunctionPass(ID), IsPostDominators(isPostDom) {}
839 : FunctionPass(ID, true), IsPostDominators(isPostDom) {}
846840
847841 /// getRoots - Return the root blocks of the current CFG. This may include
848842 /// multiple blocks if we are computing post dominators. For forward
914908 assert(Roots.size() == 1 && "Should always have entry node!");
915909 return Roots[0];
916910 }
917
918 /// isAnalysis - Return true if this pass is implementing an analysis pass.
919 virtual bool isAnalysis() const { return true; }
920911
921912 virtual bool runOnFunction(Function &) {
922913 Frontiers.clear();
2424 std::set UsedTypes;
2525 public:
2626 static char ID; // Pass identification, replacement for typeid
27 FindUsedTypes() : ModulePass((intptr_t)&ID) {}
27 FindUsedTypes() : ModulePass((intptr_t)&ID, true) {}
2828
2929 /// getTypes - After the pass has been run, return the set containing all of
3030 /// the types used in the module.
4949 void IncorporateValue(const Value *V);
5050
5151 public:
52
53 /// isAnalysis - Return true if this pass is implementing an analysis pass.
54 virtual bool isAnalysis() const { return true; }
55
5652 /// run - This incorporates all types used by the specified module
5753 bool runOnModule(Module &M);
5854
4646 public:
4747 static char ID; // Pass identification, replacement for typeid
4848
49 IntervalPartition() : FunctionPass((intptr_t)&ID), RootInterval(0) {}
50
51 /// isAnalysis - Return true if this pass is implementing an analysis pass.
52 virtual bool isAnalysis() const { return true; }
49 IntervalPartition() : FunctionPass((intptr_t)&ID, true), RootInterval(0) {}
5350
5451 // run - Calculate the interval partition for this function
5552 virtual bool runOnFunction(Function &F);
878878 public:
879879 static char ID; // Pass identification, replacement for typeid
880880
881 LoopInfo() : FunctionPass(intptr_t(&ID)) {
881 LoopInfo() : FunctionPass(intptr_t(&ID), true) {
882882 LI = new LoopInfoBase();
883883 }
884884
917917 inline bool isLoopHeader(BasicBlock *BB) const {
918918 return LI->isLoopHeader(BB);
919919 }
920
921 /// isAnalysis - Return true if this pass is implementing an analysis pass.
922 bool isAnalysis() const { return true; }
923920
924921 /// runOnFunction - Calculate the natural loop information.
925922 ///
2828 class LoopPass : public Pass {
2929
3030 public:
31 explicit LoopPass(intptr_t pid) : Pass(pid) {}
31 explicit LoopPass(intptr_t pid, bool AP = false) : Pass(pid, AP) {}
3232
3333 // runOnLoop - This method should be implemented by the subclass to perform
3434 // whatever action is necessary for the specfied Loop.
6565 static Instruction* const Dirty;
6666
6767 static char ID; // Class identification, replacement for typeinfo
68 MemoryDependenceAnalysis() : FunctionPass((intptr_t)&ID) {}
69
70 /// isAnalysis - Return true if this pass is implementing an analysis pass.
71 virtual bool isAnalysis() const { return true; }
68 MemoryDependenceAnalysis() : FunctionPass((intptr_t)&ID, true) {}
7269
7370 /// Pass Implementation stuff. This doesn't do any analysis.
7471 ///
2424 static char ID; // Pass identification, replacement for typeid
2525 DominatorTreeBase* DT;
2626
27 PostDominatorTree() : FunctionPass((intptr_t)&ID) {
27 PostDominatorTree() : FunctionPass((intptr_t)&ID, true) {
2828 DT = new DominatorTreeBase(true);
2929 }
30
31 /// isAnalysis - Return true if this pass is implementing an analysis pass.
32 virtual bool isAnalysis() const { return true; }
3330
3431 virtual bool runOnFunction(Function &F);
3532
7168 PostDominanceFrontier()
7269 : DominanceFrontierBase((intptr_t) &ID, true) {}
7370
74 /// isAnalysis - Return true if this pass is implementing an analysis pass.
75 virtual bool isAnalysis() const { return true; }
76
7771 virtual bool runOnFunction(Function &) {
7872 Frontiers.clear();
7973 PostDominatorTree &DT = getAnalysis();
191191 void *Impl; // ScalarEvolution uses the pimpl pattern
192192 public:
193193 static char ID; // Pass identification, replacement for typeid
194 ScalarEvolution() : FunctionPass((intptr_t)&ID), Impl(0) {}
194 ScalarEvolution() : FunctionPass((intptr_t)&ID, true), Impl(0) {}
195195
196196 /// getSCEV - Return a SCEV expression handle for the full generality of the
197197 /// specified expression.
290290 /// that no dangling references are left around.
291291 void deleteValueFromRecords(Value *V) const;
292292
293 /// isAnalysis - Return true if this pass is implementing an analysis pass.
294 virtual bool isAnalysis() const { return true; }
295
296293 virtual bool runOnFunction(Function &F);
297294 virtual void releaseMemory();
298295 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
3030
3131 struct CallGraphSCCPass : public Pass {
3232
33 explicit CallGraphSCCPass(intptr_t pid) : Pass(pid) {}
33 explicit CallGraphSCCPass(intptr_t pid, bool AP = false) : Pass(pid, AP) {}
3434
3535 /// doInitialization - This method is called before the SCC's of the program
3636 /// has been processed, allowing the pass to do initialization as necessary.
7272 class Pass {
7373 AnalysisResolver *Resolver; // Used to resolve analysis
7474 intptr_t PassID;
75
75 bool isAnalysisPass; // True if this pass is an analysis pass.
7676 // AnalysisImpls - This keeps track of which passes implement the interfaces
7777 // that are required by the current pass (to implement getAnalysis()).
7878 //
8181 void operator=(const Pass&); // DO NOT IMPLEMENT
8282 Pass(const Pass &); // DO NOT IMPLEMENT
8383 public:
84 explicit Pass(intptr_t pid) : Resolver(0), PassID(pid) {}
85 explicit Pass(const void *pid) : Resolver(0), PassID((intptr_t)pid) {}
84 explicit Pass(intptr_t pid, bool AP = false) : Resolver(0), PassID(pid),
85 isAnalysisPass(AP) {}
86 explicit Pass(const void *pid, bool AP = false) : Resolver(0),
87 PassID((intptr_t)pid),
88 isAnalysisPass(AP) {}
8689 virtual ~Pass();
8790
91 bool isAnalysis() const { return isAnalysisPass; }
8892 /// getPassName - Return a nice clean name for a pass. This usually
8993 /// implemented in terms of the name that is registered by one of the
9094 /// Registration templates, but can be overloaded directly.
129133 return Resolver;
130134 }
131135
132 /// isAnalysis - Return true if this pass is implementing an analysis pass.
133 virtual bool isAnalysis() const {
134 return false;
135 }
136
137136 /// getAnalysisUsage - This function should be overriden by passes that need
138137 /// analysis information to do their job. If a pass specifies that it uses a
139138 /// particular analysis result to this function, it can then use the
231230 return PMT_ModulePassManager;
232231 }
233232
234 explicit ModulePass(intptr_t pid) : Pass(pid) {}
235 explicit ModulePass(const void *pid) : Pass(pid) {}
233 explicit ModulePass(intptr_t pid, bool AP = false) : Pass(pid, AP) {}
234 explicit ModulePass(const void *pid, bool AP = false) : Pass(pid, AP) {}
236235 // Force out-of-line virtual method.
237236 virtual ~ModulePass();
238237 };
257256 ///
258257 bool runOnModule(Module &M) { return false; }
259258
260 explicit ImmutablePass(intptr_t pid) : ModulePass(pid) {}
261 explicit ImmutablePass(const void *pid) : ModulePass(pid) {}
259 explicit ImmutablePass(intptr_t pid, bool AP = false) : ModulePass(pid, AP) {}
260 explicit ImmutablePass(const void *pid, bool AP = false)
261 : ModulePass(pid, AP) {}
262262
263263 // Force out-of-line virtual method.
264264 virtual ~ImmutablePass();
275275 ///
276276 class FunctionPass : public Pass {
277277 public:
278 explicit FunctionPass(intptr_t pid) : Pass(pid) {}
279 explicit FunctionPass(const void *pid) : Pass(pid) {}
278 explicit FunctionPass(intptr_t pid, bool AP = false) : Pass(pid, AP) {}
279 explicit FunctionPass(const void *pid, bool AP = false) : Pass(pid, AP) {}
280280
281281 /// doInitialization - Virtual method overridden by subclasses to do
282282 /// any necessary per-module initialization.
327327 ///
328328 class BasicBlockPass : public Pass {
329329 public:
330 explicit BasicBlockPass(intptr_t pid) : Pass(pid) {}
331 explicit BasicBlockPass(const void *pid) : Pass(pid) {}
330 explicit BasicBlockPass(intptr_t pid, bool AP = false) : Pass(pid, AP) {}
331 explicit BasicBlockPass(const void *pid, bool AP = false) : Pass(pid, AP) {}
332332
333333 /// doInitialization - Virtual method overridden by subclasses to do
334334 /// any necessary per-module initialization.
3434 Module *M;
3535 public:
3636 static char ID; // Class identification, replacement for typeinfo
37 AliasAnalysisCounter() : ModulePass((intptr_t) &ID) {
37 AliasAnalysisCounter() : ModulePass((intptr_t) &ID, true) {
3838 No = May = Must = 0;
3939 NoMR = JustRef = JustMod = MR = 0;
4040 }
7070 }
7171 }
7272 }
73
74 /// isAnalysis - Return true if this pass is implementing an analysis pass.
75 virtual bool isAnalysis() const { return true; }
7673
7774 bool runOnModule(Module &M) {
7875 this->M = &M;
5151
5252 public:
5353 static char ID; // Pass identification, replacement for typeid
54 AAEval() : FunctionPass((intptr_t)&ID) {}
54 AAEval() : FunctionPass((intptr_t)&ID, true) {}
5555
5656 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
5757 AU.addRequired();
6868 }
6969 return false;
7070 }
71
72 /// isAnalysis - Return true if this pass is implementing an analysis pass.
73 virtual bool isAnalysis() const { return true; }
7471
7572 bool runOnFunction(Function &F);
7673 bool doFinalization(Module &M);
4040
4141 public:
4242 static char ID; // Class identification, replacement for typeinfo
43 AliasDebugger() : ModulePass((intptr_t)&ID) {}
44
45 /// isAnalysis - Return true if this pass is implementing an analysis pass.
46 virtual bool isAnalysis() const { return true; }
43 AliasDebugger() : ModulePass((intptr_t)&ID, true) {}
4744
4845 bool runOnModule(Module &M) {
4946 InitializeAliasAnalysis(this); // set up super class
550550 AliasSetTracker *Tracker;
551551 public:
552552 static char ID; // Pass identification, replacement for typeid
553 AliasSetPrinter() : FunctionPass((intptr_t)&ID) {}
553 AliasSetPrinter() : FunctionPass((intptr_t)&ID, true) {}
554554
555555 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
556556 AU.setPreservesAll();
557557 AU.addRequired();
558558 }
559
560 /// isAnalysis - Return true if this pass is implementing an analysis pass.
561 virtual bool isAnalysis() const { return true; }
562559
563560 virtual bool runOnFunction(Function &F) {
564561 Tracker = new AliasSetTracker(getAnalysis());
9191 namespace {
9292 struct VISIBILITY_HIDDEN CFGViewer : public FunctionPass {
9393 static char ID; // Pass identifcation, replacement for typeid
94 CFGViewer() : FunctionPass((intptr_t)&ID) {}
95
96 /// isAnalysis - Return true if this pass is implementing an analysis pass.
97 virtual bool isAnalysis() const { return true; }
94 CFGViewer() : FunctionPass((intptr_t)&ID, true) {}
9895
9996 virtual bool runOnFunction(Function &F) {
10097 F.viewCFG();
114111
115112 struct VISIBILITY_HIDDEN CFGOnlyViewer : public FunctionPass {
116113 static char ID; // Pass identifcation, replacement for typeid
117 CFGOnlyViewer() : FunctionPass((intptr_t)&ID) {}
118
119 /// isAnalysis - Return true if this pass is implementing an analysis pass.
120 virtual bool isAnalysis() const { return true; }
114 CFGOnlyViewer() : FunctionPass((intptr_t)&ID, true) {}
121115
122116 virtual bool runOnFunction(Function &F) {
123117 CFGOnly = true;
140134 struct VISIBILITY_HIDDEN CFGPrinter : public FunctionPass {
141135 static char ID; // Pass identification, replacement for typeid
142136 CFGPrinter() : FunctionPass((intptr_t)&ID) {}
143 explicit CFGPrinter(intptr_t pid) : FunctionPass(pid) {}
144
145 /// isAnalysis - Return true if this pass is implementing an analysis pass.
146 virtual bool isAnalysis() const { return true; }
137 explicit CFGPrinter(intptr_t pid) : FunctionPass(pid, true) {}
147138
148139 virtual bool runOnFunction(Function &F) {
149140 std::string Filename = "cfg." + F.getName() + ".dot";
172163 struct VISIBILITY_HIDDEN CFGOnlyPrinter : public CFGPrinter {
173164 static char ID; // Pass identification, replacement for typeid
174165 CFGOnlyPrinter() : CFGPrinter((intptr_t)&ID) {}
175
176 /// isAnalysis - Return true if this pass is implementing an analysis pass.
177 virtual bool isAnalysis() const { return true; }
178
179166 virtual bool runOnFunction(Function &F) {
180167 bool OldCFGOnly = CFGOnly;
181168 CFGOnly = true;
429429
430430 public:
431431 static char ID;
432 Andersens() : ModulePass((intptr_t)&ID) {}
433
434 /// isAnalysis - Return true if this pass is implementing an analysis pass.
435 virtual bool isAnalysis() const { return true; }
432 Andersens() : ModulePass((intptr_t)&ID, true) {}
436433
437434 bool runOnModule(Module &M) {
438435 InitializeAliasAnalysis(this);
8383
8484 public:
8585 static char ID;
86 GlobalsModRef() : ModulePass((intptr_t)&ID) {}
87
88 /// isAnalysis - Return true if this pass is implementing an analysis pass.
89 virtual bool isAnalysis() const { return true; }
86 GlobalsModRef() : ModulePass((intptr_t)&ID, true) {}
9087
9188 bool runOnModule(Module &M) {
9289 InitializeAliasAnalysis(this); // set up super class
5050 abort();
5151 }
5252 public:
53
54 /// isAnalysis - Return true if this pass is implementing an analysis pass.
55 virtual bool isAnalysis() const { return true; }
56
5753 static char ID; // Pass identification, replacement for typeid
58 InstCount() : FunctionPass((intptr_t)&ID) {}
54 InstCount() : FunctionPass((intptr_t)&ID, true) {}
5955
6056 virtual bool runOnFunction(Function &F);
6157
4040 // FIXME: This should not be a FunctionPass.
4141 struct VISIBILITY_HIDDEN LoadVN : public FunctionPass, public ValueNumbering {
4242 static char ID; // Class identification, replacement for typeinfo
43 LoadVN() : FunctionPass((intptr_t)&ID) {}
44
45 /// isAnalysis - Return true if this pass is implementing an analysis pass.
46 virtual bool isAnalysis() const { return true; }
43 LoadVN() : FunctionPass((intptr_t)&ID, true) {}
4744
4845 /// Pass Implementation stuff. This doesn't do any analysis.
4946 ///
3333 public:
3434 static char ID; // Class identification, replacement for typeinfo
3535 explicit LoaderPass(const std::string &filename = "")
36 : ModulePass((intptr_t)&ID), Filename(filename) {
36 : ModulePass((intptr_t)&ID, true), Filename(filename) {
3737 if (filename.empty()) Filename = ProfileInfoFilename;
3838 }
3939
4444 virtual const char *getPassName() const {
4545 return "Profiling information loader";
4646 }
47
48 /// isAnalysis - Return true if this pass is implementing an analysis pass.
49 virtual bool isAnalysis() const { return true; }
5047
5148 /// run - Load the profile information from the specified file.
5249 virtual bool runOnModule(Module &M);
429429 // generate the analysis again. Stale analysis info should not be
430430 // available at this point.
431431 if (P->isAnalysis() && findAnalysisPass(P->getPassInfo()))
432 return;
432 return;
433433
434434 AnalysisUsage AnUsage;
435435 P->getAnalysisUsage(AnUsage);