1 //===- CallGraphSCCPass.cpp - Pass that operates BU on call graph ---------===//
3 // This file implements the CallGraphSCCPass class, which is used for passes
4 // which are implemented as bottom-up traversals on the call graph. Because
5 // there may be cycles in the call graph, passes of this type operate on the
6 // call-graph in SCC order: that is, they process function bottom-up, except for
7 // recursive functions, which they process all at once.
9 //===----------------------------------------------------------------------===//
11 #include "llvm/CallGraphSCCPass.h"
12 #include "llvm/Analysis/CallGraph.h"
13 #include "Support/TarjanSCCIterator.h"
15 /// getAnalysisUsage - For this class, we declare that we require and preserve
16 /// the call graph. If the derived class implements this method, it should
17 /// always explicitly call the implementation here.
18 void CallGraphSCCPass::getAnalysisUsage(AnalysisUsage &AU) const {
19 AU.addRequired<CallGraph>();
20 AU.addPreserved<CallGraph>();
23 bool CallGraphSCCPass::run(Module &M) {
24 CallGraph &CG = getAnalysis<CallGraph>();
26 for (TarjanSCC_iterator<CallGraph*> I = tarj_begin(&CG), E = tarj_end(&CG);
28 Changed = runOnSCC(**I);