2003-08-31 03:54:59 +02:00
|
|
|
//===- CallGraphSCCPass.cpp - Pass that operates BU on call graph ---------===//
|
2005-04-21 23:13:18 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02: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 23:13:18 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2003-08-31 03:54:59 +02: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-02 00:55:40 +02:00
|
|
|
#include "llvm/ADT/SCCIterator.h"
|
2004-04-20 23:30:06 +02:00
|
|
|
using namespace llvm;
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2003-08-31 03:54:59 +02: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 06:48:05 +02:00
|
|
|
bool CallGraphSCCPass::runOnModule(Module &M) {
|
2003-08-31 03:54:59 +02:00
|
|
|
CallGraph &CG = getAnalysis<CallGraph>();
|
2004-04-20 23:52:26 +02:00
|
|
|
bool Changed = doInitialization(CG);
|
2003-08-31 22:01:57 +02:00
|
|
|
for (scc_iterator<CallGraph*> I = scc_begin(&CG), E = scc_end(&CG);
|
2003-08-31 03:54:59 +02:00
|
|
|
I != E; ++I)
|
2003-08-31 21:35:16 +02:00
|
|
|
Changed = runOnSCC(*I);
|
2004-04-20 23:52:26 +02:00
|
|
|
return Changed | doFinalization(CG);
|
2003-08-31 03:54:59 +02:00
|
|
|
}
|