Reverting back to original 1.8 version so I can manually merge in patch.
[llvm-complete.git] / lib / Analysis / IPA / CallGraphSCCPass.cpp
blob360bc23be30456ec347495adfd3de12528fdcfec
1 //===- CallGraphSCCPass.cpp - Pass that operates BU on call graph ---------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
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.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the CallGraphSCCPass class, which is used for passes
11 // which are implemented as bottom-up traversals on the call graph. Because
12 // there may be cycles in the call graph, passes of this type operate on the
13 // call-graph in SCC order: that is, they process function bottom-up, except for
14 // recursive functions, which they process all at once.
16 //===----------------------------------------------------------------------===//
18 #include "llvm/CallGraphSCCPass.h"
19 #include "llvm/Analysis/CallGraph.h"
20 #include "llvm/ADT/SCCIterator.h"
21 using namespace llvm;
23 /// getAnalysisUsage - For this class, we declare that we require and preserve
24 /// the call graph. If the derived class implements this method, it should
25 /// always explicitly call the implementation here.
26 void CallGraphSCCPass::getAnalysisUsage(AnalysisUsage &AU) const {
27 AU.addRequired<CallGraph>();
28 AU.addPreserved<CallGraph>();
31 bool CallGraphSCCPass::runOnModule(Module &M) {
32 CallGraph &CG = getAnalysis<CallGraph>();
33 bool Changed = doInitialization(CG);
34 for (scc_iterator<CallGraph*> I = scc_begin(&CG), E = scc_end(&CG);
35 I != E; ++I)
36 Changed = runOnSCC(*I);
37 return Changed | doFinalization(CG);