llvm.org GIT mirror llvm / 9ccaf53
Don't use PassInfo* as a type identifier for passes. Instead, use the address of the static ID member as the sole unique type identifier. Clean up APIs related to this change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110396 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 9 years ago
212 changed file(s) with 494 addition(s) and 490 deletion(s). Raw diff Collapse all Expand all
2121 struct DOTGraphTraitsViewer : public FunctionPass {
2222 std::string Name;
2323
24 DOTGraphTraitsViewer(std::string GraphName, const void *ID) : FunctionPass(ID) {
24 DOTGraphTraitsViewer(std::string GraphName, char &ID) : FunctionPass(ID) {
2525 Name = GraphName;
2626 }
2727
4747
4848 std::string Name;
4949
50 DOTGraphTraitsPrinter(std::string GraphName, const void *ID)
50 DOTGraphTraitsPrinter(std::string GraphName, char &ID)
5151 : FunctionPass(ID) {
5252 Name = GraphName;
5353 }
701701 static char ID; // Pass ID, replacement for typeid
702702 DominatorTreeBase* DT;
703703
704 DominatorTree() : FunctionPass(&ID) {
704 DominatorTree() : FunctionPass(ID) {
705705 DT = new DominatorTreeBase(false);
706706 }
707707
889889 const bool IsPostDominators;
890890
891891 public:
892 DominanceFrontierBase(void *ID, bool isPostDom)
892 DominanceFrontierBase(char &ID, bool isPostDom)
893893 : FunctionPass(ID), IsPostDominators(isPostDom) {}
894894
895895 /// getRoots - Return the root blocks of the current CFG. This may include
10081008 public:
10091009 static char ID; // Pass ID, replacement for typeid
10101010 DominanceFrontier() :
1011 DominanceFrontierBase(&ID, false) {}
1011 DominanceFrontierBase(ID, false) {}
10121012
10131013 BasicBlock *getRoot() const {
10141014 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) {}
2929
3030 /// getTypes - After the pass has been run, return the set containing all of
3131 /// 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) {}
5151
5252 // run - Calculate the interval partition for this function
5353 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) {}
3434 ~LazyValueInfo() { assert(PImpl == 0 && "releaseMemory not called"); }
3535
3636 /// 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) {
3131 }
32 explicit LibCallAliasAnalysis(const void *ID, LibCallInfo *LC)
32 explicit LibCallAliasAnalysis(char &ID, LibCallInfo *LC)
3333 : FunctionPass(ID), LCI(LC) {
3434 }
3535 ~LibCallAliasAnalysis();
5454 /// an analysis interface through multiple inheritance. If needed, it
5555 /// should override this to adjust the this pointer as needed for the
5656 /// specified pass info.
57 virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
58 if (PI->isPassID(&AliasAnalysis::ID))
57 virtual void *getAdjustedAnalysisPointer(const void *PI) {
58 if (PI == &AliasAnalysis::ID)
5959 return (AliasAnalysis*)this;
6060 return this;
6161 }
9090
9191 public:
9292 static char ID; // Class identification, replacement for typeinfo
93 LoopDependenceAnalysis() : LoopPass(&ID) {}
93 LoopDependenceAnalysis() : LoopPass(ID) {}
9494
9595 /// isDependencePair - Check whether two values can possibly give rise to
9696 /// a data dependence: that is the case if both are instructions accessing
939939 public:
940940 static char ID; // Pass identification, replacement for typeid
941941
942 LoopInfo() : FunctionPass(&ID) {}
942 LoopInfo() : FunctionPass(ID) {}
943943
944944 LoopInfoBase& getBase() { return LI; }
945945
2727
2828 class LoopPass : public Pass {
2929 public:
30 explicit LoopPass(intptr_t pid) : Pass(PT_Loop, pid) {}
31 explicit LoopPass(void *pid) : Pass(PT_Loop, pid) {}
30 explicit LoopPass(char &pid) : Pass(PT_Loop, pid) {}
3231
3332 /// getPrinterPass - Get a pass to print the function corresponding
3433 /// to a Loop.
9191 // file.
9292 //
9393 ModulePass *createProfileLoaderPass();
94 extern const PassInfo *ProfileLoaderPassID;
94 extern char &ProfileLoaderPassID;
9595
9696 //===--------------------------------------------------------------------===//
9797 //
105105 // instead of loading it from a previous run.
106106 //
107107 FunctionPass *createProfileEstimatorPass();
108 extern const PassInfo *ProfileEstimatorPassID;
108 extern char &ProfileEstimatorPassID;
109109
110110 //===--------------------------------------------------------------------===//
111111 //
2424 static char ID; // Pass identification, replacement for typeid
2525 DominatorTreeBase* DT;
2626
27 PostDominatorTree() : FunctionPass(&ID) {
27 PostDominatorTree() : FunctionPass(ID) {
2828 DT = new DominatorTreeBase(true);
2929 }
3030
105105 struct PostDominanceFrontier : public DominanceFrontierBase {
106106 static char ID;
107107 PostDominanceFrontier()
108 : DominanceFrontierBase(&ID, true) {}
108 : DominanceFrontierBase(ID, true) {}
109109
110110 virtual bool runOnFunction(Function &) {
111111 Frontiers.clear();
3232
3333 class CallGraphSCCPass : public Pass {
3434 public:
35 explicit CallGraphSCCPass(intptr_t pid) : Pass(PT_CallGraphSCC, pid) {}
36 explicit CallGraphSCCPass(void *pid) : Pass(PT_CallGraphSCC, pid) {}
35 explicit CallGraphSCCPass(char &pid) : Pass(PT_CallGraphSCC, pid) {}
3736
3837 /// createPrinterPass - Get a pass that prints the Module
3938 /// corresponding to a CallGraph.
2222 public:
2323 static char ID;
2424
25 CalculateSpillWeights() : MachineFunctionPass(&ID) {}
25 CalculateSpillWeights() : MachineFunctionPass(ID) {}
2626
2727 virtual void getAnalysisUsage(AnalysisUsage &au) const;
2828
6767
6868 public:
6969 static char ID; // Pass identification, replacement for typeid
70 LiveIntervals() : MachineFunctionPass(&ID) {}
70 LiveIntervals() : MachineFunctionPass(ID) {}
7171
7272 // Calculate the spill weight to assign to a single instruction.
7373 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) {}
4242
4343 typedef SS2IntervalMap::iterator iterator;
4444 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) {}
4949
5050 /// VarInfo - This represents the regions where a virtual register is live in
5151 /// the program. We represent this with three different pieces of
3030 /// override runOnMachineFunction.
3131 class MachineFunctionPass : public FunctionPass {
3232 protected:
33 explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {}
34 explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {}
33 explicit MachineFunctionPass(char &ID) : FunctionPass(ID) {}
3534
3635 /// runOnMachineFunction - This method must be overloaded to perform the
3736 /// desired machine code transformation or analysis.
6666 public:
6767 static char ID; // Pass identification, replacement for typeid
6868
69 MachineLoopInfo() : MachineFunctionPass(&ID) {}
69 MachineLoopInfo() : MachineFunctionPass(ID) {}
7070
7171 LoopInfoBase& getBase() { return LI; }
7272
4242
4343 /// MachineLoopInfo pass - This pass is a loop analysis pass.
4444 ///
45 extern const PassInfo *const MachineLoopInfoID;
45 extern char &MachineLoopInfoID;
4646
4747 /// MachineDominators pass - This pass is a machine dominators analysis pass.
4848 ///
49 extern const PassInfo *const MachineDominatorsID;
49 extern char &MachineDominatorsID;
5050
5151 /// PHIElimination pass - This pass eliminates machine instruction PHI nodes
5252 /// by inserting copy instructions. This destroys SSA information, but is the
5353 /// desired input for some register allocators. This pass is "required" by
5454 /// these register allocator like this: AU.addRequiredID(PHIEliminationID);
5555 ///
56 extern const PassInfo *const PHIEliminationID;
56 extern char &PHIEliminationID;
5757
5858 /// StrongPHIElimination pass - This pass eliminates machine instruction PHI
5959 /// nodes by inserting copy instructions. This destroys SSA information, but
6161 /// "required" by these register allocator like this:
6262 /// AU.addRequiredID(PHIEliminationID);
6363 /// This pass is still in development
64 extern const PassInfo *const StrongPHIEliminationID;
65
66 extern const PassInfo *const PreAllocSplittingID;
64 extern char &StrongPHIEliminationID;
65
66 extern char &PreAllocSplittingID;
6767
6868 /// SimpleRegisterCoalescing pass. Aggressively coalesces every register
6969 /// copy it can.
7070 ///
71 extern const PassInfo *const SimpleRegisterCoalescingID;
71 extern char &SimpleRegisterCoalescingID;
7272
7373 /// TwoAddressInstruction pass - This pass reduces two-address instructions to
7474 /// use two operands. This destroys SSA information but it is desired by
7575 /// register allocators.
76 extern const PassInfo *const TwoAddressInstructionPassID;
76 extern char &TwoAddressInstructionPassID;
7777
7878 /// UnreachableMachineBlockElimination pass - This pass removes unreachable
7979 /// machine basic blocks.
80 extern const PassInfo *const UnreachableMachineBlockElimID;
80 extern char &UnreachableMachineBlockElimID;
8181
8282 /// DeadMachineInstructionElim pass - This pass removes dead machine
8383 /// instructions.
3030 public:
3131 static char ID;
3232
33 ProcessImplicitDefs() : MachineFunctionPass(&ID) {}
33 ProcessImplicitDefs() : MachineFunctionPass(ID) {}
3434
3535 virtual void getAnalysisUsage(AnalysisUsage &au) const;
3636
474474 public:
475475 static char ID;
476476
477 SlotIndexes() : MachineFunctionPass(&ID), indexListHead(0) {}
477 SlotIndexes() : MachineFunctionPass(ID), indexListHead(0) {}
478478
479479 virtual void getAnalysisUsage(AnalysisUsage &au) const;
480480 virtual void releaseMemory();
4949 class StringRef;
5050
5151 // AnalysisID - Use the PassInfo to identify a pass...
52 typedef const PassInfo* AnalysisID;
52 typedef const void* AnalysisID;
5353
5454 /// Different types of internal pass managers. External pass managers
5555 /// (PassManager and FunctionPassManager) are not represented here.
8181 ///
8282 class Pass {
8383 AnalysisResolver *Resolver; // Used to resolve analysis
84 intptr_t PassID;
84 const void *PassID;
8585 PassKind Kind;
8686 void operator=(const Pass&); // DO NOT IMPLEMENT
8787 Pass(const Pass &); // DO NOT IMPLEMENT
8888
8989 public:
90 explicit Pass(PassKind K, intptr_t pid);
91 explicit Pass(PassKind K, const void *pid);
90 explicit Pass(PassKind K, char &pid);
9291 virtual ~Pass();
9392
9493
10099 ///
101100 virtual const char *getPassName() const;
102101
103 /// getPassInfo - Return the PassInfo data structure that corresponds to this
104 /// pass... If the pass has not been registered, this will return null.
105 ///
106 const PassInfo *getPassInfo() const;
102 /// getPassID - Return the PassID number that corresponds to this pass.
103 virtual AnalysisID getPassID() const {
104 return PassID;
105 }
107106
108107 /// print - Print out the internal state of the pass. This is called by
109108 /// Analyze to print out the contents of an analysis. Otherwise it is not
158157 /// an analysis interface through multiple inheritance. If needed, it should
159158 /// override this to adjust the this pointer as needed for the specified pass
160159 /// info.
161 virtual void *getAdjustedAnalysisPointer(const PassInfo *);
160 virtual void *getAdjustedAnalysisPointer(AnalysisID ID);
162161 virtual ImmutablePass *getAsImmutablePass();
163162 virtual PMDataManager *getAsPMDataManager();
164163
169168 // dumpPassStructure - Implement the -debug-passes=PassStructure option
170169 virtual void dumpPassStructure(unsigned Offset = 0);
171170
172 template
173 static const PassInfo *getClassPassInfo() {
174 return lookupPassInfo(intptr_t(&AnalysisClass::ID));
175 }
176
177171 // lookupPassInfo - Return the pass info object for the specified pass class,
178172 // or null if it is not known.
179 static const PassInfo *lookupPassInfo(intptr_t TI);
173 static const PassInfo *lookupPassInfo(const void *TI);
180174
181175 // lookupPassInfo - Return the pass info object for the pass with the given
182176 // argument string, or null if it is not known.
199193 /// don't have the class name available (use getAnalysisIfAvailable if you
200194 /// do), but it can tell you if you need to preserve the pass at least.
201195 ///
202 bool mustPreserveAnalysisID(const PassInfo *AnalysisID) const;
196 bool mustPreserveAnalysisID(char &AID) const;
203197
204198 /// getAnalysis() - This function is used by subclasses to get
205199 /// to the analysis information that they claim to use by overriding the
212206 AnalysisType &getAnalysis(Function &F); // Defined in PassAnalysisSupport.h
213207
214208 template
215 AnalysisType &getAnalysisID(const PassInfo *PI) const;
209 AnalysisType &getAnalysisID(AnalysisID PI) const;
216210
217211 template
218 AnalysisType &getAnalysisID(const PassInfo *PI, Function &F);
212 AnalysisType &getAnalysisID(AnalysisID PI, Function &F);
219213 };
220214
221215
239233 /// Return what kind of Pass Manager can manage this pass.
240234 virtual PassManagerType getPotentialPassManagerType() const;
241235
242 explicit ModulePass(intptr_t pid) : Pass(PT_Module, pid) {}
243 explicit ModulePass(const void *pid) : Pass(PT_Module, pid) {}
236 explicit ModulePass(char &pid) : Pass(PT_Module, pid) {}
244237 // Force out-of-line virtual method.
245238 virtual ~ModulePass();
246239 };
267260 ///
268261 bool runOnModule(Module &) { return false; }
269262
270 explicit ImmutablePass(intptr_t pid) : ModulePass(pid) {}
271 explicit ImmutablePass(const void *pid)
263 explicit ImmutablePass(char &pid)
272264 : ModulePass(pid) {}
273265
274266 // Force out-of-line virtual method.
286278 ///
287279 class FunctionPass : public Pass {
288280 public:
289 explicit FunctionPass(intptr_t pid) : Pass(PT_Function, pid) {}
290 explicit FunctionPass(const void *pid) : Pass(PT_Function, pid) {}
281 explicit FunctionPass(char &pid) : Pass(PT_Function, pid) {}
291282
292283 /// createPrinterPass - Get a function printer pass.
293284 Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const;
339330 ///
340331 class BasicBlockPass : public Pass {
341332 public:
342 explicit BasicBlockPass(intptr_t pid) : Pass(PT_BasicBlock, pid) {}
343 explicit BasicBlockPass(const void *pid) : Pass(PT_BasicBlock, pid) {}
333 explicit BasicBlockPass(char &pid) : Pass(PT_BasicBlock, pid) {}
344334
345335 /// createPrinterPass - Get a function printer pass.
346336 Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const;
4848 // addRequired - Add the specified ID to the required set of the usage info
4949 // for a pass.
5050 //
51 AnalysisUsage &addRequiredID(AnalysisID ID);
51 AnalysisUsage &addRequiredID(const void *ID);
52 AnalysisUsage &addRequiredID(char &ID);
5253 template
5354 AnalysisUsage &addRequired() {
54 return addRequiredID(Pass::getClassPassInfo());
55 }
56
57 AnalysisUsage &addRequiredTransitiveID(AnalysisID ID);
55 return addRequiredID(PassClass::ID);
56 }
57
58 AnalysisUsage &addRequiredTransitiveID(char &ID);
5859 template
5960 AnalysisUsage &addRequiredTransitive() {
60 AnalysisID ID = Pass::getClassPassInfo();
61 return addRequiredTransitiveID(ID);
61 return addRequiredTransitiveID(PassClass::ID);
6262 }
6363
6464 // addPreserved - Add the specified ID to the set of analyses preserved by
6565 // this pass
6666 //
67 AnalysisUsage &addPreservedID(AnalysisID ID) {
67 AnalysisUsage &addPreservedID(const void *ID) {
6868 Preserved.push_back(ID);
6969 return *this;
7070 }
71 AnalysisUsage &addPreservedID(char &ID) {
72 Preserved.push_back(&ID);
73 return *this;
74 }
7175
7276 // addPreserved - Add the specified Pass class to the set of analyses
7377 // preserved by this pass.
7478 //
7579 template
7680 AnalysisUsage &addPreserved() {
77 assert(Pass::getClassPassInfo() && "Pass class not registered!");
78 Preserved.push_back(Pass::getClassPassInfo());
81 Preserved.push_back(&PassClass::ID);
7982 return *this;
8083 }
8184
8487 // This can be useful when a pass is trivially preserved, but may not be
8588 // linked in. Be careful about spelling!
8689 //
87 AnalysisUsage &addPreserved(StringRef Arg) {
88 const PassInfo *PI = Pass::lookupPassInfo(Arg);
89 // If the pass exists, preserve it. Otherwise silently do nothing.
90 if (PI) Preserved.push_back(PI);
91 return *this;
92 }
90 AnalysisUsage &addPreserved(StringRef Arg);
9391
9492 // setPreservesAll - Set by analyses that do not transform their input at all
9593 void setPreservesAll() { PreservesAll = true; }
129127 inline PMDataManager &getPMDataManager() { return PM; }
130128
131129 // Find pass that is implementing PI.
132 Pass *findImplPass(const PassInfo *PI) {
130 Pass *findImplPass(AnalysisID PI) {
133131 Pass *ResultPass = 0;
134132 for (unsigned i = 0; i < AnalysisImpls.size() ; ++i) {
135133 if (AnalysisImpls[i].first == PI) {
141139 }
142140
143141 // Find pass that is implementing PI. Initialize pass for Function F.
144 Pass *findImplPass(Pass *P, const PassInfo *PI, Function &F);
145
146 void addAnalysisImplsPair(const PassInfo *PI, Pass *P) {
147 std::pair pir = std::make_pair(PI,P);
142 Pass *findImplPass(Pass *P, AnalysisID PI, Function &F);
143
144 void addAnalysisImplsPair(AnalysisID PI, Pass *P) {
145 std::pair pir = std::make_pair(PI,P);
148146 AnalysisImpls.push_back(pir);
149147 }
150148
159157
160158 // AnalysisImpls - This keeps track of which passes implements the interfaces
161159 // that are required by the current pass (to implement getAnalysis()).
162 std::vectorconst PassInfo*, Pass*> > AnalysisImpls;
160 std::vectorAnalysisID, Pass*> > AnalysisImpls;
163161
164162 private:
165163 // PassManager that is used to resolve analysis info
178176 AnalysisType *Pass::getAnalysisIfAvailable() const {
179177 assert(Resolver && "Pass not resident in a PassManager object!");
180178
181 const PassInfo *PI = getClassPassInfo();
182 if (PI == 0) return 0;
179 const void *PI = &AnalysisType::ID;
183180
184181 Pass *ResultPass = Resolver->getAnalysisIfAvailable(PI, true);
185182 if (ResultPass == 0) return 0;
198195 template
199196 AnalysisType &Pass::getAnalysis() const {
200197 assert(Resolver && "Pass has not been inserted into a PassManager object!");
201 return getAnalysisID(getClassPassInfo());
202 }
203
204 template
205 AnalysisType &Pass::getAnalysisID(const PassInfo *PI) const {
198 return getAnalysisID(&AnalysisType::ID);
199 }
200
201 template
202 AnalysisType &Pass::getAnalysisID(AnalysisID PI) const {
206203 assert(PI && "getAnalysis for unregistered pass!");
207204 assert(Resolver&&"Pass has not been inserted into a PassManager object!");
208205 // PI *must* appear in AnalysisImpls. Because the number of passes used
228225 AnalysisType &Pass::getAnalysis(Function &F) {
229226 assert(Resolver &&"Pass has not been inserted into a PassManager object!");
230227
231 return getAnalysisID(getClassPassInfo(), F);
232 }
233
234 template
235 AnalysisType &Pass::getAnalysisID(const PassInfo *PI, Function &F) {
228 return getAnalysisID(&AnalysisType::ID, F);
229 }
230
231 template
232 AnalysisType &Pass::getAnalysisID(AnalysisID PI, Function &F) {
236233 assert(PI && "getAnalysis for unregistered pass!");
237234 assert(Resolver && "Pass has not been inserted into a PassManager object!");
238235 // PI *must* appear in AnalysisImpls. Because the number of passes used
301301 /// through getAnalysis interface.
302302 virtual void addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass);
303303
304 virtual Pass *getOnTheFlyPass(Pass *P, const PassInfo *PI, Function &F);
304 virtual Pass *getOnTheFlyPass(Pass *P, AnalysisID PI, Function &F);
305305
306306 /// Initialize available analysis information.
307307 void initializeAnalysisInfo() {
413413 public:
414414 static char ID;
415415 explicit FPPassManager(int Depth)
416 : ModulePass(&ID), PMDataManager(Depth) { }
416 : ModulePass(ID), PMDataManager(Depth) { }
417417
418418 /// run - Execute all of the passes scheduled for execution. Keep track of
419419 /// whether any of the passes modifies the module, and if so, return true.
3333 mutable sys::SmartMutex Lock;
3434
3535 /// PassInfoMap - Keep track of the PassInfo object for each registered pass.
36 typedef std::map<intptr_t, const PassInfo*> MapType;
36 typedef std::map<const void*, const PassInfo*> MapType;
3737 MapType PassInfoMap;
3838
3939 typedef StringMap StringMapType;
5050 public:
5151 static PassRegistry *getPassRegistry();
5252
53 const PassInfo *getPassInfo(intptr_t TI) const;
53 const PassInfo *getPassInfo(const void *TI) const;
5454 const PassInfo *getPassInfo(StringRef Arg) const;
5555
5656 void registerPass(const PassInfo &PI);
5757 void unregisterPass(const PassInfo &PI);
5858
5959 /// Analysis Group Mechanisms.
60 void registerAnalysisGroup(intptr_t InterfaceID, intptr_t PassID,
60 void registerAnalysisGroup(const void *InterfaceID, const void *PassID,
6161 PassInfo& Registeree, bool isDefault);
6262
6363 void enumerateWith(PassRegistrationListener *L);
4040 private:
4141 const char *const PassName; // Nice name for Pass
4242 const char *const PassArgument; // Command Line argument to run this pass
43 const intptr_t PassID;
43 const void *PassID;
4444 const bool IsCFGOnlyPass; // Pass only looks at the CFG.
4545 const bool IsAnalysis; // True if an analysis pass.
4646 const bool IsAnalysisGroup; // True if an analysis group.
5151 public:
5252 /// PassInfo ctor - Do not call this directly, this should only be invoked
5353 /// through RegisterPass.
54 PassInfo(const char *name, const char *arg, intptr_t pi,
54 PassInfo(const char *name, const char *arg, const void *pi,
5555 NormalCtor_t normal = 0,
5656 bool isCFGOnly = false, bool is_analysis = false)
5757 : PassName(name), PassArgument(arg), PassID(pi),
6262 /// PassInfo ctor - Do not call this directly, this should only be invoked
6363 /// through RegisterPass. This version is for use by analysis groups; it
6464 /// does not auto-register the pass.
65 PassInfo(const char *name, intptr_t pi)
65 PassInfo(const char *name, const void *pi)
6666 : PassName(name), PassArgument(""), PassID(pi),
6767 IsCFGOnlyPass(false),
6868 IsAnalysis(false), IsAnalysisGroup(true), NormalCtor(0) {
8080
8181 /// getTypeInfo - Return the id object for the pass...
8282 /// TODO : Rename
83 intptr_t getTypeInfo() const { return PassID; }
83 const void *getTypeInfo() const { return PassID; }
8484
8585 /// Return true if this PassID implements the specified ID pointer.
86 bool isPassID(void *IDPtr) const {
87 return PassID == (intptr_t)IDPtr;
86 bool isPassID(const void *IDPtr) const {
87 return PassID == IDPtr;
8888 }
8989
9090 /// isAnalysisGroup - Return true if this is an analysis group, not a normal
160160 // Register Pass using default constructor...
161161 RegisterPass(const char *PassArg, const char *Name, bool CFGOnly = false,
162162 bool is_analysis = false)
163 : PassInfo(Name, PassArg, intptr_t(&passName::ID),
163 : PassInfo(Name, PassArg, &passName::ID,
164164 PassInfo::NormalCtor_t(callDefaultCtor),
165165 CFGOnly, is_analysis) {
166166
190190 class RegisterAGBase : public PassInfo {
191191 protected:
192192 RegisterAGBase(const char *Name,
193 intptr_t InterfaceID,
194 intptr_t PassID = 0,
193 const void *InterfaceID,
194 const void *PassID = 0,
195195 bool isDefault = false);
196196 };
197197
199199 struct RegisterAnalysisGroup : public RegisterAGBase {
200200 explicit RegisterAnalysisGroup(PassInfo &RPB)
201201 : RegisterAGBase(RPB.getPassName(),
202 intptr_t(&Interface::ID), RPB.getTypeInfo(),
202 &Interface::ID, RPB.getTypeInfo(),
203203 Default) {
204204 }
205205
206206 explicit RegisterAnalysisGroup(const char *Name)
207 : RegisterAGBase(Name, intptr_t(&Interface::ID)) {
207 : RegisterAGBase(Name, &Interface::ID) {
208208 }
209209 };
210210
109109
110110 /// Constructs a TargetData from a specification string. See init().
111111 explicit TargetData(StringRef TargetDescription)
112 : ImmutablePass(&ID) {
112 : ImmutablePass(ID) {
113113 init(TargetDescription);
114114 }
115115
117117 explicit TargetData(const Module *M);
118118
119119 TargetData(const TargetData &TD) :
120 ImmutablePass(&ID),
120 ImmutablePass(ID),
121121 LittleEndian(TD.isLittleEndian()),
122122 PointerMemSize(TD.PointerMemSize),
123123 PointerABIAlign(TD.PointerABIAlign),
2929 /// perform the inlining operations that do not depend on the policy.
3030 ///
3131 struct Inliner : public CallGraphSCCPass {
32 explicit Inliner(void *ID);
33 explicit Inliner(void *ID, int Threshold);
32 explicit Inliner(char &ID);
33 explicit Inliner(char &ID, int Threshold);
3434
3535 /// getAnalysisUsage - For this class, we declare that we require and preserve
3636 /// the call graph. If the derived class implements this method, it should
148148 // ret i32 %Y
149149 //
150150 FunctionPass *createPromoteMemoryToRegisterPass();
151 extern const PassInfo *const PromoteMemoryToRegisterID;
151 extern char &PromoteMemoryToRegisterID;
152152
153153 //===----------------------------------------------------------------------===//
154154 //
157157 // hacking easier.
158158 //
159159 FunctionPass *createDemoteRegisterToMemoryPass();
160 extern const PassInfo *const DemoteRegisterToMemoryID;
160 extern char &DemoteRegisterToMemoryID;
161161
162162 //===----------------------------------------------------------------------===//
163163 //
201201 // (set, immediate dominators, tree, and frontier) information.
202202 //
203203 FunctionPass *createBreakCriticalEdgesPass();
204 extern const PassInfo *const BreakCriticalEdgesID;
204 extern char &BreakCriticalEdgesID;
205205
206206 //===----------------------------------------------------------------------===//
207207 //
212212 // AU.addRequiredID(LoopSimplifyID);
213213 //
214214 Pass *createLoopSimplifyPass();
215 extern const PassInfo *const LoopSimplifyID;
215 extern char &LoopSimplifyID;
216216
217217 //===----------------------------------------------------------------------===//
218218 //
227227 // chained binary branch instructions.
228228 //
229229 FunctionPass *createLowerSwitchPass();
230 extern const PassInfo *const LowerSwitchID;
230 extern char &LowerSwitchID;
231231
232232 //===----------------------------------------------------------------------===//
233233 //
242242 FunctionPass *createLowerInvokePass(const TargetLowering *TLI = 0);
243243 FunctionPass *createLowerInvokePass(const TargetLowering *TLI,
244244 bool useExpensiveEHSupport);
245 extern const PassInfo *const LowerInvokePassID;
245 extern char &LowerInvokePassID;
246246
247247 //===----------------------------------------------------------------------===//
248248 //
257257 // optimizations.
258258 //
259259 Pass *createLCSSAPass();
260 extern const PassInfo *const LCSSAID;
260 extern char &LCSSAID;
261261
262262 //===----------------------------------------------------------------------===//
263263 //
303303 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
304304 //
305305 FunctionPass *createInstructionNamerPass();
306 extern const PassInfo *const InstructionNamerID;
306 extern char &InstructionNamerID;
307307
308308 //===----------------------------------------------------------------------===//
309309 //
3838 public:
3939 static char ID; // Pass identification, replacement for typeid.
4040 SSI() :
41 FunctionPass(&ID) {
41 FunctionPass(ID) {
4242 }
4343
4444 void getAnalysisUsage(AnalysisUsage &AU) const;
2525 BasicBlock *ReturnBlock, *UnwindBlock, *UnreachableBlock;
2626 public:
2727 static char ID; // Pass identification, replacement for typeid
28 UnifyFunctionExitNodes() : FunctionPass(&ID),
28 UnifyFunctionExitNodes() : FunctionPass(ID),
2929 ReturnBlock(0), UnwindBlock(0) {}
3030
3131 // We can preserve non-critical-edgeness when we unify function exit nodes
3333 Module *M;
3434 public:
3535 static char ID; // Class identification, replacement for typeinfo
36 AliasAnalysisCounter() : ModulePass(&ID) {
36 AliasAnalysisCounter() : ModulePass(ID) {
3737 No = May = Must = 0;
3838 NoMR = JustRef = JustMod = MR = 0;
3939 }
8686 /// an analysis interface through multiple inheritance. If needed, it
8787 /// should override this to adjust the this pointer as needed for the
8888 /// specified pass info.
89 virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
90 if (PI->isPassID(&AliasAnalysis::ID))
89 virtual void *getAdjustedAnalysisPointer(AnalysisID PI) {
90 if (PI == &AliasAnalysis::ID)
9191 return (AliasAnalysis*)this;
9292 return this;
9393 }
4949
5050 public:
5151 static char ID; // Pass identification, replacement for typeid
52 AAEval() : FunctionPass(&ID) {}
52 AAEval() : FunctionPass(ID) {}
5353
5454 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
5555 AU.addRequired();
3838
3939 public:
4040 static char ID; // Class identification, replacement for typeinfo
41 AliasDebugger() : ModulePass(&ID) {}
41 AliasDebugger() : ModulePass(ID) {}
4242
4343 bool runOnModule(Module &M) {
4444 InitializeAliasAnalysis(this); // set up super class
8282 /// an analysis interface through multiple inheritance. If needed, it
8383 /// should override this to adjust the this pointer as needed for the
8484 /// specified pass info.
85 virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
86 if (PI->isPassID(&AliasAnalysis::ID))
85 virtual void *getAdjustedAnalysisPointer(AnalysisID PI) {
86 if (PI == &AliasAnalysis::ID)
8787 return (AliasAnalysis*)this;
8888 return this;
8989 }
578578 AliasSetTracker *Tracker;
579579 public:
580580 static char ID; // Pass identification, replacement for typeid
581 AliasSetPrinter() : FunctionPass(&ID) {}
581 AliasSetPrinter() : FunctionPass(ID) {}
582582
583583 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
584584 AU.setPreservesAll();
136136 ///
137137 struct NoAA : public ImmutablePass, public AliasAnalysis {
138138 static char ID; // Class identification, replacement for typeinfo
139 NoAA() : ImmutablePass(&ID) {}
140 explicit NoAA(void *PID) : ImmutablePass(PID) { }
139 NoAA() : ImmutablePass(ID) {}
140 explicit NoAA(char &PID) : ImmutablePass(PID) { }
141141
142142 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
143143 }
168168 /// an analysis interface through multiple inheritance. If needed, it should
169169 /// override this to adjust the this pointer as needed for the specified pass
170170 /// info.
171 virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
172 if (PI->isPassID(&AliasAnalysis::ID))
171 virtual void *getAdjustedAnalysisPointer(AnalysisID PI) {
172 if (PI == &AliasAnalysis::ID)
173173 return (AliasAnalysis*)this;
174174 return this;
175175 }
214214 /// derives from the NoAA class.
215215 struct BasicAliasAnalysis : public NoAA {
216216 static char ID; // Class identification, replacement for typeinfo
217 BasicAliasAnalysis() : NoAA(&ID) {}
217 BasicAliasAnalysis() : NoAA(ID) {}
218218
219219 AliasResult alias(const Value *V1, unsigned V1Size,
220220 const Value *V2, unsigned V2Size) {
239239 /// an analysis interface through multiple inheritance. If needed, it should
240240 /// override this to adjust the this pointer as needed for the specified pass
241241 /// info.
242 virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
243 if (PI->isPassID(&AliasAnalysis::ID))
242 virtual void *getAdjustedAnalysisPointer(AnalysisID PI) {
243 if (PI == &AliasAnalysis::ID)
244244 return (AliasAnalysis*)this;
245245 return this;
246246 }
2424 namespace {
2525 struct CFGViewer : public FunctionPass {
2626 static char ID; // Pass identifcation, replacement for typeid
27 CFGViewer() : FunctionPass(&ID) {}
27 CFGViewer() : FunctionPass(ID) {}
2828
2929 virtual bool runOnFunction(Function &F) {
3030 F.viewCFG();
4545 namespace {
4646 struct CFGOnlyViewer : public FunctionPass {
4747 static char ID; // Pass identifcation, replacement for typeid
48 CFGOnlyViewer() : FunctionPass(&ID) {}
48 CFGOnlyViewer() : FunctionPass(ID) {}
4949
5050 virtual bool runOnFunction(Function &F) {
5151 F.viewCFGOnly();
6767 namespace {
6868 struct CFGPrinter : public FunctionPass {
6969 static char ID; // Pass identification, replacement for typeid
70 CFGPrinter() : FunctionPass(&ID) {}
71 explicit CFGPrinter(void *pid) : FunctionPass(pid) {}
70 CFGPrinter() : FunctionPass(ID) {}
71 explicit CFGPrinter(char &pid) : FunctionPass(pid) {}
7272
7373 virtual bool runOnFunction(Function &F) {
7474 std::string Filename = "cfg." + F.getNameStr() + ".dot";
100100 namespace {
101101 struct CFGOnlyPrinter : public FunctionPass {
102102 static char ID; // Pass identification, replacement for typeid
103 CFGOnlyPrinter() : FunctionPass(&ID) {}
104 explicit CFGOnlyPrinter(void *pid) : FunctionPass(pid) {}
103 CFGOnlyPrinter() : FunctionPass(ID) {}
104 explicit CFGOnlyPrinter(char &pid) : FunctionPass(pid) {}
105105 virtual bool runOnFunction(Function &F) {
106106 std::string Filename = "cfg." + F.getNameStr() + ".dot";
107107 errs() << "Writing '" << Filename << "'...";
3939 void printVariableDeclaration(const Value *V);
4040 public:
4141 static char ID; // Pass identification
42 PrintDbgInfo() : FunctionPass(&ID), Out(outs()) {}
42 PrintDbgInfo() : FunctionPass(ID), Out(outs()) {}
4343
4444 virtual bool runOnFunction(Function &F);
4545 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){}
8989 };
9090
9191 struct DomOnlyViewer
9292 : public DOTGraphTraitsViewer {
9393 static char ID;
94 DomOnlyViewer() : DOTGraphTraitsViewer("domonly", &ID){}
94 DomOnlyViewer() : DOTGraphTraitsViewer("domonly", ID){}
9595 };
9696
9797 struct PostDomViewer
9898 : public DOTGraphTraitsViewer {
9999 static char ID;
100100 PostDomViewer() :
101 DOTGraphTraitsViewer("postdom", &ID){}
101 DOTGraphTraitsViewer("postdom", ID){}
102102 };
103103
104104 struct PostDomOnlyViewer
105105 : public DOTGraphTraitsViewer {
106106 static char ID;
107107 PostDomOnlyViewer() :
108 DOTGraphTraitsViewer("postdomonly", &ID){}
108 DOTGraphTraitsViewer("postdomonly", ID){}
109109 };
110110 } // end anonymous namespace
111111
132132 struct DomPrinter
133133 : public DOTGraphTraitsPrinter {
134134 static char ID;
135 DomPrinter() : DOTGraphTraitsPrinter("dom", &ID) {}
135 DomPrinter() : DOTGraphTraitsPrinter("dom", ID) {}
136136 };
137137
138138 struct DomOnlyPrinter
139139 : public DOTGraphTraitsPrinter {
140140 static char ID;
141 DomOnlyPrinter() : DOTGraphTraitsPrinter("domonly", &ID) {}
141 DomOnlyPrinter() : DOTGraphTraitsPrinter("domonly", ID) {}
142142 };
143143
144144 struct PostDomPrinter
145145 : public DOTGraphTraitsPrinter {
146146 static char ID;
147147 PostDomPrinter() :
148 DOTGraphTraitsPrinter("postdom", &ID) {}
148 DOTGraphTraitsPrinter("postdom", ID) {}
149149 };
150150
151151 struct PostDomOnlyPrinter
152152 : public DOTGraphTraitsPrinter {
153153 static char ID;
154154 PostDomOnlyPrinter() :
155 DOTGraphTraitsPrinter("postdomonly", &ID) {}
155 DOTGraphTraitsPrinter("postdomonly", ID) {}
156156 };
157157 } // end anonymous namespace
158158
4141
4242 public:
4343 static char ID; // Class identification, replacement for typeinfo
44 BasicCallGraph() : ModulePass(&ID), Root(0),
44 BasicCallGraph() : ModulePass(ID), Root(0),
4545 ExternalCallingNode(0), CallsExternalNode(0) {}
4646
4747 // runOnModule - Compute the call graph for the specified module.
8585 /// an analysis interface through multiple inheritance. If needed, it should
8686 /// override this to adjust the this pointer as needed for the specified pass
8787 /// info.
88 virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
89 if (PI->isPassID(&CallGraph::ID))
88 virtual void *getAdjustedAnalysisPointer(AnalysisID PI) {
89 if (PI == &CallGraph::ID)
9090 return (CallGraph*)this;
9191 return this;
9292 }
4444 public:
4545 static char ID;
4646 explicit CGPassManager(int Depth)
47 : ModulePass(&ID), PMDataManager(Depth) { }
47 : ModulePass(ID), PMDataManager(Depth) { }
4848
4949 /// run - Execute all of the passes scheduled for execution. Keep track of
5050 /// whether any of the passes modifies the module, and if so, return true.
581581
582582 public:
583583 static char ID;
584 PrintCallGraphPass() : CallGraphSCCPass(&ID), Out(dbgs()) {}
584 PrintCallGraphPass() : CallGraphSCCPass(ID), Out(dbgs()) {}
585585 PrintCallGraphPass(const std::string &B, raw_ostream &o)
586 : CallGraphSCCPass(&ID), Banner(B), Out(o) {}
586 : CallGraphSCCPass(ID), Banner(B), Out(o) {}
587587
588588 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
589589 AU.setPreservesAll();
8787
8888 public:
8989 static char ID;
90 GlobalsModRef() : ModulePass(&ID) {}
90 GlobalsModRef() : ModulePass(ID) {}
9191
9292 bool runOnModule(Module &M) {
9393 InitializeAliasAnalysis(this); // set up super class
149149 /// an analysis interface through multiple inheritance. If needed, it
150150 /// should override this to adjust the this pointer as needed for the
151151 /// specified pass info.
152 virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
153 if (PI->isPassID(&AliasAnalysis::ID))
152 virtual void *getAdjustedAnalysisPointer(AnalysisID PI) {
153 if (PI == &AliasAnalysis::ID)
154154 return (AliasAnalysis*)this;
155155 return this;
156156 }
139139 }
140140
141141 IVUsers::IVUsers()
142 : LoopPass(&ID) {
142 : LoopPass(ID) {
143143 }
144144
145145 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) {}
5454
5555 virtual bool runOnFunction(Function &F);
5656
9090 // distinguish it from a copy constructor. Always pass in false for now.
9191 //
9292 IntervalPartition::IntervalPartition(IntervalPartition &IP, bool)
93 : FunctionPass(&ID) {
93 : FunctionPass(ID) {
9494 assert(IP.getRootInterval() && "Cannot operate on empty IntervalPartitions!");
9595
9696 // Pass false to intervals_begin because we take ownership of it's memory
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) {}
111111
112112 virtual bool runOnFunction(Function &F);
113113
2424 INITIALIZE_PASS(LiveValues, "live-values",
2525 "Value Liveness Analysis", false, true);
2626
27 LiveValues::LiveValues() : FunctionPass(&ID) {}
27 LiveValues::LiveValues() : FunctionPass(ID) {}
2828
2929 void LiveValues::getAnalysisUsage(AnalysisUsage &AU) const {
3030 AU.addRequired();
2929
3030 public:
3131 static char ID;
32 PrintLoopPass() : LoopPass(&ID), Out(dbgs()) {}
32 PrintLoopPass() : LoopPass(ID), Out(dbgs()) {}
3333 PrintLoopPass(const std::string &B, raw_ostream &o)
34 : LoopPass(&ID), Banner(B), Out(o) {}
34 : LoopPass(ID), Banner(B), Out(o) {}
3535
3636 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
3737 AU.setPreservesAll();
5858 char LPPassManager::ID = 0;
5959
6060 LPPassManager::LPPassManager(int Depth)
61 : FunctionPass(&ID), PMDataManager(Depth) {
61 : FunctionPass(ID), PMDataManager(Depth) {
6262 skipThisLoop = false;
6363 redoThisLoop = false;
6464 LI = NULL;
4949 "Memory Dependence Analysis", false, true);
5050
5151 MemoryDependenceAnalysis::MemoryDependenceAnalysis()
52 : FunctionPass(&ID), PredCache(0) {
52 : FunctionPass(ID), PredCache(0) {
5353 }
5454 MemoryDependenceAnalysis::~MemoryDependenceAnalysis() {
5555 }
2929 DebugInfoFinder Finder;
3030 public:
3131 static char ID; // Pass identification, replacement for typeid
32 ModuleDebugInfoPrinter() : ModulePass(&ID) {}
32 ModuleDebugInfoPrinter() : ModulePass(ID) {}
3333
3434 virtual bool runOnModule(Module &M);
3535
2727 using namespace llvm;
2828
2929 char PointerTracking::ID = 0;
30 PointerTracking::PointerTracking() : FunctionPass(&ID) {}
30 PointerTracking::PointerTracking() : FunctionPass(ID) {}
3131
3232 bool PointerTracking::runOnFunction(Function &F) {
3333 predCache.clear();
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) {
4242 if (execcount == 0) ExecCount = LoopWeight;
4343 }
4444
5858 /// an analysis interface through multiple inheritance. If needed, it
5959 /// should override this to adjust the this pointer as needed for the
6060 /// specified pass info.
61 virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
62 if (PI->isPassID(&ProfileInfo::ID))
61 virtual void *getAdjustedAnalysisPointer(AnalysisID PI) {
62 if (PI == &ProfileInfo::ID)
6363 return (ProfileInfo*)this;
6464 return this;
6565 }
7777 static RegisterAnalysisGroup Y(X);
7878
7979 namespace llvm {
80 const PassInfo *ProfileEstimatorPassID = &X;
80 char &ProfileEstimatorPassID = ProfileEstimatorPass::ID;
8181
8282 FunctionPass *createProfileEstimatorPass() {
8383 return new ProfileEstimatorPass();
10751075 namespace {
10761076 struct NoProfileInfo : public ImmutablePass, public ProfileInfo {
10771077 static char ID; // Class identification, replacement for typeinfo
1078 NoProfileInfo() : ImmutablePass(&ID) {}
1078 NoProfileInfo() : ImmutablePass(ID) {}
10791079
10801080 /// getAdjustedAnalysisPointer - This method is used when a pass implements
10811081 /// an analysis interface through multiple inheritance. If needed, it
10821082 /// should override this to adjust the this pointer as needed for the
10831083 /// specified pass info.
1084 virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
1085 if (PI->isPassID(&ProfileInfo::ID))
1084 virtual void *getAdjustedAnalysisPointer(AnalysisID PI) {
1085 if (PI == &ProfileInfo::ID)
10861086 return (ProfileInfo*)this;
10871087 return this;
10881088 }
4444 public:
4545 static char ID; // Class identification, replacement for typeinfo
4646 explicit LoaderPass(const std::string &filename = "")
47 : ModulePass(&ID), Filename(filename) {
47 : ModulePass(ID), Filename(filename) {
4848 if (filename.empty()) Filename = ProfileInfoFilename;
4949 }
5050
6666 /// an analysis interface through multiple inheritance. If needed, it
6767 /// should override this to adjust the this pointer as needed for the
6868 /// specified pass info.
69 virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
70 if (PI->isPassID(&ProfileInfo::ID))
69 virtual void *getAdjustedAnalysisPointer(AnalysisID PI) {
70 if (PI == &ProfileInfo::ID)
7171 return (ProfileInfo*)this;
7272 return this;
7373 }
8383
8484 static RegisterAnalysisGroup Y(X);
8585
86 const PassInfo *llvm::ProfileLoaderPassID = &X;
86 char &llvm::ProfileLoaderPassID = LoaderPass::ID;
8787
8888 ModulePass *llvm::createProfileLoaderPass() { return new LoaderPass(); }
8989
5858 public:
5959 static char ID; // Class identification, replacement for typeinfo
6060
61 explicit ProfileVerifierPassT () : FunctionPass(&ID) {
61 explicit ProfileVerifierPassT () : FunctionPass(ID) {
6262 DisableAssertions = ProfileVerifierDisableAssertions;
6363 }
64 explicit ProfileVerifierPassT (bool da) : FunctionPass(&ID),
64 explicit ProfileVerifierPassT (bool da) : FunctionPass(ID),
6565 DisableAssertions(da) {
6666 }
6767
588588 TopLevelRegion = 0;
589589 }
590590
591 RegionInfo::RegionInfo() : FunctionPass(&ID) {
591 RegionInfo::RegionInfo() : FunctionPass(ID) {
592592 TopLevelRegion = 0;
593593 }
594594
120120 struct RegionViewer
121121 : public DOTGraphTraitsViewer {
122122 static char ID;
123 RegionViewer() : DOTGraphTraitsViewer("reg", &ID){}
123 RegionViewer() : DOTGraphTraitsViewer("reg", ID){}
124124 };
125125
126126 char RegionViewer::ID = 0;
130130 struct RegionOnlyViewer
131131 : public DOTGraphTraitsViewer {
132132 static char ID;
133 RegionOnlyViewer() : DOTGraphTraitsViewer("regonly", &ID){}
133 RegionOnlyViewer() : DOTGraphTraitsViewer("regonly", ID){}
134134 };
135135
136136 char RegionOnlyViewer::ID = 0;
142142 : public DOTGraphTraitsPrinter {
143143 static char ID;
144144 RegionPrinter() :
145 DOTGraphTraitsPrinter("reg", &ID) {}
145 DOTGraphTraitsPrinter("reg", ID) {}
146146 };
147147 } //end anonymous namespace
148148
156156 : public DOTGraphTraitsPrinter {
157157 static char ID;
158158 RegionOnlyPrinter() :
159 DOTGraphTraitsPrinter("reg", &ID) {}
159 DOTGraphTraitsPrinter("reg", ID) {}
160160 };
161161
162162 }
57415741 //===----------------------------------------------------------------------===//
57425742
57435743 ScalarEvolution::ScalarEvolution()
5744 : FunctionPass(&ID), FirstUnknown(0) {
5744 : FunctionPass(ID), FirstUnknown(0) {
57455745 }
57465746
57475747 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) {}
3737
3838 /// getAdjustedAnalysisPointer - This method is used when a pass implements
3939 /// an analysis interface through multiple inheritance. If needed, it
4040 /// should override this to adjust the this pointer as needed for the
4141 /// specified pass info.
42 virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
43 if (PI->isPassID(&AliasAnalysis::ID))
42 virtual void *getAdjustedAnalysisPointer(AnalysisID PI) {
43 if (PI == &AliasAnalysis::ID)
4444 return (AliasAnalysis*)this;
4545 return this;
4646 }
8181 public AliasAnalysis {
8282 public:
8383 static char ID; // Class identification, replacement for typeinfo
84 TypeBasedAliasAnalysis() : ImmutablePass(&ID) {}
84 TypeBasedAliasAnalysis() : ImmutablePass(ID) {}
8585
8686 /// getAdjustedAnalysisPointer - This method is used when a pass implements
8787 /// an analysis interface through multiple inheritance. If needed, it
8888 /// should override this to adjust the this pointer as needed for the
8989 /// specified pass info.
90 virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
91 if (PI->isPassID(&AliasAnalysis::ID))
90 virtual void *getAdjustedAnalysisPointer(const void *PI) {
91 if (PI == &AliasAnalysis::ID)
9292 return (AliasAnalysis*)this;
9393 return this;
9494 }
2020 public:
2121 static char ID; // Pass identification, replacement for typeid
2222 explicit WriteBitcodePass(raw_ostream &o)
23 : ModulePass(&ID), OS(o) {}
23 : ModulePass(ID), OS(o) {}
2424
2525 const char *getPassName() const { return "Bitcode Writer"; }
2626
9090
9191
9292 AsmPrinter::AsmPrinter(TargetMachine &tm, MCStreamer &Streamer)
93 : MachineFunctionPass(&ID),
93 : MachineFunctionPass(ID),
9494 TM(tm), MAI(tm.getMCAsmInfo()),
9595 OutContext(Streamer.getContext()),
9696 OutStreamer(Streamer),
6464 public:
6565 static char ID;
6666 explicit BranchFolderPass(bool defaultEnableTailMerge)
67 : MachineFunctionPass(&ID), BranchFolder(defaultEnableTailMerge) {}
67 : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge) {}
6868
6969 virtual bool runOnMachineFunction(MachineFunction &MF);
7070 virtual const char *getPassName() const { return "Control Flow Optimizer"; }
3535
3636 public:
3737 static char ID;
38 CodePlacementOpt() : MachineFunctionPass(&ID) {}
38 CodePlacementOpt() : MachineFunctionPass(ID) {}
3939
4040 virtual bool runOnMachineFunction(MachineFunction &MF);
4141 virtual const char *getPassName() const {
3535
3636 public:
3737 static char ID; // Pass identification, replacement for typeid
38 DeadMachineInstructionElim() : MachineFunctionPass(&ID) {}
38 DeadMachineInstructionElim() : MachineFunctionPass(ID) {}
3939
4040 private:
4141 bool isDead(const MachineInstr *MI) const;
159159 public:
160160 static char ID; // Pass identification, replacement for typeid.
161161 DwarfEHPrepare(const TargetMachine *tm, bool fast) :
162 FunctionPass(&ID), TM(tm), TLI(TM->getTargetLowering()),
162 FunctionPass(ID), TM(tm), TLI(TM->getTargetLowering()),
163163 CompileFast(fast),
164164 ExceptionValueIntrinsic(0), SelectorIntrinsic(0),
165165 URoR(0), EHCatchAllValue(0), RewindFunction(0) {}
6262 //===----------------------------------------------------------------------===//
6363
6464 ELFWriter::ELFWriter(raw_ostream &o, TargetMachine &tm)
65 : MachineFunctionPass(&ID), O(o), TM(tm),
65 : MachineFunctionPass(ID), O(o), TM(tm),
6666 OutContext(*new MCContext(*TM.getMCAsmInfo())),
6767 TLOF(TM.getTargetLowering()->getObjFileLowering()),
6868 is64Bit(TM.getTargetData()->getPointerSizeInBits() == 64),
2929 raw_ostream &OS;
3030
3131 public:
32 Printer() : FunctionPass(&ID), OS(errs()) {}
33 explicit Printer(raw_ostream &OS) : FunctionPass(&ID), OS(OS) {}
32 Printer() : FunctionPass(ID), OS(errs()) {}
33 explicit Printer(raw_ostream &OS) : FunctionPass(ID), OS(OS) {}
3434
3535
3636 const char *getPassName() const;
6969 char GCModuleInfo::ID = 0;
7070
7171 GCModuleInfo::GCModuleInfo()
72 : ImmutablePass(&ID) {}
72 : ImmutablePass(ID) {}
7373
7474 GCModuleInfo::~GCModuleInfo() {
7575 clear();
188188 return new Deleter();
189189 }
190190
191 Deleter::Deleter() : FunctionPass(&ID) {}
191 Deleter::Deleter() : FunctionPass(ID) {}
192192
193193 const char *Deleter::getPassName() const {
194194 return "Delete Garbage Collector Information";
129129 char LowerIntrinsics::ID = 0;
130130
131131 LowerIntrinsics::LowerIntrinsics()
132 : FunctionPass(&ID) {}
132 : FunctionPass(ID) {}
133133
134134 const char *LowerIntrinsics::getPassName() const {
135135 return "Lower Garbage Collection Instructions";
317317 char MachineCodeAnalysis::ID = 0;
318318
319319 MachineCodeAnalysis::MachineCodeAnalysis()
320 : MachineFunctionPass(&ID) {}
320 : MachineFunctionPass(ID) {}
321321
322322 const char *MachineCodeAnalysis::getPassName() const {
323323 return "Analyze Machine Code For Garbage Collection";
153153 int FnNum;
154154 public:
155155 static char ID;
156 IfConverter() : MachineFunctionPass(&ID), FnNum(-1) {}
156 IfConverter() : MachineFunctionPass(ID), FnNum(-1) {}
157157
158158 virtual bool runOnMachineFunction(MachineFunction &MF);
159159 virtual const char *getPassName() const { return "If Converter"; }
3535
3636 public:
3737 static char ID; // Pass identification, replacement for typeid
38 LowerSubregsInstructionPass() : MachineFunctionPass(&ID) {}
38 LowerSubregsInstructionPass() : MachineFunctionPass(ID) {}
3939
4040 const char *getPassName() const {
4141 return "Subregister lowering instruction pass";
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) {}
4444
4545 virtual bool runOnMachineFunction(MachineFunction &MF);
4646
2626 static RegisterPass
2727 E("machinedomtree", "MachineDominator Tree Construction", true);
2828
29 const PassInfo *const llvm::MachineDominatorsID = &E;
29 char &llvm::MachineDominatorsID = MachineDominatorTree::ID;
3030
3131 void MachineDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const {
3232 AU.setPreservesAll();
4040 }
4141
4242 MachineDominatorTree::MachineDominatorTree()
43 : MachineFunctionPass(&ID) {
43 : MachineFunctionPass(ID) {
4444 DT = new DominatorTreeBase(false);
4545 }
4646
1919 // a default constructor.
2020 static PassInfo
2121 X("Machine Function Analysis", "machine-function-analysis",
22 intptr_t(&MachineFunctionAnalysis::ID), 0,
22 &MachineFunctionAnalysis::ID, 0,
2323 /*CFGOnly=*/false, /*is_analysis=*/true);
2424
2525 char MachineFunctionAnalysis::ID = 0;
2626
2727 MachineFunctionAnalysis::MachineFunctionAnalysis(const TargetMachine &tm,
2828 CodeGenOpt::Level OL) :
29 FunctionPass(&ID), TM(tm), OptLevel(OL), MF(0) {
29 FunctionPass(ID), TM(tm), OptLevel(OL), MF(0) {
3030 }
3131
3232 MachineFunctionAnalysis::~MachineFunctionAnalysis() {
2828 const std::string Banner;
2929
3030 MachineFunctionPrinterPass(raw_ostream &os, const std::string &banner)
31 : MachineFunctionPass(&ID), OS(os), Banner(banner) {}
31 : MachineFunctionPass(ID), OS(os), Banner(banner) {}
3232
3333 const char *getPassName() const { return "MachineFunction Printer"; }
3434
7373 public:
7474 static char ID; // Pass identification, replacement for typeid
7575 MachineLICM() :
76 MachineFunctionPass(&ID), PreRegAlloc(true) {}
76 MachineFunctionPass(ID), PreRegAlloc(true) {}
7777
7878 explicit MachineLICM(bool PreRA) :
79 MachineFunctionPass(&ID), PreRegAlloc(PreRA) {}
79 MachineFunctionPass(ID), PreRegAlloc(PreRA) {}
8080
8181 virtual bool runOnMachineFunction(MachineFunction &MF);
8282
3232 static RegisterPass
3333 X("machine-loops", "Machine Natural Loop Construction", true);
3434
35 const PassInfo *const llvm::MachineLoopInfoID = &X;
35 char &llvm::MachineLoopInfoID = MachineLoopInfo::ID;
3636
3737 bool MachineLoopInfo::runOnMachineFunction(MachineFunction &) {
3838 releaseMemory();
253253 //===----------------------------------------------------------------------===//
254254
255255 MachineModuleInfo::MachineModuleInfo(const MCAsmInfo &MAI)
256 : ImmutablePass(&ID), Context(MAI),
256 : ImmutablePass(ID), Context(MAI),
257257 ObjFileMMI(0),
258258 CurCallSite(0), CallsEHReturn(0), CallsUnwindInit(0), DbgInfoAvailable(false){
259259 // Always emit some info, by default "no personality" info.
263263 }
264264
265265 MachineModuleInfo::MachineModuleInfo()
266 : ImmutablePass(&ID), Context(*(MCAsmInfo*)0) {
266 : ImmutablePass(ID), Context(*(MCAsmInfo*)0) {
267267 assert(0 && "This MachineModuleInfo constructor should never be called, MMI "
268268 "should always be explicitly constructed by LLVMTargetMachine");
269269 abort();
4343
4444 public:
4545 static char ID; // Pass identification
46 MachineSinking() : MachineFunctionPass(&ID) {}
46 MachineSinking() : MachineFunctionPass(ID) {}
4747
4848 virtual bool runOnMachineFunction(MachineFunction &MF);
4949
193193 static char ID; // Pass ID, replacement for typeid
194194
195195 MachineVerifierPass()
196 : MachineFunctionPass(&ID) {}
196 : MachineFunctionPass(ID) {}
197197
198198 void getAnalysisUsage(AnalysisUsage &AU) const {
199199 AU.setPreservesAll();
4242
4343 public:
4444 static char ID; // Pass identification
45 OptimizeExts() : MachineFunctionPass(&ID) {}
45 OptimizeExts() : MachineFunctionPass(ID) {}
4646
4747 virtual bool runOnMachineFunction(MachineFunction &MF);
4848
3232
3333 public:
3434 static char ID; // Pass identification
35 OptimizePHIs() : MachineFunctionPass(&ID) {}
35 OptimizePHIs() : MachineFunctionPass(ID) {}
3636
3737 virtual bool runOnMachineFunction(MachineFunction &MF);
3838
3939 static RegisterPass
4040 X("phi-node-elimination", "Eliminate PHI nodes for register allocation");
4141
42 const PassInfo *const llvm::PHIEliminationID = &X;
42 char &llvm::PHIEliminationID = PHIElimination::ID;
4343
4444 void llvm::PHIElimination::getAnalysisUsage(AnalysisUsage &AU) const {
4545 AU.addPreserved();
2424
2525 public:
2626 static char ID; // Pass identification, replacement for typeid
27 PHIElimination() : MachineFunctionPass(&ID) {}
27 PHIElimination() : MachineFunctionPass(ID) {}
2828
2929 virtual bool runOnMachineFunction(MachineFunction &Fn);
3030
8484 public:
8585 static char ID;
8686 PostRAScheduler(CodeGenOpt::Level ol) :
87 MachineFunctionPass(&ID), OptLevel(ol) {}
87 MachineFunctionPass(ID), OptLevel(ol) {}
8888
8989 void getAnalysisUsage(AnalysisUsage &AU) const {
9090 AU.setPreservesCFG();
9191 public:
9292 static char ID;
9393 PreAllocSplitting()
94 : MachineFunctionPass(&ID) {}
94 : MachineFunctionPass(ID) {}
9595
9696 virtual bool runOnMachineFunction(MachineFunction &MF);
9797
205205 static RegisterPass
206206 X("pre-alloc-splitting", "Pre-Register Allocation Live Interval Splitting");
207207
208 const PassInfo *const llvm::PreAllocSplittingID = &X;
208 char &llvm::PreAllocSplittingID = PreAllocSplitting::ID;
209209
210210 /// findSpillPoint - Find a gap as far away from the given MI that's suitable
211211 /// for spilling the current live interval. The index must be before any
3535 class PEI : public MachineFunctionPass {
3636 public:
3737 static char ID;
38 PEI() : MachineFunctionPass(&ID) {}
38 PEI() : MachineFunctionPass(ID) {}
3939
4040 const char *getPassName() const {
4141 return "Prolog/Epilog Insertion & Frame Finalization";
4646 class RAFast : public MachineFunctionPass {
4747 public:
4848 static char ID;
49 RAFast() : MachineFunctionPass(&ID), StackSlotForVirtReg(-1),
49 RAFast() : MachineFunctionPass(ID), StackSlotForVirtReg(-1),
5050 isBulkSpilling(false) {}
5151 private:
5252 const TargetMachine *TM;
8989
9090 struct RALinScan : public MachineFunctionPass {
9191 static char ID;
92 RALinScan() : MachineFunctionPass(&ID) {
92 RALinScan() : MachineFunctionPass(ID) {
9393 // Initialize the queue to record recently-used registers.
9494 if (NumRecentlyUsedRegs > 0)
9595 RecentRegs.resize(NumRecentlyUsedRegs, 0);
8383 static char ID;
8484
8585 /// Construct a PBQP register allocator.
86 PBQPRegAlloc() : MachineFunctionPass(&ID) {}
86 PBQPRegAlloc() : MachineFunctionPass(ID) {}
8787
8888 /// Return the pass name.
8989 virtual const char* getPassName() const {
197197 public:
198198 static char ID;
199199
200 RenderMachineFunction() : MachineFunctionPass(&ID) {}
200 RenderMachineFunction() : MachineFunctionPass(ID) {}
201201
202202 virtual void getAnalysisUsage(AnalysisUsage &au) const;
203203
170170 //===----------------------------------------------------------------------===//
171171
172172 SelectionDAGISel::SelectionDAGISel(const TargetMachine &tm, CodeGenOpt::Level OL) :
173 MachineFunctionPass(&ID), TM(tm), TLI(*tm.getTargetLowering()),
173 MachineFunctionPass(ID), TM(tm), TLI(*tm.getTargetLowering()),
174174 FuncInfo(new FunctionLoweringInfo(TLI)),
175175 CurDAG(new SelectionDAG(tm)),
176176 SDB(new SelectionDAGBuilder(*CurDAG, *FuncInfo, OL)),
6464 // Declare that we implement the RegisterCoalescer interface
6565 static RegisterAnalysisGroup V(X);
6666
67 const PassInfo *const llvm::SimpleRegisterCoalescingID = &X;
67 char &llvm::SimpleRegisterCoalescingID = SimpleRegisterCoalescing::ID;
6868
6969 void SimpleRegisterCoalescing::getAnalysisUsage(AnalysisUsage &AU) const {
7070 AU.setPreservesCFG();
6363
6464 public:
6565 static char ID; // Pass identifcation, replacement for typeid
66 SimpleRegisterCoalescing() : MachineFunctionPass(&ID) {}
66 SimpleRegisterCoalescing() : MachineFunctionPass(ID) {}
6767
6868 struct InstrSlots {
6969 enum {
5757 public:
5858 static char ID; // Pass identification, replacement for typeid
5959 explicit SjLjEHPass(const TargetLowering *tli = NULL)
60 : FunctionPass(&ID), TLI(tli) { }
60 : FunctionPass(ID), TLI(tli) { }
6161 bool doInitialization(Module &M);
6262 bool runOnFunction(Function &F);
6363
3535 public:
3636 static char ID;
3737
38 LoopSplitter() : MachineFunctionPass(&ID) {}
38 LoopSplitter() : MachineFunctionPass(ID) {}
3939
4040 virtual void getAnalysisUsage(AnalysisUsage &au) const;
4141
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) {}
6565 StackProtector(const TargetLowering *tli)
66 : FunctionPass(&ID), TLI(tli) {}
66 : FunctionPass(ID), TLI(tli) {}
6767
6868 virtual bool runOnFunction(Function &Fn);
6969 };
9494 public:
9595 static char ID; // Pass identification
9696 StackSlotColoring() :
97 MachineFunctionPass(&ID), ColorWithRegs(false), NextColor(-1) {}
97 MachineFunctionPass(ID), ColorWithRegs(false), NextColor(-1) {}
9898 StackSlotColoring(bool RegColor) :
99 MachineFunctionPass(&ID), ColorWithRegs(RegColor), NextColor(-1) {}
99 MachineFunctionPass(ID), ColorWithRegs(RegColor), NextColor(-1) {}
100100
101101 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
102102 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) {}
4242
4343 // Waiting stores, for each MBB, the set of copies that need to
4444 // be inserted into that MBB
153153 X("strong-phi-node-elimination",
154154 "Eliminate PHI nodes for register allocation, intelligently");
155155
156 const PassInfo *const llvm::StrongPHIEliminationID = &X;
156 char &llvm::StrongPHIEliminationID = StrongPHIElimination::ID;
157157
158158 /// computeDFS - Computes the DFS-in and DFS-out numbers of the dominator tree
159159 /// of the given MachineFunction. These numbers are then used in other parts
6868 public:
6969 static char ID;
7070 explicit TailDuplicatePass(bool PreRA) :
71 MachineFunctionPass(&ID), PreRegAlloc(PreRA) {}
71 MachineFunctionPass(ID), PreRegAlloc(PreRA) {}
7272
7373 virtual bool runOnMachineFunction(MachineFunction &MF);
7474 virtual const char *getPassName() const { return "Tail Duplication"; }
137137
138138 public:
139139 static char ID; // Pass identification, replacement for typeid
140 TwoAddressInstructionPass() : MachineFunctionPass(&ID) {}
140 TwoAddressInstructionPass() : MachineFunctionPass(ID) {}
141141
142142 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
143143 AU.setPreservesCFG();
161161 static RegisterPass
162162 X("twoaddressinstruction", "Two-Address instruction pass");
163163
164 const PassInfo *const llvm::TwoAddressInstructionPassID = &X;
164 char &llvm::TwoAddressInstructionPassID = TwoAddressInstructionPass::ID;
165165
166166 /// Sink3AddrInstruction - A two-address instruction has been converted to a
167167 /// three-address instruction to avoid clobbering a register. Try to sink it
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) {}
4646
4747 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
4848 AU.addPreserved();
9999 MachineModuleInfo *MMI;
100100 public:
101101 static char ID; // Pass identification, replacement for typeid
102 UnreachableMachineBlockElim() : MachineFunctionPass(&ID) {}
102 UnreachableMachineBlockElim() : MachineFunctionPass(ID) {}
103103 };
104104 }
105105 char UnreachableMachineBlockElim::ID = 0;
108108 Y("unreachable-mbb-elimination",
109109 "Remove unreachable machine basic blocks");
110110
111 const PassInfo *const llvm::UnreachableMachineBlockElimID = &Y;
111 char &llvm::UnreachableMachineBlockElimID = UnreachableMachineBlockElim::ID;
112112
113113 void UnreachableMachineBlockElim::getAnalysisUsage(AnalysisUsage &AU) const {
114114 AU.addPreserved();
138138
139139 public:
140140 static char ID;
141 VirtRegMap() : MachineFunctionPass(&ID), Virt2PhysMap(NO_PHYS_REG),
141 VirtRegMap() : MachineFunctionPass(ID), Virt2PhysMap(NO_PHYS_REG),
142142 Virt2StackSlotMap(NO_STACK_SLOT),
143143 Virt2ReMatIdMap(NO_STACK_SLOT), Virt2SplitMap(0),
144144 Virt2SplitKillMap(SlotIndex()), ReMatMap(NULL),
6464 static char ID;
6565 public:
6666 ARMCodeEmitter(TargetMachine &tm, JITCodeEmitter &mce)
67 : MachineFunctionPass(&ID), JTI(0),
67 : MachineFunctionPass(ID), JTI(0),
6868 II((const ARMInstrInfo *)tm.getInstrInfo()),
6969 TD(tm.getTargetData()), TM(tm),
7070 MCE(mce), MCPEs(0), MJTEs(0),
172172 bool isThumb2;
173173 public:
174174 static char ID;
175 ARMConstantIslands() : MachineFunctionPass(&ID) {}
175 ARMConstantIslands() : MachineFunctionPass(ID) {}
176176
177177 virtual bool runOnMachineFunction(MachineFunction &MF);
178178
2525 class ARMExpandPseudo : public MachineFunctionPass {
2626 public:
2727 static char ID;
28 ARMExpandPseudo() : MachineFunctionPass(&ID) {}
28 ARMExpandPseudo() : MachineFunctionPass(ID) {}
2929
3030 const TargetInstrInfo *TII;
3131 const TargetRegisterInfo *TRI;
7777 public:
7878 static char ID; // Pass identification, replacement for typeid.
7979 explicit ARMGlobalMerge(const TargetLowering *tli)
80 : FunctionPass(&ID), TLI(tli) {}
80 : FunctionPass(ID), TLI(tli) {}
8181
8282 virtual bool doInitialization(Module &M);
8383 virtual bool runOnFunction(Function& F);
5656 namespace {
5757 struct ARMLoadStoreOpt : public MachineFunctionPass {
5858 static char ID;
59 ARMLoadStoreOpt() : MachineFunctionPass(&ID) {}
59 ARMLoadStoreOpt() : MachineFunctionPass(ID) {}
6060
6161 const TargetInstrInfo *TII;
6262 const TargetRegisterInfo *TRI;
12671267 namespace {
12681268 struct ARMPreAllocLoadStoreOpt : public MachineFunctionPass{
12691269 static char ID;
1270 ARMPreAllocLoadStoreOpt() : MachineFunctionPass(&ID) {}
1270 ARMPreAllocLoadStoreOpt() : MachineFunctionPass(ID) {}
12711271
12721272 const TargetData *TD;
12731273 const TargetInstrInfo *TII;
2323 namespace {
2424 struct NEONMoveFixPass : public MachineFunctionPass {
2525 static char ID;
26 NEONMoveFixPass() : MachineFunctionPass(&ID) {}
26 NEONMoveFixPass() : MachineFunctionPass(ID) {}
2727
2828 virtual bool runOnMachineFunction(MachineFunction &Fn);
2929
2222
2323 public:
2424 static char ID;
25 NEONPreAllocPass() : MachineFunctionPass(&ID) {}
25 NEONPreAllocPass() : MachineFunctionPass(ID) {}
2626
2727 virtual bool runOnMachineFunction(MachineFunction &MF);
2828
2626
2727 public:
2828 static char ID;
29 Thumb2ITBlockPass() : MachineFunctionPass(&ID) {}
29 Thumb2ITBlockPass() : MachineFunctionPass(ID) {}
3030
3131 const Thumb2InstrInfo *TII;
3232 const TargetRegisterInfo *TRI;
172172 char Thumb2SizeReduce::ID = 0;
173173 }
174174
175 Thumb2SizeReduce::Thumb2SizeReduce() : MachineFunctionPass(&ID) {
175 Thumb2SizeReduce::Thumb2SizeReduce() : MachineFunctionPass(ID) {
176176 for (unsigned i = 0, e = array_lengthof(ReduceTable); i != e; ++i) {
177177 unsigned FromOpc = ReduceTable[i].WideOpc;
178178 if (!ReduceOpcodeMap.insert(std::make_pair(FromOpc, i)).second)
2121 namespace {
2222 struct AlphaBSel : public MachineFunctionPass {
2323 static char ID;
24 AlphaBSel() : MachineFunctionPass(&ID) {}
24 AlphaBSel() : MachineFunctionPass(ID) {}
2525
2626 virtual bool runOnMachineFunction(MachineFunction &Fn);
2727
3333 public:
3434 static char ID;
3535
36 AlphaCodeEmitter(JITCodeEmitter &mce) : MachineFunctionPass(&ID),
36 AlphaCodeEmitter(JITCodeEmitter &mce) : MachineFunctionPass(ID),
3737 MCE(mce) {}
3838
3939 /// getBinaryCodeForInstr - This function, generated by the
3838
3939 static char ID;
4040 AlphaLLRPPass(AlphaTargetMachine &tm)
41 : MachineFunctionPass(&ID), TM(tm) { }
41 : MachineFunctionPass(ID), TM(tm) { }
4242
4343 virtual const char *getPassName() const {
4444 return "Alpha NOP inserter";
7272 public:
7373 static char ID;
7474 CBackendNameAllUsedStructsAndMergeFunctions()
75 : ModulePass(&ID) {}
75 : ModulePass(ID) {}
7676 void getAnalysisUsage(AnalysisUsage &AU) const {
7777 AU.addRequired();
7878 }
109109 public:
110110 static char ID;
111111 explicit CWriter(formatted_raw_ostream &o)
112 : FunctionPass(&ID), Out(o), IL(0), Mang(0), LI(0),
112 : FunctionPass(ID), Out(o), IL(0), Mang(0), LI(0),
113113 TheModule(0), TAsm(0), TCtx(0), TD(0), OpaqueCounter(0),
114114 NextAnonValueNumber(0) {
115115 FPCounter = 0;
103103 public:
104104 static char ID;
105105 explicit CppWriter(formatted_raw_ostream &o) :
106 ModulePass(&ID), Out(o), uniqueNum(0), is_inline(false), indent_level(0){}
106 ModulePass(ID), Out(o), uniqueNum(0), is_inline(false), indent_level(0){}
107107
108108 virtual const char *getPassName() const { return "C++ backend"; }
109109
3131
3232 static char ID;
3333 Filler(TargetMachine &tm)
34 : MachineFunctionPass(&ID), TM(tm), TII(tm.getInstrInfo()) { }
34 : MachineFunctionPass(ID), TM(tm), TII(tm.getInstrInfo()) { }
3535
3636 virtual const char *getPassName() const {
3737 return "MBlaze Delay Slot Filler";
3939 static char ID;
4040 MSILModule(const std::set*& _UsedTypes,
4141 const TargetData*& _TD)
42 : ModulePass(&ID), UsedTypes(_UsedTypes), TD(_TD) {}
42 : ModulePass(ID), UsedTypes(_UsedTypes), TD(_TD) {}
4343
4444 void getAnalysisUsage(AnalysisUsage &AU) const {
4545 AU.addRequired();
8585 DenseMap AnonValueNumbers;
8686 unsigned NextAnonValueNumber;
8787
88 MSILWriter(formatted_raw_ostream &o) : FunctionPass(&ID), Out(o),
88 MSILWriter(formatted_raw_ostream &o) : FunctionPass(ID), Out(o),
8989 NextAnonValueNumber(0) {
9090 UniqID = 0;
9191 }
2929 namespace {
3030 struct MSP430BSel : public MachineFunctionPass {
3131 static char ID;
32 MSP430BSel() : MachineFunctionPass(&ID) {}
32 MSP430BSel() : MachineFunctionPass(ID) {}
3333
3434 /// BlockSizes - The sizes of the basic blocks in the function.
3535 std::vector BlockSizes;
3131
3232 static char ID;
3333 Filler(TargetMachine &tm)
34 : MachineFunctionPass(&ID), TM(tm), TII(tm.getInstrInfo()) { }
34 : MachineFunctionPass(ID), TM(tm), TII(tm.getInstrInfo()) { }
3535
3636 virtual const char *getPassName() const {
3737 return "Mips Delay Slot Filler";
3737 namespace {
3838 struct MemSelOpt : public MachineFunctionPass {
3939 static char ID;
40 MemSelOpt() : MachineFunctionPass(&ID) {}
40 MemSelOpt() : MachineFunctionPass(ID) {}
4141
4242 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
4343 AU.addPreservedID(MachineLoopInfoID);
3434 class PIC16Cloner : public ModulePass {
3535 public:
3636 static char ID; // Class identification
37 PIC16Cloner() : ModulePass(&ID) {}
37 PIC16Cloner() : ModulePass(ID) {}
3838
3939 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
4040 AU.addRequired();
3838 unsigned IndirectCallColor;
3939 public:
4040 static char ID; // Class identification
41 PIC16Overlay() : ModulePass(&ID) {
41 PIC16Overlay() : ModulePass(ID) {
4242 OverlayStr = "Overlay=";
4343 InterruptDepth = PIC16OVERLAY::StartInterruptColor;
4444 IndirectCallColor = PIC16OVERLAY::StartIndirectCallColor;
3030 namespace {
3131 struct PPCBSel : public MachineFunctionPass {
3232 static char ID;
33 PPCBSel() : MachineFunctionPass(&ID) {}
33 PPCBSel() : MachineFunctionPass(ID) {}
3434
3535 /// BlockSizes - The sizes of the basic blocks in the function.
3636 std::vector BlockSizes;
4444 public:
4545
4646 PPCCodeEmitter(TargetMachine &tm, JITCodeEmitter &mce)
47 : MachineFunctionPass(&ID), TM(tm), MCE(mce) {}
47 : MachineFunctionPass(ID), TM(tm), MCE(mce) {}
4848
4949 /// getBinaryCodeForInstr - This function, generated by the
5050 /// CodeEmitterGenerator using TableGen, produces the binary encoding for
3131
3232 static char ID;
3333 Filler(TargetMachine &tm)
34 : MachineFunctionPass(&ID), TM(tm), TII(tm.getInstrInfo()) { }
34 : MachineFunctionPass(ID), TM(tm), TII(tm.getInstrInfo()) { }
3535
3636 virtual const char *getPassName() const {
3737 return "SPARC Delay Slot Filler";
3535
3636 static char ID;
3737 explicit FPMover(TargetMachine &tm)
38 : MachineFunctionPass(&ID), TM(tm) { }
38 : MachineFunctionPass(ID), TM(tm) { }
3939
4040 virtual const char *getPassName() const {
4141 return "Sparc Double-FP Move Fixer";
225225 ///
226226 /// @note This has to exist, because this is a pass, but it should never be
227227 /// used.
228 TargetData::TargetData() : ImmutablePass(&ID) {
228 TargetData::TargetData() : ImmutablePass(ID) {
229229 report_fatal_error("Bad TargetData ctor used. "
230230 "Tool did not specify a TargetData to use?");
231231 }
232232
233233 TargetData::TargetData(const Module *M)
234 : ImmutablePass(&ID) {
234 : ImmutablePass(ID) {
235235 init(M->getDataLayout());
236236 }
237237
114114 unsigned Distance;
115115
116116 public:
117 SSEDomainFixPass() : MachineFunctionPass(&ID) {}
117 SSEDomainFixPass() : MachineFunctionPass(ID) {}
118118
119119 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
120120 AU.setPreservesAll();
5252 public:
5353 static char ID;
5454 explicit Emitter(X86TargetMachine &tm, CodeEmitter &mce)
55 : MachineFunctionPass(&ID), II(0), TD(0), TM(tm),
55 : MachineFunctionPass(ID), II(0), TD(0), TM(tm),
5656 MCE(mce), PICBaseOffset(0), Is64BitMode(false),
5757 IsPIC(TM.getRelocationModel() == Reloc::PIC_) {}
5858 Emitter(X86TargetMachine &tm, CodeEmitter &mce,
5959 const X86InstrInfo &ii, const TargetData &td, bool is64)
60 : MachineFunctionPass(&ID), II(&ii), TD(&td), TM(tm),
60 : MachineFunctionPass(ID), II(&ii), TD(&td), TM(tm),
6161 MCE(mce), PICBaseOffset(0), Is64BitMode(is64),
6262 IsPIC(TM.getRelocationModel() == Reloc::PIC_) {}
6363
4949 namespace {
5050 struct FPS : public MachineFunctionPass {
5151 static char ID;
52 FPS() : MachineFunctionPass(&ID) {
52 FPS() : MachineFunctionPass(ID) {
5353 // This is really only to keep valgrind quiet.
5454 // The logic in isLive() is too much for it.
5555 memset(Stack, 0, sizeof(Stack));
30283028 /// global base register for x86-32.
30293029 struct CGBR : public MachineFunctionPass {
30303030 static char ID;
3031 CGBR() : MachineFunctionPass(&ID) {}
3031 CGBR() : MachineFunctionPass(ID) {}
30323032
30333033 virtual bool runOnMachineFunction(MachineFunction &MF) {
30343034 const X86TargetMachine *TM =
15231523 namespace {
15241524 struct MSAH : public MachineFunctionPass {
15251525 static char ID;
1526 MSAH() : MachineFunctionPass(&ID) {}
1526 MSAH() : MachineFunctionPass(ID) {}
15271527
15281528 virtual bool runOnMachineFunction(MachineFunction &MF) {
15291529 const X86TargetMachine *TM =
2424 // Hello - The first implementation, without getAnalysisUsage.
2525 struct Hello : public FunctionPass {
2626 static char ID; // Pass identification, replacement for typeid
27 Hello() : FunctionPass(&ID) {}
27 Hello() : FunctionPass(ID) {}
2828
2929 virtual bool runOnFunction(Function &F) {
3030 ++HelloCounter;
4242 // Hello2 - The second implementation with getAnalysisUsage implemented.
4343 struct Hello2 : public FunctionPass {
4444 static char ID; // Pass identification, replacement for typeid
45 Hello2() : FunctionPass(&ID) {}
45 Hello2() : FunctionPass(ID) {}
4646
4747 virtual bool runOnFunction(Function &F) {
4848 ++HelloCounter;
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) {}
7070
7171 /// A vector used to hold the indices of a single GEP instruction
7272 typedef std::vector IndicesVector;
3030 namespace {
3131 struct ConstantMerge : public ModulePass {
3232 static char ID; // Pass identification, replacement for typeid
33 ConstantMerge() : ModulePass(&ID) {}
33 ConstantMerge() : ModulePass(ID) {}
3434
3535 // run - For this pass, process all of the globals in the module,
3636 // eliminating duplicate constants.
121121
122122 protected:
123123 // DAH uses this to specify a different ID.
124 explicit DAE(void *ID) : ModulePass(ID) {}
124 explicit DAE(char &ID) : ModulePass(ID) {}
125125
126126 public:
127127 static char ID; // Pass identification, replacement for typeid
128 DAE() : ModulePass(&ID) {}
128 DAE() : ModulePass(ID) {}
129129
130130 bool runOnModule(Module &M);
131131
158158 /// by bugpoint.
159159 struct DAH : public DAE {
160160 static char ID;
161 DAH() : DAE(&ID) {}
161 DAH() : DAE(ID) {}
162162
163163 virtual bool ShouldHackArguments() const { return true; }
164164 };
2525 namespace {
2626 struct DTE : public ModulePass {
2727 static char ID; // Pass identification, replacement for typeid
28 DTE() : ModulePass(&ID) {}
28 DTE() : ModulePass(ID) {}
2929
3030 // doPassInitialization - For this pass, it removes global symbol table
3131 // entries for primitive types. These are never used for linking in GCC and
3434 ///
3535 explicit GVExtractorPass(std::vector& GVs, bool deleteS = true,
3636 bool relinkCallees = false)
37 : ModulePass(&ID), Named(GVs), deleteStuff(deleteS),
37 : ModulePass(ID), Named(GVs), deleteStuff(deleteS),
3838 reLink(relinkCallees) {}
3939
4040 bool runOnModule(Module &M) {
4040 namespace {
4141 struct FunctionAttrs : public CallGraphSCCPass {
4242 static char ID; // Pass identification, replacement for typeid
43 FunctionAttrs() : CallGraphSCCPass(&ID) {}
43 FunctionAttrs() : CallGraphSCCPass(ID) {}
4444
4545 // runOnSCC - Analyze the SCC, performing the transformation if possible.
4646 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) {}
3434
3535 // run - Do the GlobalDCE pass on the specified module, optionally updating
3636 // 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) {}
6262
6363 bool runOnModule(Module &M);
6464
3434 ///
3535 struct IPCP : public ModulePass {
3636 static char ID; // Pass identification, replacement for typeid
37 IPCP() : ModulePass(&ID) {}
37 IPCP() : ModulePass(ID) {}
3838
3939 bool runOnModule(Module &M);
4040 private:
3535 InlineCostAnalyzer CA;
3636 public:
3737 // Use extremely low threshold.
38 AlwaysInliner() : Inliner(&ID, -2000000000) {}
38 AlwaysInliner() : Inliner(ID, -2000000000) {}
3939 static char ID; // Pass identification, replacement for typeid
4040 InlineCost getInlineCost(CallSite CS) {
4141 return CA.getInlineCost(CS, NeverInline);
3232 SmallPtrSet NeverInline;
3333 InlineCostAnalyzer CA;
3434 public:
35 SimpleInliner() : Inliner(&ID) {}
36 SimpleInliner(int Threshold) : Inliner(&ID, Threshold) {}
35 SimpleInliner() : Inliner(ID) {}
36 SimpleInliner(int Threshold) : Inliner(ID, Threshold) {}
3737 static char ID; // Pass identification, replacement for typeid
3838 InlineCost getInlineCost(CallSite CS) {
3939 return CA.getInlineCost(CS, NeverInline);
4747 // Threshold to use when optsize is specified (and there is no -inline-limit).
4848 const int OptSizeThreshold = 75;
4949
50 Inliner::Inliner(void *ID)
50 Inliner::Inliner(char &ID)
5151 : CallGraphSCCPass(ID), InlineThreshold(InlineLimit) {}
5252
53 Inliner::Inliner(void *ID, int Threshold)
53 Inliner::Inliner(char &ID, int Threshold)
5454 : CallGraphSCCPass(ID), InlineThreshold(Threshold) {}
5555
5656 /// getAnalysisUsage - For this class, we declare that we require and preserve
6666 "Internalize Global Symbols", false, false);
6767
6868 InternalizePass::InternalizePass(bool AllButMain)
69 : ModulePass(&ID), AllButMain(AllButMain){
69 : ModulePass(ID), AllButMain(AllButMain){
7070 if (!APIFile.empty()) // If a filename is specified, use it.
7171 LoadFile(APIFile.c_str());
7272 if (!APIList.empty()) // If a list is specified, use it as well.
7474 }
7575
7676 InternalizePass::InternalizePass(const std::vector&exportList)
77 : ModulePass(&ID), AllButMain(false){
77 : ModulePass(ID), AllButMain(false){
7878 for(std::vector::const_iterator itr = exportList.begin();
7979 itr != exportList.end(); itr++) {
8080 ExternalNames.insert(*itr);
3636 unsigned NumLoops;
3737
3838 explicit LoopExtractor(unsigned numLoops = ~0)
39 : LoopPass(&ID), NumLoops(numLoops) {}
39 : LoopPass(ID), NumLoops(numLoops) {}
4040
4141 virtual bool runOnLoop(Loop *L, LPPassManager &LPM);
4242
146146 std::vector > BlocksToNotExtractByName;
147147 public:
148148 static char ID; // Pass identification, replacement for typeid
149 BlockExtractorPass() : ModulePass(&ID) {
149 BlockExtractorPass() : ModulePass(ID) {
150150 if (!BlockFile.empty())
151151 LoadFile(BlockFile.c_str());
152152 }
108108 bool IsTransformableFunction(StringRef Name);
109109 public:
110110 static char ID; // Pass identification, replacement for typeid
111 LowerSetJmp() : ModulePass(&ID) {}
111 LowerSetJmp() : ModulePass(ID) {}
112112
113113 void visitCallInst(CallInst& CI);
114114 void visitInvokeInst(InvokeInst& II);
8787 ///
8888 struct MergeFunctions : public ModulePass {
8989 static char ID; // Pass identification, replacement for typeid
90 MergeFunctions() : ModulePass(&ID) {}
90 MergeFunctions() : ModulePass(ID) {}
9191
9292 bool runOnModule(Module &M);
9393 };
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) {}
3333
3434 bool runOnModule(Module& M);
3535
4949 int scanDistribution(Function&, int, std::map&);
5050 public :
5151 static char ID; // Pass identification, replacement for typeid
52 PartSpec() : ModulePass(&ID) {}
52 PartSpec() : ModulePass(ID) {}
5353 bool runOnModule(Module &M);
5454 };
5555 }
3636 namespace {
3737 struct PruneEH : public CallGraphSCCPass {
3838 static char ID; // Pass identification, replacement for typeid
39 PruneEH() : CallGraphSCCPass(&ID) {}
39 PruneEH() : CallGraphSCCPass(ID) {}
4040
4141 // runOnSCC - Analyze the SCC, performing the transformation if possible.
4242 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) { }
3232 virtual bool runOnModule(Module &M);
3333 };
3434
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) {}
4242
4343 virtual bool runOnModule(Module &M);
4444
5151 public:
5252 static char ID; // Pass identification, replacement for typeid
5353 explicit StripNonDebugSymbols()
54 : ModulePass(&ID) {}
54 : ModulePass(ID) {}
5555
5656 virtual bool runOnModule(Module &M);
5757
6464 public:
6565 static char ID; // Pass identification, replacement for typeid
6666 explicit StripDebugDeclare()
67 : ModulePass(&ID) {}
67 : ModulePass(ID) {}
6868
6969 virtual bool runOnModule(Module &M);
7070
7777 public:
7878 static char ID; // Pass identification, replacement for typeid
7979 explicit StripDeadDebugInfo()
80 : ModulePass(&ID) {}
80 : ModulePass(ID) {}
8181
8282 virtual bool runOnModule(Module &M);
8383
4949
5050 virtual bool runOnSCC(CallGraphSCC &SCC);
5151 static char ID; // Pass identification, replacement for typeid
52 SRETPromotion() : CallGraphSCCPass(&ID) {}
52 SRETPromotion() : CallGraphSCCPass(ID) {}
5353
5454 private:
5555 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) {}
8484
8585 public:
8686 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) {}
3737
3838 virtual const char *getPassName() const {
3939 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) {}
3939
4040 void getAnalysisUsage(AnalysisUsage &AU) const {
4141 AU.addRequiredID(ProfileEstimatorPassID);
4848 class ABCD : public FunctionPass {
4949 public:
5050 static char ID; // Pass identification, replacement for typeid.
51 ABCD() : FunctionPass(&ID) {}
51 ABCD() : FunctionPass(ID) {}
5252
5353 void getAnalysisUsage(AnalysisUsage &AU) const {
5454 AU.addRequired();
3232 namespace {
3333 struct ADCE : public FunctionPass {
3434 static char ID; // Pass identification, replacement for typeid
35 ADCE() : FunctionPass(&ID) {}
35 ADCE() : FunctionPass(ID) {}
3636
3737 virtual bool runOnFunction(Function& F);
3838
4040 namespace {
4141 struct BlockPlacement : public FunctionPass {
4242 static char ID; // Pass identification, replacement for typeid
43 BlockPlacement() : FunctionPass(&ID) {}
43 BlockPlacement() : FunctionPass(ID) {}
4444
4545 virtual bool runOnFunction(Function &F);
4646
5353 public:
5454 static char ID; // Pass identification, replacement for typeid
5555 explicit CodeGenPrepare(const TargetLowering *tli = 0)
56 : FunctionPass(&ID), TLI(tli) {}
56 : FunctionPass(ID), TLI(tli) {}
5757 bool runOnFunction(Function &F);
5858
5959 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) {}
3737
3838 bool runOnFunction(Function &F);
3939
3434 //
3535 struct DeadInstElimination : public BasicBlockPass {
3636 static char ID; // Pass identification, replacement for typeid
37 DeadInstElimination() : BasicBlockPass(&ID) {}
37 DeadInstElimination() : BasicBlockPass(ID) {}
3838 virtual bool runOnBasicBlock(BasicBlock &BB) {
3939 bool Changed = false;
4040 for (BasicBlock::iterator DI = BB.begin(); DI != BB.end(); ) {
6969 //
7070 struct DCE : public FunctionPass {
7171 static char ID; // Pass identification, replacement for typeid
72 DCE() : FunctionPass(&ID) {}
72 DCE() : FunctionPass(ID) {}
7373
7474 virtual bool runOnFunction(Function &F);
7575
3939 TargetData *TD;
4040
4141 static char ID; // Pass identification, replacement for typeid
42 DSE() : FunctionPass(&ID) {}
42 DSE() : FunctionPass(ID) {}
4343
4444 virtual bool runOnFunction(Function &F) {
4545 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) {}
3030 };
3131 }
3232
664664 public:
665665 static char ID; // Pass identification, replacement for typeid
666666 explicit GVN(bool noloads = false)
667 : FunctionPass(&ID), NoLoads(noloads), MD(0) { }
667 : FunctionPass(ID), NoLoads(noloads), MD(0) { }
668668
669669 private:
670670 bool NoLoads;
7676 public:
7777
7878 static char ID; // Pass identification, replacement for typeid
79 IndVarSimplify() : LoopPass(&ID) {}
79 IndVarSimplify() : LoopPass(ID) {}
8080
8181 virtual bool runOnLoop(Loop *L, LPPassManager &LPM);
8282
7878 #endif
7979 public:
8080 static char ID; // Pass identification
81 JumpThreading() : FunctionPass(&ID) {}
81 JumpThreading() : FunctionPass(ID) {}
8282
8383 bool runOnFunction(Function &F);
8484
6565 namespace {
6666 struct LICM : public LoopPass {
6767 static char ID; // Pass identification, replacement for typeid
68 LICM() : LoopPass(&ID) {}
68 LICM() : LoopPass(ID) {}
6969
7070 virtual bool runOnLoop(Loop *L, LPPassManager &LPM);
7171
2727 class LoopDeletion : public LoopPass {
2828 public:
2929 static char ID; // Pass ID, replacement for typeid
30 LoopDeletion() : LoopPass(&ID) {}
30 LoopDeletion() : LoopPass(ID) {}
3131
3232 // Possibly eliminate loop L if it is dead.
3333 bool runOnLoop(Loop* L, LPPassManager& LPM);
7373 class LoopIndexSplit : public LoopPass {
7474 public:
7575 static char ID; // Pass ID, replacement for typeid
76 LoopIndexSplit() : LoopPass(&ID) {}
76 LoopIndexSplit() : LoopPass(ID) {}
7777
7878 // Index split Loop L. Return true if loop is split.
7979 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) {}
3838
3939 // Rotate Loop L as many times as possible. Return true if
4040 // loop is rotated at least once.
37503750 }
37513751
37523752 LoopStrengthReduce::LoopStrengthReduce(const TargetLowering *tli)
3753 : LoopPass(&ID), TLI(tli) {}
3753 : LoopPass(ID), TLI(tli) {}
37543754
37553755 void LoopStrengthReduce::getAnalysisUsage(AnalysisUsage &AU) const {
37563756 // 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) {}
4646
4747 /// A magic value for use with the Threshold parameter to indicate
4848 /// that the loop unroll should be performed regardless of how much
9191 public:
9292 static char ID; // Pass ID, replacement for typeid
9393 explicit LoopUnswitch(bool Os = false) :
94 LoopPass(&ID), OptimizeForSize(Os), redoLoop(false),
94 LoopPass(ID), OptimizeForSize(Os), redoLoop(false),
9595 currentLoop(NULL), DF(NULL), DT(NULL), loopHeader(NULL),
9696 loopPreheader(NULL) {}
9797
137137
138138 struct LowerAtomic : public BasicBlockPass {
139139 static char ID;
140 LowerAtomic() : BasicBlockPass(&ID) {}
140 LowerAtomic() : BasicBlockPass(ID) {}
141141 bool runOnBasicBlock(BasicBlock &BB) {
142142 bool Changed = false;
143143 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) {}
307307
308308 private:
309309 // 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) {}
8080
8181 bool runOnFunction(Function &F);
8282
3535 namespace {
3636 struct RegToMem : public FunctionPass {
3737 static char ID; // Pass identification, replacement for typeid
38 RegToMem() : FunctionPass(&ID) {}
38 RegToMem() : FunctionPass(ID) {}
3939
4040 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
4141 AU.addRequiredID(BreakCriticalEdgesID);
123123
124124 // createDemoteRegisterToMemory - Provide an entry point to create this pass.
125125 //
126 const PassInfo *const llvm::DemoteRegisterToMemoryID = &X;
126 char &llvm::DemoteRegisterToMemoryID = RegToMem::ID;
127127 FunctionPass *llvm::createDemoteRegisterToMemoryPass() {
128128 return new RegToMem();
129129 }
15851585 ///
15861586 struct SCCP : public FunctionPass {
15871587 static char ID; // Pass identification, replacement for typeid
1588 SCCP() : FunctionPass(&ID) {}
1588 SCCP() : FunctionPass(ID) {}
15891589
15901590 // runOnFunction - Run the Sparse Conditional Constant Propagation
15911591 // algorithm, and return true if the function was modified.
17011701 ///
17021702 struct IPSCCP : public ModulePass {
17031703 static char ID;
1704 IPSCCP() : ModulePass(&ID) {}
1704 IPSCCP() : ModulePass(ID) {}
17051705 bool runOnModule(Module &M);
17061706 };
17071707 } // end anonymous namespace
5050 namespace {
5151 struct SROA : public FunctionPass {
5252 static char ID; // Pass identification, replacement for typeid
53 explicit SROA(signed T = -1) : FunctionPass(&ID) {
53 explicit SROA(signed T = -1) : FunctionPass(ID) {
5454 if (T == -1)
5555 SRThreshold = 128;
5656 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) {}
4545
4646 virtual bool runOnFunction(Function &F);
4747 };
3131 const TargetData *TD;
3232 public:
3333 static char ID; // Pass identification
34 SimplifyHalfPowrLibCalls() : FunctionPass(&ID) {}
34 SimplifyHalfPowrLibCalls() : FunctionPass(ID) {}
3535
3636 bool runOnFunction(Function &F);
3737
12361236 bool Modified; // This is only used by doInitialization.
12371237 public:
12381238 static char ID; // Pass identification
1239 SimplifyLibCalls() : FunctionPass(&ID), StrCpy(false), StrCpyChk(true) {}
1239 SimplifyLibCalls() : FunctionPass(ID), StrCpy(false), StrCpyChk(true) {}
12401240 void InitOptimizations();
12411241 bool runOnFunction(Function &F);
12421242
3434
3535 public:
3636 static char ID; // Pass identification
37 Sinking() : FunctionPass(&ID) {}
37 Sinking() : FunctionPass(ID) {}
3838
3939 virtual bool runOnFunction(Function &F);
4040
4848 bool runOnFunction(Function &F);
4949 public:
5050 static char ID; // Pass identification, replacement for typeid
51 TailDup() : FunctionPass(&ID) {}
51 TailDup() : FunctionPass(ID) {}
5252
5353 private:
5454 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) {}
7575
7676 virtual bool runOnFunction(Function &F);
7777
3535 namespace {
3636 struct BreakCriticalEdges : public FunctionPass {
3737 static char ID; // Pass identification, replacement for typeid
38 BreakCriticalEdges() : FunctionPass(&ID) {}
38 BreakCriticalEdges() : FunctionPass(ID) {}
3939
4040 virtual bool runOnFunction(Function &F);
4141
5656 X("break-crit-edges", "Break critical edges in CFG");
5757
5858 // Publically exposed interface to pass...
59 const PassInfo *const llvm::BreakCriticalEdgesID = &X;
59 char &llvm::BreakCriticalEdgesID = BreakCriticalEdges::ID;
6060 FunctionPass *llvm::createBreakCriticalEdgesPass() {
6161 return new BreakCriticalEdges();
6262 }
2222 namespace {
2323 struct InstNamer : public FunctionPass {
2424 static char ID; // Pass identification, replacement for typeid
25 InstNamer() : FunctionPass(&ID) {}
25 InstNamer() : FunctionPass(ID) {}
2626
2727 void getAnalysisUsage(AnalysisUsage &Info) const {
2828 Info.setPreservesAll();
5252 }
5353
5454
55 const PassInfo *const llvm::InstructionNamerID = &X;
55 char &llvm::InstructionNamerID = InstNamer::ID;
5656 //===----------------------------------------------------------------------===//
5757 //
5858 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
4646 namespace {
4747 struct LCSSA : public LoopPass {
4848 static char ID; // Pass identification, replacement for typeid
49 LCSSA() : LoopPass(&ID) {}
49 LCSSA() : LoopPass(ID) {}
5050
5151 // Cached analysis information for the current function.
5252 DominatorTree *DT;
9292 static RegisterPass X("lcssa", "Loop-Closed SSA Form Pass");
9393
9494 Pass *llvm::createLCSSAPass() { return new LCSSA(); }
95 const PassInfo *const llvm::LCSSAID = &X;
95 char &llvm::LCSSAID = LCSSA::ID;
9696
9797
9898 /// BlockDominatesAnExit - Return true if the specified block dominates at least
6464 namespace {
6565 struct LoopSimplify : public LoopPass {
6666 static char ID; // Pass identification, replacement for typeid
67 LoopSimplify() : LoopPass(&ID) {}
67 LoopSimplify() : LoopPass(ID) {}
6868
6969 // AA - If we have an alias analysis object to update, this is it, otherwise
7070 // this is null.
109109 X("loopsimplify", "Canonicalize natural loops", true);
110110
111111 // Publically exposed interface to pass...
112 const PassInfo *const llvm::LoopSimplifyID = &X;
112 char &llvm::LoopSimplifyID = LoopSimplify::ID;
113113 Pass *llvm::createLoopSimplifyPass() { return new LoopSimplify(); }
114114
115115 /// runOnLoop - Run down all loops in the CFG (recursively, but we could do
7777 static char ID; // Pass identification, replacement for typeid
7878 explicit LowerInvoke(const TargetLowering *tli = NULL,
7979 bool useExpensiveEHSupport = ExpensiveEHSupport)
80 : FunctionPass(&ID), useExpensiveEHSupport(useExpensiveEHSupport),
80 : FunctionPass(ID), useExpensiveEHSupport(useExpensiveEHSupport),
8181 TLI(tli) { }
8282 bool doInitialization(Module &M);
8383 bool runOnFunction(Function &F);
102102 static RegisterPass
103103 X("lowerinvoke", "Lower invoke and unwind, for unwindless code generators");
104104
105 const PassInfo *const llvm::LowerInvokePassID = &X;
105 char &llvm::LowerInvokePassID = LowerInvoke::ID;
106106
107107 // Public Interface To the LowerInvoke pass.
108108 FunctionPass *llvm::createLowerInvokePass(const TargetLowering *TLI) {
3333 class LowerSwitch : public FunctionPass {
3434 public:
3535 static char ID; // Pass identification, replacement for typeid
36 LowerSwitch() : FunctionPass(&ID) {}
36 LowerSwitch() : FunctionPass(ID) {}
3737
3838 virtual bool runOnFunction(Function &F);
3939
8484 X("lowerswitch", "Lower SwitchInst's to branches");
8585
8686 // Publically exposed interface to pass...
87 const PassInfo *const llvm::LowerSwitchID = &X;
87 char &llvm::LowerSwitchID = LowerSwitch::ID;
8888 // createLowerSwitchPass - Interface to this file...
8989 FunctionPass *llvm::createLowerSwitchPass() {
9090 return new LowerSwitch();
2626 namespace {
2727 struct PromotePass : public FunctionPass {
2828 static char ID; // Pass identification, replacement for typeid
29 PromotePass() : FunctionPass(&ID) {}
29 PromotePass() : FunctionPass(ID) {}
3030
3131 // runOnFunction - To run this pass, first we calculate the alloca
3232 // instructions that are safe for promotion, then we promote each one.
81