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