LLVM API Documentation

CallGraphSCCPass.h

Go to the documentation of this file.
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 
00026 namespace llvm {
00027 
00028 class CallGraphNode;
00029 class CallGraph;
00030 class PMStack;
00031 
00032 struct CallGraphSCCPass : public Pass {
00033 
00034   explicit CallGraphSCCPass(intptr_t pid) : Pass(pid) {}
00035   explicit CallGraphSCCPass(void *pid) : Pass(pid) {}
00036 
00037   /// doInitialization - This method is called before the SCC's of the program
00038   /// has been processed, allowing the pass to do initialization as necessary.
00039   virtual bool doInitialization(CallGraph &CG) {
00040     return false;
00041   }
00042 
00043   /// runOnSCC - This method should be implemented by the subclass to perform
00044   /// whatever action is necessary for the specified SCC.  Note that
00045   /// non-recursive (or only self-recursive) functions will have an SCC size of
00046   /// 1, where recursive portions of the call graph will have SCC size > 1.
00047   ///
00048   virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC) = 0;
00049 
00050   /// doFinalization - This method is called after the SCC's of the program has
00051   /// been processed, allowing the pass to do final cleanup as necessary.
00052   virtual bool doFinalization(CallGraph &CG) {
00053     return false;
00054   }
00055 
00056   /// Assign pass manager to manager this pass
00057   virtual void assignPassManager(PMStack &PMS,
00058                                  PassManagerType PMT = PMT_CallGraphPassManager);
00059 
00060   ///  Return what kind of Pass Manager can manage this pass.
00061   virtual PassManagerType getPotentialPassManagerType() const {
00062     return PMT_CallGraphPassManager;
00063   }
00064 
00065   /// getAnalysisUsage - For this class, we declare that we require and preserve
00066   /// the call graph.  If the derived class implements this method, it should
00067   /// always explicitly call the implementation here.
00068   virtual void getAnalysisUsage(AnalysisUsage &Info) const;
00069 };
00070 
00071 } // End llvm namespace
00072 
00073 #endif



This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.