2002-07-11 00:38:08 +02:00
|
|
|
//===- Printer.cpp - Code for printing data structure graphs nicely -------===//
|
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
|
|
|
//===----------------------------------------------------------------------===//
|
2002-07-11 00:38:08 +02:00
|
|
|
//
|
|
|
|
// This file implements the 'dot' graph printer.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-07-07 08:32:21 +02:00
|
|
|
#include "llvm/Analysis/DataStructure/DataStructure.h"
|
|
|
|
#include "llvm/Analysis/DataStructure/DSGraph.h"
|
|
|
|
#include "llvm/Analysis/DataStructure/DSGraphTraits.h"
|
2002-07-11 00:38:08 +02:00
|
|
|
#include "llvm/Module.h"
|
2003-07-01 18:27:32 +02:00
|
|
|
#include "llvm/Constants.h"
|
2002-07-11 00:38:08 +02:00
|
|
|
#include "llvm/Assembly/Writer.h"
|
2004-09-02 00:55:40 +02:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
|
|
|
#include "llvm/Support/GraphWriter.h"
|
|
|
|
#include "llvm/ADT/Statistic.h"
|
2002-07-11 00:38:08 +02:00
|
|
|
#include <fstream>
|
|
|
|
#include <sstream>
|
2003-11-13 00:11:14 +01:00
|
|
|
using namespace llvm;
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2002-10-03 22:38:41 +02:00
|
|
|
// OnlyPrintMain - The DataStructure printer exposes this option to allow
|
|
|
|
// printing of only the graph for "main".
|
|
|
|
//
|
2002-11-18 22:42:45 +01:00
|
|
|
namespace {
|
|
|
|
cl::opt<bool> OnlyPrintMain("only-print-main-ds", cl::ReallyHidden);
|
2004-01-22 14:42:43 +01:00
|
|
|
cl::opt<bool> DontPrintAnything("dont-print-ds", cl::ReallyHidden);
|
2004-02-08 00:58:05 +01:00
|
|
|
Statistic<> MaxGraphSize ("dsa", "Maximum graph size");
|
|
|
|
Statistic<> NumFoldedNodes ("dsa", "Number of folded nodes (in final graph)");
|
2002-11-18 22:42:45 +01:00
|
|
|
}
|
2002-10-03 22:38:41 +02:00
|
|
|
|
2002-07-11 00:38:08 +02:00
|
|
|
void DSNode::dump() const { print(std::cerr, 0); }
|
|
|
|
|
2003-02-01 05:01:21 +01:00
|
|
|
static std::string getCaption(const DSNode *N, const DSGraph *G) {
|
2002-07-11 00:38:08 +02:00
|
|
|
std::stringstream OS;
|
2003-06-30 05:15:25 +02:00
|
|
|
Module *M = 0;
|
2004-02-26 00:06:30 +01:00
|
|
|
|
2004-03-02 22:39:43 +01:00
|
|
|
if (!G) G = N->getParentGraph();
|
2004-02-26 00:06:30 +01:00
|
|
|
|
2003-06-30 05:15:25 +02:00
|
|
|
// Get the module from ONE of the functions in the graph it is available.
|
2005-03-15 17:55:04 +01:00
|
|
|
if (G && G->retnodes_begin() != G->retnodes_end())
|
|
|
|
M = G->retnodes_begin()->first->getParent();
|
2004-03-02 22:39:43 +01:00
|
|
|
if (M == 0 && G) {
|
|
|
|
// If there is a global in the graph, we can use it to find the module.
|
|
|
|
const DSScalarMap &SM = G->getScalarMap();
|
|
|
|
if (SM.global_begin() != SM.global_end())
|
|
|
|
M = (*SM.global_begin())->getParent();
|
|
|
|
}
|
2002-10-02 00:33:50 +02:00
|
|
|
|
2002-11-06 07:20:27 +01:00
|
|
|
if (N->isNodeCompletelyFolded())
|
2003-07-02 06:39:27 +02:00
|
|
|
OS << "COLLAPSED";
|
2002-11-06 07:20:27 +01:00
|
|
|
else {
|
2002-11-18 22:42:45 +01:00
|
|
|
WriteTypeSymbolic(OS, N->getType(), M);
|
|
|
|
if (N->isArray())
|
2002-10-20 22:39:17 +02:00
|
|
|
OS << " array";
|
2002-11-06 07:20:27 +01:00
|
|
|
}
|
2003-06-19 23:15:11 +02:00
|
|
|
if (unsigned NodeType = N->getNodeFlags()) {
|
2002-11-06 07:20:27 +01:00
|
|
|
OS << ": ";
|
2003-06-19 23:15:11 +02:00
|
|
|
if (NodeType & DSNode::AllocaNode ) OS << "S";
|
|
|
|
if (NodeType & DSNode::HeapNode ) OS << "H";
|
|
|
|
if (NodeType & DSNode::GlobalNode ) OS << "G";
|
|
|
|
if (NodeType & DSNode::UnknownNode) OS << "U";
|
|
|
|
if (NodeType & DSNode::Incomplete ) OS << "I";
|
|
|
|
if (NodeType & DSNode::Modified ) OS << "M";
|
|
|
|
if (NodeType & DSNode::Read ) OS << "R";
|
|
|
|
#ifndef NDEBUG
|
|
|
|
if (NodeType & DSNode::DEAD ) OS << "<dead>";
|
|
|
|
#endif
|
2002-10-02 00:33:50 +02:00
|
|
|
OS << "\n";
|
|
|
|
}
|
|
|
|
|
2005-03-20 03:40:11 +01:00
|
|
|
EquivalenceClasses<GlobalValue*> *GlobalECs = 0;
|
|
|
|
if (G) GlobalECs = &G->getGlobalECs();
|
2005-04-21 23:13:18 +02:00
|
|
|
|
2005-03-20 03:40:11 +01:00
|
|
|
for (unsigned i = 0, e = N->getGlobalsList().size(); i != e; ++i) {
|
|
|
|
WriteAsOperand(OS, N->getGlobalsList()[i], false, true, M);
|
|
|
|
|
|
|
|
// Figure out how many globals are equivalent to this one.
|
|
|
|
if (GlobalECs) {
|
|
|
|
EquivalenceClasses<GlobalValue*>::iterator I =
|
|
|
|
GlobalECs->findValue(N->getGlobalsList()[i]);
|
|
|
|
if (I != GlobalECs->end()) {
|
2005-04-21 23:13:18 +02:00
|
|
|
unsigned NumMembers =
|
2005-03-20 03:40:11 +01:00
|
|
|
std::distance(GlobalECs->member_begin(I), GlobalECs->member_end());
|
|
|
|
if (NumMembers != 1) OS << " + " << (NumMembers-1) << " EC";
|
|
|
|
}
|
|
|
|
}
|
2002-07-11 22:33:32 +02:00
|
|
|
OS << "\n";
|
|
|
|
}
|
|
|
|
|
2002-07-11 00:38:08 +02:00
|
|
|
return OS.str();
|
|
|
|
}
|
|
|
|
|
2003-11-13 00:11:14 +01:00
|
|
|
namespace llvm {
|
2002-10-13 21:31:57 +02:00
|
|
|
template<>
|
2002-10-17 03:02:46 +02:00
|
|
|
struct DOTGraphTraits<const DSGraph*> : public DefaultDOTGraphTraits {
|
|
|
|
static std::string getGraphName(const DSGraph *G) {
|
2003-06-30 05:15:25 +02:00
|
|
|
switch (G->getReturnNodes().size()) {
|
2003-06-30 07:57:39 +02:00
|
|
|
case 0: return G->getFunctionNames();
|
|
|
|
case 1: return "Function " + G->getFunctionNames();
|
|
|
|
default: return "Functions: " + G->getFunctionNames();
|
2003-06-30 05:15:25 +02:00
|
|
|
}
|
2002-10-13 21:31:57 +02:00
|
|
|
}
|
|
|
|
|
2002-10-17 03:02:46 +02:00
|
|
|
static std::string getNodeLabel(const DSNode *Node, const DSGraph *Graph) {
|
2002-10-13 21:31:57 +02:00
|
|
|
return getCaption(Node, Graph);
|
|
|
|
}
|
|
|
|
|
2002-10-17 03:02:46 +02:00
|
|
|
static std::string getNodeAttributes(const DSNode *N) {
|
2004-05-05 08:10:06 +02:00
|
|
|
return "shape=Mrecord";
|
2002-10-13 21:31:57 +02:00
|
|
|
}
|
2004-06-22 09:13:10 +02:00
|
|
|
|
|
|
|
static bool edgeTargetsEdgeSource(const void *Node,
|
|
|
|
DSNode::const_iterator I) {
|
|
|
|
unsigned O = I.getNode()->getLink(I.getOffset()).getOffset();
|
|
|
|
return (O >> DS::PointerShift) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DSNode::const_iterator getEdgeTarget(const DSNode *Node,
|
|
|
|
DSNode::const_iterator I) {
|
|
|
|
unsigned O = I.getNode()->getLink(I.getOffset()).getOffset();
|
|
|
|
unsigned LinkNo = O >> DS::PointerShift;
|
|
|
|
const DSNode *N = *I;
|
|
|
|
DSNode::const_iterator R = N->begin();
|
|
|
|
for (; LinkNo; --LinkNo)
|
|
|
|
++R;
|
|
|
|
return R;
|
|
|
|
}
|
|
|
|
|
2005-04-21 23:13:18 +02:00
|
|
|
|
2002-10-16 04:04:36 +02:00
|
|
|
/// addCustomGraphFeatures - Use this graph writing hook to emit call nodes
|
|
|
|
/// and the return node.
|
|
|
|
///
|
2002-10-17 03:02:46 +02:00
|
|
|
static void addCustomGraphFeatures(const DSGraph *G,
|
|
|
|
GraphWriter<const DSGraph*> &GW) {
|
2003-06-30 05:15:25 +02:00
|
|
|
Module *CurMod = 0;
|
2005-03-15 17:55:04 +01:00
|
|
|
if (G->retnodes_begin() != G->retnodes_end())
|
|
|
|
CurMod = G->retnodes_begin()->first->getParent();
|
2004-03-02 22:39:43 +01:00
|
|
|
else {
|
|
|
|
// If there is a global in the graph, we can use it to find the module.
|
|
|
|
const DSScalarMap &SM = G->getScalarMap();
|
|
|
|
if (SM.global_begin() != SM.global_end())
|
|
|
|
CurMod = (*SM.global_begin())->getParent();
|
|
|
|
}
|
|
|
|
|
2003-02-04 01:03:18 +01:00
|
|
|
|
2002-11-02 01:13:20 +01:00
|
|
|
// Add scalar nodes to the graph...
|
2003-06-30 05:15:25 +02:00
|
|
|
const DSGraph::ScalarMapTy &VM = G->getScalarMap();
|
|
|
|
for (DSGraph::ScalarMapTy::const_iterator I = VM.begin(); I != VM.end();++I)
|
2004-07-18 02:18:30 +02:00
|
|
|
if (!isa<GlobalValue>(I->first)) {
|
2002-11-02 01:13:20 +01:00
|
|
|
std::stringstream OS;
|
2003-02-04 01:03:18 +01:00
|
|
|
WriteAsOperand(OS, I->first, false, true, CurMod);
|
2002-11-18 22:42:45 +01:00
|
|
|
GW.emitSimpleNode(I->first, "", OS.str());
|
2005-04-21 23:13:18 +02:00
|
|
|
|
2002-11-02 01:13:20 +01:00
|
|
|
// Add edge from return node to real destination
|
2004-10-30 09:21:19 +02:00
|
|
|
DSNode *DestNode = I->second.getNode();
|
2002-11-06 07:20:27 +01:00
|
|
|
int EdgeDest = I->second.getOffset() >> DS::PointerShift;
|
2002-11-02 01:13:20 +01:00
|
|
|
if (EdgeDest == 0) EdgeDest = -1;
|
2004-10-30 09:21:19 +02:00
|
|
|
GW.emitEdge(I->first, -1, DestNode,
|
2002-11-02 01:13:20 +01:00
|
|
|
EdgeDest, "arrowtail=tee,color=gray63");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-16 04:04:36 +02:00
|
|
|
// Output the returned value pointer...
|
2005-03-15 17:55:04 +01:00
|
|
|
for (DSGraph::retnodes_iterator I = G->retnodes_begin(),
|
|
|
|
E = G->retnodes_end(); I != E; ++I)
|
2003-06-30 05:15:25 +02:00
|
|
|
if (I->second.getNode()) {
|
|
|
|
std::string Label;
|
2005-03-15 17:55:04 +01:00
|
|
|
if (G->getReturnNodes().size() == 1)
|
2003-06-30 05:15:25 +02:00
|
|
|
Label = "returning";
|
|
|
|
else
|
|
|
|
Label = I->first->getName() + " ret node";
|
|
|
|
// Output the return node...
|
2003-11-12 05:58:19 +01:00
|
|
|
GW.emitSimpleNode((void*)I->first, "plaintext=circle", Label);
|
2003-06-30 05:15:25 +02:00
|
|
|
|
|
|
|
// Add edge from return node to real destination
|
2004-10-30 09:21:19 +02:00
|
|
|
DSNode *RetNode = I->second.getNode();
|
2003-06-30 05:15:25 +02:00
|
|
|
int RetEdgeDest = I->second.getOffset() >> DS::PointerShift;;
|
|
|
|
if (RetEdgeDest == 0) RetEdgeDest = -1;
|
2004-10-30 09:21:19 +02:00
|
|
|
GW.emitEdge((void*)I->first, -1, RetNode,
|
2003-06-30 05:15:25 +02:00
|
|
|
RetEdgeDest, "arrowtail=tee,color=gray63");
|
|
|
|
}
|
2002-10-16 22:16:16 +02:00
|
|
|
|
|
|
|
// Output all of the call nodes...
|
2005-01-31 00:51:02 +01:00
|
|
|
const std::list<DSCallSite> &FCs =
|
2002-11-10 07:53:59 +01:00
|
|
|
G->shouldPrintAuxCalls() ? G->getAuxFunctionCalls()
|
|
|
|
: G->getFunctionCalls();
|
2005-01-31 00:51:02 +01:00
|
|
|
for (std::list<DSCallSite>::const_iterator I = FCs.begin(), E = FCs.end();
|
|
|
|
I != E; ++I) {
|
|
|
|
const DSCallSite &Call = *I;
|
2003-02-05 22:59:58 +01:00
|
|
|
std::vector<std::string> EdgeSourceCaptions(Call.getNumPtrArgs()+2);
|
|
|
|
EdgeSourceCaptions[0] = "r";
|
|
|
|
if (Call.isDirectCall())
|
|
|
|
EdgeSourceCaptions[1] = Call.getCalleeFunc()->getName();
|
2003-02-14 21:25:47 +01:00
|
|
|
else
|
|
|
|
EdgeSourceCaptions[1] = "f";
|
2003-02-05 22:59:58 +01:00
|
|
|
|
|
|
|
GW.emitSimpleNode(&Call, "shape=record", "call", Call.getNumPtrArgs()+2,
|
|
|
|
&EdgeSourceCaptions);
|
2002-10-16 22:16:16 +02:00
|
|
|
|
2002-10-21 15:47:57 +02:00
|
|
|
if (DSNode *N = Call.getRetVal().getNode()) {
|
2002-11-06 07:20:27 +01:00
|
|
|
int EdgeDest = Call.getRetVal().getOffset() >> DS::PointerShift;
|
2002-10-21 15:47:57 +02:00
|
|
|
if (EdgeDest == 0) EdgeDest = -1;
|
2003-02-13 21:14:40 +01:00
|
|
|
GW.emitEdge(&Call, 0, N, EdgeDest, "color=gray63,tailclip=false");
|
2002-10-21 15:47:57 +02:00
|
|
|
}
|
2003-02-05 22:59:58 +01:00
|
|
|
|
|
|
|
// Print out the callee...
|
|
|
|
if (Call.isIndirectCall()) {
|
|
|
|
DSNode *N = Call.getCalleeNode();
|
|
|
|
assert(N && "Null call site callee node!");
|
2003-02-13 21:14:40 +01:00
|
|
|
GW.emitEdge(&Call, 1, N, -1, "color=gray63,tailclip=false");
|
2002-10-21 15:47:57 +02:00
|
|
|
}
|
2003-02-05 22:59:58 +01:00
|
|
|
|
2002-10-21 04:08:03 +02:00
|
|
|
for (unsigned j = 0, e = Call.getNumPtrArgs(); j != e; ++j)
|
|
|
|
if (DSNode *N = Call.getPtrArg(j).getNode()) {
|
2002-11-06 07:20:27 +01:00
|
|
|
int EdgeDest = Call.getPtrArg(j).getOffset() >> DS::PointerShift;
|
2002-10-16 22:16:16 +02:00
|
|
|
if (EdgeDest == 0) EdgeDest = -1;
|
2003-02-13 21:14:40 +01:00
|
|
|
GW.emitEdge(&Call, j+2, N, EdgeDest, "color=gray63,tailclip=false");
|
2002-10-16 22:16:16 +02:00
|
|
|
}
|
|
|
|
}
|
2002-10-16 04:04:36 +02:00
|
|
|
}
|
2002-10-13 21:31:57 +02:00
|
|
|
};
|
2003-11-13 00:11:14 +01:00
|
|
|
} // end namespace llvm
|
2002-10-13 21:31:57 +02:00
|
|
|
|
2002-10-17 03:02:46 +02:00
|
|
|
void DSNode::print(std::ostream &O, const DSGraph *G) const {
|
|
|
|
GraphWriter<const DSGraph *> W(O, G);
|
|
|
|
W.writeNode(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSGraph::print(std::ostream &O) const {
|
|
|
|
WriteGraph(O, this, "DataStructures");
|
|
|
|
}
|
2002-10-13 21:31:57 +02:00
|
|
|
|
2003-02-01 05:01:21 +01:00
|
|
|
void DSGraph::writeGraphToFile(std::ostream &O,
|
|
|
|
const std::string &GraphName) const {
|
|
|
|
std::string Filename = GraphName + ".dot";
|
2002-07-31 00:07:26 +02:00
|
|
|
O << "Writing '" << Filename << "'...";
|
|
|
|
std::ofstream F(Filename.c_str());
|
2005-04-21 23:13:18 +02:00
|
|
|
|
2002-07-31 00:07:26 +02:00
|
|
|
if (F.good()) {
|
2002-10-17 03:02:46 +02:00
|
|
|
print(F);
|
2002-11-11 01:01:02 +01:00
|
|
|
unsigned NumCalls = shouldPrintAuxCalls() ?
|
|
|
|
getAuxFunctionCalls().size() : getFunctionCalls().size();
|
|
|
|
O << " [" << getGraphSize() << "+" << NumCalls << "]\n";
|
2002-07-31 00:07:26 +02:00
|
|
|
} else {
|
|
|
|
O << " error opening file for writing!\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-10 19:17:07 +01:00
|
|
|
/// viewGraph - Emit a dot graph, run 'dot', run gv on the postscript file,
|
|
|
|
/// then cleanup. For use from the debugger.
|
|
|
|
///
|
|
|
|
void DSGraph::viewGraph() const {
|
|
|
|
std::ofstream F("/tmp/tempgraph.dot");
|
|
|
|
if (!F.good()) {
|
|
|
|
std::cerr << "Error opening '/tmp/tempgraph.dot' for temporary graph!\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
print(F);
|
2003-02-11 20:27:27 +01:00
|
|
|
F.close();
|
2004-05-05 08:10:06 +02:00
|
|
|
if (system("dot -Tps -Gsize=10,7.5 -Grotate=90 /tmp/tempgraph.dot > /tmp/tempgraph.ps"))
|
2003-02-10 19:17:07 +01:00
|
|
|
std::cerr << "Error running dot: 'dot' not in path?\n";
|
|
|
|
system("gv /tmp/tempgraph.ps");
|
|
|
|
system("rm /tmp/tempgraph.dot /tmp/tempgraph.ps");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:30 +02:00
|
|
|
template <typename Collection>
|
2002-07-27 03:12:15 +02:00
|
|
|
static void printCollection(const Collection &C, std::ostream &O,
|
2003-02-01 05:01:21 +01:00
|
|
|
const Module *M, const std::string &Prefix) {
|
2002-07-27 03:12:15 +02:00
|
|
|
if (M == 0) {
|
|
|
|
O << "Null Module pointer, cannot continue!\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-11-07 03:18:46 +01:00
|
|
|
unsigned TotalNumNodes = 0, TotalCallNodes = 0;
|
2002-07-27 03:12:15 +02:00
|
|
|
for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
|
2002-11-10 07:53:59 +01:00
|
|
|
if (C.hasGraph(*I)) {
|
2002-11-07 02:54:44 +01:00
|
|
|
DSGraph &Gr = C.getDSGraph((Function&)*I);
|
2002-11-10 07:53:59 +01:00
|
|
|
unsigned NumCalls = Gr.shouldPrintAuxCalls() ?
|
|
|
|
Gr.getAuxFunctionCalls().size() : Gr.getFunctionCalls().size();
|
2005-03-25 21:54:45 +01:00
|
|
|
bool IsDuplicateGraph = false;
|
2002-11-10 07:53:59 +01:00
|
|
|
|
2005-02-01 20:10:48 +01:00
|
|
|
if (I->getName() == "main" || !OnlyPrintMain) {
|
2005-03-15 17:55:04 +01:00
|
|
|
Function *SCCFn = Gr.retnodes_begin()->first;
|
2005-03-25 21:37:32 +01:00
|
|
|
if (&*I == SCCFn) {
|
2005-02-01 20:10:48 +01:00
|
|
|
Gr.writeGraphToFile(O, Prefix+I->getName());
|
2005-03-25 21:37:32 +01:00
|
|
|
} else {
|
2005-03-25 21:54:45 +01:00
|
|
|
IsDuplicateGraph = true; // Don't double count node/call nodes.
|
2005-02-01 20:10:48 +01:00
|
|
|
O << "Didn't write '" << Prefix+I->getName()
|
|
|
|
<< ".dot' - Graph already emitted to '" << Prefix+SCCFn->getName()
|
|
|
|
<< "\n";
|
2005-03-25 21:37:32 +01:00
|
|
|
}
|
2005-02-01 20:10:48 +01:00
|
|
|
} else {
|
2005-03-25 21:54:45 +01:00
|
|
|
Function *SCCFn = Gr.retnodes_begin()->first;
|
|
|
|
if (&*I == SCCFn) {
|
|
|
|
O << "Skipped Writing '" << Prefix+I->getName() << ".dot'... ["
|
|
|
|
<< Gr.getGraphSize() << "+" << NumCalls << "]\n";
|
|
|
|
} else {
|
|
|
|
IsDuplicateGraph = true; // Don't double count node/call nodes.
|
|
|
|
}
|
2002-11-07 02:54:44 +01:00
|
|
|
}
|
2002-11-18 22:42:45 +01:00
|
|
|
|
2005-03-25 21:54:45 +01:00
|
|
|
if (!IsDuplicateGraph) {
|
|
|
|
unsigned GraphSize = Gr.getGraphSize();
|
|
|
|
if (MaxGraphSize < GraphSize) MaxGraphSize = GraphSize;
|
2004-02-08 00:58:05 +01:00
|
|
|
|
2005-03-25 21:54:45 +01:00
|
|
|
TotalNumNodes += Gr.getGraphSize();
|
|
|
|
TotalCallNodes += NumCalls;
|
|
|
|
for (DSGraph::node_iterator NI = Gr.node_begin(), E = Gr.node_end();
|
|
|
|
NI != E; ++NI)
|
|
|
|
if (NI->isNodeCompletelyFolded())
|
|
|
|
++NumFoldedNodes;
|
|
|
|
}
|
2002-11-07 02:54:44 +01:00
|
|
|
}
|
2002-11-07 03:18:46 +01:00
|
|
|
|
2002-11-09 22:12:07 +01:00
|
|
|
DSGraph &GG = C.getGlobalsGraph();
|
|
|
|
TotalNumNodes += GG.getGraphSize();
|
|
|
|
TotalCallNodes += GG.getFunctionCalls().size();
|
2002-11-09 22:40:58 +01:00
|
|
|
if (!OnlyPrintMain) {
|
2002-11-09 22:12:07 +01:00
|
|
|
GG.writeGraphToFile(O, Prefix+"GlobalsGraph");
|
|
|
|
} else {
|
|
|
|
O << "Skipped Writing '" << Prefix << "GlobalsGraph.dot'... ["
|
|
|
|
<< GG.getGraphSize() << "+" << GG.getFunctionCalls().size() << "]\n";
|
|
|
|
}
|
|
|
|
|
2005-04-21 23:13:18 +02:00
|
|
|
O << "\nGraphs contain [" << TotalNumNodes << "+" << TotalCallNodes
|
2002-11-08 02:21:07 +01:00
|
|
|
<< "] nodes total" << std::endl;
|
2002-07-11 00:38:08 +02:00
|
|
|
}
|
2002-07-18 02:12:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
// print - Print out the analysis results...
|
2002-07-27 03:12:15 +02:00
|
|
|
void LocalDataStructures::print(std::ostream &O, const Module *M) const {
|
2004-01-22 14:42:43 +01:00
|
|
|
if (DontPrintAnything) return;
|
2002-10-02 00:33:50 +02:00
|
|
|
printCollection(*this, O, M, "ds.");
|
2002-07-18 02:12:30 +02:00
|
|
|
}
|
|
|
|
|
2002-07-27 03:12:15 +02:00
|
|
|
void BUDataStructures::print(std::ostream &O, const Module *M) const {
|
2004-01-22 14:42:43 +01:00
|
|
|
if (DontPrintAnything) return;
|
2002-10-02 00:33:50 +02:00
|
|
|
printCollection(*this, O, M, "bu.");
|
2002-07-31 00:07:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TDDataStructures::print(std::ostream &O, const Module *M) const {
|
2004-01-22 14:42:43 +01:00
|
|
|
if (DontPrintAnything) return;
|
2002-10-02 00:33:50 +02:00
|
|
|
printCollection(*this, O, M, "td.");
|
2002-10-17 06:24:30 +02:00
|
|
|
}
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2003-11-13 06:05:41 +01:00
|
|
|
void CompleteBUDataStructures::print(std::ostream &O, const Module *M) const {
|
2004-01-22 14:42:43 +01:00
|
|
|
if (DontPrintAnything) return;
|
2003-11-13 06:05:41 +01:00
|
|
|
printCollection(*this, O, M, "cbu.");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-13 20:51:24 +01:00
|
|
|
void EquivClassGraphs::print(std::ostream &O, const Module *M) const {
|
|
|
|
if (DontPrintAnything) return;
|
|
|
|
printCollection(*this, O, M, "eq.");
|
|
|
|
}
|
|
|
|
|