diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-07-30 22:07:26 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-07-30 22:07:26 +0000 |
commit | dfd2f32bf74d2cc925a000d6e47fb74b156ce997 (patch) | |
tree | a4bca2b8d4fc71b49aa9fd372a0361a9e8cf2853 /lib/Analysis/DataStructure | |
parent | aaeee75af864126e14c528d3340739f50e38eb1c (diff) | |
download | external_llvm-dfd2f32bf74d2cc925a000d6e47fb74b156ce997.zip external_llvm-dfd2f32bf74d2cc925a000d6e47fb74b156ce997.tar.gz external_llvm-dfd2f32bf74d2cc925a000d6e47fb74b156ce997.tar.bz2 |
Print globals graph after either the BU or the TD pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3172 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure')
-rw-r--r-- | lib/Analysis/DataStructure/Printer.cpp | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/lib/Analysis/DataStructure/Printer.cpp b/lib/Analysis/DataStructure/Printer.cpp index 03ce297..00418f8 100644 --- a/lib/Analysis/DataStructure/Printer.cpp +++ b/lib/Analysis/DataStructure/Printer.cpp @@ -15,7 +15,7 @@ void DSNode::dump() const { print(std::cerr, 0); } string DSNode::getCaption(const DSGraph *G) const { std::stringstream OS; - Module *M = G ? G->getFunction().getParent() : 0; + Module *M = G && &G->getFunction()? G->getFunction().getParent() : 0; WriteTypeSymbolic(OS, getType(), M); OS << " "; @@ -111,8 +111,12 @@ void DSGraph::print(std::ostream &O) const { << "\tnode [shape=Mrecord];\n" << "\tedge [arrowtail=\"dot\"];\n" << "\tsize=\"10,7.5\";\n" - << "\trotate=\"90\";\n" - << "\tlabel=\"Function\\ " << Func.getName() << "\";\n\n"; + << "\trotate=\"90\";\n"; + + if (&Func != 0) + O << "\tlabel=\"Function\\ " << Func.getName() << "\";\n\n"; + else + O << "\tlabel=\"Global Graph\";\n\n"; // Output all of the nodes... for (unsigned i = 0, e = Nodes.size(); i != e; ++i) @@ -146,6 +150,22 @@ void DSGraph::print(std::ostream &O) const { O << "}\n"; } + +static void printGraph(const DSGraph &Graph, std::ostream &O, + const string &GraphName, const string &Prefix) { + string Filename = Prefix + "." + GraphName + ".dot"; + O << "Writing '" << Filename << "'..."; + std::ofstream F(Filename.c_str()); + + if (F.good()) { + Graph.print(F); + O << " [" << Graph.getGraphSize() << "+" + << Graph.getFunctionCalls().size() << "]\n"; + } else { + O << " error opening file for writing!\n"; + } +} + template <typename Collection> static void printCollection(const Collection &C, std::ostream &O, const Module *M, const string &Prefix) { @@ -155,20 +175,8 @@ static void printCollection(const Collection &C, std::ostream &O, } for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) - if (!I->isExternal()) { - string Filename = Prefix + "." + I->getName() + ".dot"; - O << "Writing '" << Filename << "'..."; - std::ofstream F(Filename.c_str()); - - if (F.good()) { - DSGraph &Graph = C.getDSGraph((Function&)*I); - Graph.print(F); - O << " [" << Graph.getGraphSize() << "+" - << Graph.getFunctionCalls().size() << "]\n"; - } else { - O << " error opening file for writing!\n"; - } - } + if (!I->isExternal()) + printGraph(C.getDSGraph((Function&)*I), O, I->getName(), Prefix); } @@ -179,4 +187,20 @@ void LocalDataStructures::print(std::ostream &O, const Module *M) const { void BUDataStructures::print(std::ostream &O, const Module *M) const { printCollection(*this, O, M, "bu"); + + for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) + if (!I->isExternal()) { + printGraph(*getDSGraph(*I).GlobalsGraph, O, "program", "gg"); + break; + } +} + +void TDDataStructures::print(std::ostream &O, const Module *M) const { + printCollection(*this, O, M, "td"); + + for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) + if (!I->isExternal()) { + printGraph(*getDSGraph(*I).GlobalsGraph, O, "program", "gg"); + break; + } } |