1 //===- CallGraphSCCPass.h - Pass that operates BU on call graph -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the CallGraphSCCPass class, which is used for passes which
11 // are implemented as bottom-up traversals on the call graph. Because there may
12 // be cycles in the call graph, passes of this type operate on the call-graph in
13 // SCC order: that is, they process function bottom-up, except for recursive
14 // functions, which they process all at once.
16 // These passes are inherently interprocedural, and are required to keep the
17 // call graph up-to-date if they do anything which could modify it.
19 //===----------------------------------------------------------------------===//
21 #ifndef LLVM_CALL_GRAPH_SCC_PASS_H
22 #define LLVM_CALL_GRAPH_SCC_PASS_H
24 #include "llvm/Pass.h"
32 struct CallGraphSCCPass : public Pass {
34 /// doInitialization - This method is called before the SCC's of the program
35 /// has been processed, allowing the pass to do initialization as necessary.
36 virtual bool doInitialization(CallGraph &CG) {
40 /// runOnSCC - This method should be implemented by the subclass to perform
41 /// whatever action is necessary for the specified SCC. Note that
42 /// non-recursive (or only self-recursive) functions will have an SCC size of
43 /// 1, where recursive portions of the call graph will have SCC size > 1.
45 virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC) = 0;
47 /// doFinalization - This method is called after the SCC's of the program has
48 /// been processed, allowing the pass to do final cleanup as necessary.
49 virtual bool doFinalization(CallGraph &CG) {
53 /// Assign pass manager to manager this pass
54 virtual void assignPassManager(PMStack &PMS,
55 PassManagerType PMT = PMT_CallGraphPassManager);
57 /// Return what kind of Pass Manager can manage this pass.
58 virtual PassManagerType getPotentialPassManagerType() const {
59 return PMT_CallGraphPassManager;
62 /// getAnalysisUsage - For this class, we declare that we require and preserve
63 /// the call graph. If the derived class implements this method, it should
64 /// always explicitly call the implementation here.
65 virtual void getAnalysisUsage(AnalysisUsage &Info) const;
68 } // End llvm namespace