LLVM API Documentation
00001 //===- CallGraphSCCPass.h - Pass that operates BU on call graph -*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the CallGraphSCCPass class, which is used for passes which 00011 // are implemented as bottom-up traversals on the call graph. Because there may 00012 // be cycles in the call graph, passes of this type operate on the call-graph in 00013 // SCC order: that is, they process function bottom-up, except for recursive 00014 // functions, which they process all at once. 00015 // 00016 // These passes are inherently interprocedural, and are required to keep the 00017 // call graph up-to-date if they do anything which could modify it. 00018 // 00019 //===----------------------------------------------------------------------===// 00020 00021 #ifndef LLVM_CALL_GRAPH_SCC_PASS_H 00022 #define LLVM_CALL_GRAPH_SCC_PASS_H 00023 00024 #include "llvm/Pass.h" 00025 #include "llvm/Analysis/CallGraph.h" 00026 00027 namespace llvm { 00028 00029 class CallGraphNode; 00030 class CallGraph; 00031 class PMStack; 00032 00033 struct CallGraphSCCPass : public Pass { 00034 00035 explicit CallGraphSCCPass(intptr_t pid) : Pass(pid) {} 00036 explicit CallGraphSCCPass(void *pid) : Pass(pid) {} 00037 00038 /// doInitialization - This method is called before the SCC's of the program 00039 /// has been processed, allowing the pass to do initialization as necessary. 00040 virtual bool doInitialization(CallGraph &CG) { 00041 return false; 00042 } 00043 00044 /// runOnSCC - This method should be implemented by the subclass to perform 00045 /// whatever action is necessary for the specified SCC. Note that 00046 /// non-recursive (or only self-recursive) functions will have an SCC size of 00047 /// 1, where recursive portions of the call graph will have SCC size > 1. 00048 /// 00049 virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC) = 0; 00050 00051 /// doFinalization - This method is called after the SCC's of the program has 00052 /// been processed, allowing the pass to do final cleanup as necessary. 00053 virtual bool doFinalization(CallGraph &CG) { 00054 return false; 00055 } 00056 00057 /// Assign pass manager to manager this pass 00058 virtual void assignPassManager(PMStack &PMS, 00059 PassManagerType PMT = PMT_CallGraphPassManager); 00060 00061 /// Return what kind of Pass Manager can manage this pass. 00062 virtual PassManagerType getPotentialPassManagerType() const { 00063 return PMT_CallGraphPassManager; 00064 } 00065 00066 /// getAnalysisUsage - For this class, we declare that we require and preserve 00067 /// the call graph. If the derived class implements this method, it should 00068 /// always explicitly call the implementation here. 00069 virtual void getAnalysisUsage(AnalysisUsage &Info) const; 00070 }; 00071 00072 } // End llvm namespace 00073 00074 #endif