//===- PrintSCC.cpp - Enumerate SCCs in some key graphs -------------------===//
-//
+//
// 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.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file provides passes to print out SCCs in a CFG or a CallGraph.
// analyze -cfgscc to print the SCCs in each CFG of a module.
// analyze -cfgscc -stats to print the #SCCs and the maximum SCC size.
// analyze -cfgscc -debug > /dev/null to watch the algorithm in action.
-//
+//
// and similarly:
// analyze -callscc [-stats] [-debug] to print SCCs in the CallGraph
-//
+//
// (3) To test the scc_iterator.
//
//===----------------------------------------------------------------------===//
#include "llvm/Module.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Support/CFG.h"
-#include "Support/SCCIterator.h"
-
-namespace llvm {
+#include "llvm/ADT/SCCIterator.h"
+#include <iostream>
+using namespace llvm;
namespace {
struct CFGSCC : public FunctionPass {
bool runOnFunction(Function& func);
- void print(std::ostream &O) const { }
+ void print(std::ostream &O, const Module* = 0) const { }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
}
};
- struct CallGraphSCC : public Pass {
+ struct CallGraphSCC : public ModulePass {
// run - Print out SCCs in the call graph for the specified module.
- bool run(Module &M);
+ bool runOnModule(Module &M);
- void print(std::ostream &O) const { }
+ void print(std::ostream &O, const Module* = 0) const { }
// getAnalysisUsage - This pass requires the CallGraph.
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
// run - Print out SCCs in the call graph for the specified module.
-bool CallGraphSCC::run(Module &M) {
+bool CallGraphSCC::runOnModule(Module &M) {
CallGraphNode* rootNode = getAnalysis<CallGraph>().getRoot();
unsigned sccNum = 0;
std::cout << "SCCs for the program in PostOrder:";
return true;
}
-
-} // End llvm namespace