2003-08-31 01:54:59 +00:00
|
|
|
//===- CallGraphSCCPass.cpp - Pass that operates BU on call graph ---------===//
|
2005-04-21 21:13:18 +00:00
|
|
|
//
|
2003-10-20 19:43:21 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-21 21:13:18 +00:00
|
|
|
//
|
2003-10-20 19:43:21 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2003-08-31 01:54:59 +00:00
|
|
|
//
|
|
|
|
// This file implements the CallGraphSCCPass class, which is used for passes
|
|
|
|
// which are implemented as bottom-up traversals on the call graph. Because
|
|
|
|
// there may be cycles in the call graph, passes of this type operate on the
|
|
|
|
// call-graph in SCC order: that is, they process function bottom-up, except for
|
|
|
|
// recursive functions, which they process all at once.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/CallGraphSCCPass.h"
|
|
|
|
#include "llvm/Analysis/CallGraph.h"
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/ADT/SCCIterator.h"
|
2004-04-20 21:30:06 +00:00
|
|
|
using namespace llvm;
|
2003-11-11 22:41:34 +00:00
|
|
|
|
2003-08-31 01:54:59 +00:00
|
|
|
/// getAnalysisUsage - For this class, we declare that we require and preserve
|
|
|
|
/// the call graph. If the derived class implements this method, it should
|
|
|
|
/// always explicitly call the implementation here.
|
|
|
|
void CallGraphSCCPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.addRequired<CallGraph>();
|
|
|
|
AU.addPreserved<CallGraph>();
|
|
|
|
}
|
|
|
|
|
2004-09-20 04:48:05 +00:00
|
|
|
bool CallGraphSCCPass::runOnModule(Module &M) {
|
2003-08-31 01:54:59 +00:00
|
|
|
CallGraph &CG = getAnalysis<CallGraph>();
|
2004-04-20 21:52:26 +00:00
|
|
|
bool Changed = doInitialization(CG);
|
2003-08-31 20:01:57 +00:00
|
|
|
for (scc_iterator<CallGraph*> I = scc_begin(&CG), E = scc_end(&CG);
|
2003-08-31 01:54:59 +00:00
|
|
|
I != E; ++I)
|
2003-08-31 19:35:16 +00:00
|
|
|
Changed = runOnSCC(*I);
|
2004-04-20 21:52:26 +00:00
|
|
|
return Changed | doFinalization(CG);
|
2003-08-31 01:54:59 +00:00
|
|
|
}
|