LLVM API Documentation
00001 //===- CallGraphSCCPass.h - Pass that operates BU on call graph -*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source 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 00026 namespace llvm { 00027 00028 class CallGraphNode; 00029 class CallGraph; 00030 00031 struct CallGraphSCCPass : public ModulePass { 00032 00033 /// doInitialization - This method is called before the SCC's of the program 00034 /// has been processed, allowing the pass to do initialization as necessary. 00035 virtual bool doInitialization(CallGraph &CG) { 00036 return false; 00037 } 00038 00039 /// runOnSCC - This method should be implemented by the subclass to perform 00040 /// whatever action is necessary for the specified SCC. Note that 00041 /// non-recursive (or only self-recursive) functions will have an SCC size of 00042 /// 1, where recursive portions of the call graph will have SCC size > 1. 00043 /// 00044 virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC) = 0; 00045 00046 /// doFinalization - This method is called after the SCC's of the program has 00047 /// been processed, allowing the pass to do final cleanup as necessary. 00048 virtual bool doFinalization(CallGraph &CG) { 00049 return false; 00050 } 00051 00052 /// run - Run this pass, returning true if a modification was made to the 00053 /// module argument. This is implemented in terms of the runOnSCC method. 00054 /// 00055 virtual bool runOnModule(Module &M); 00056 00057 00058 /// getAnalysisUsage - For this class, we declare that we require and preserve 00059 /// the call graph. If the derived class implements this method, it should 00060 /// always explicitly call the implementation here. 00061 virtual void getAnalysisUsage(AnalysisUsage &Info) const; 00062 }; 00063 00064 } // End llvm namespace 00065 00066 #endif