summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-07-11 20:33:32 +0000
committerChris Lattner <sabre@nondot.org>2002-07-11 20:33:32 +0000
commit76d5b489e33efd51b2387de3b64ef5c666754072 (patch)
tree3d1583fcead27c4f72dc757b817fa167d6faf48e /lib
parentf9ae4c5cb6b546b83a11d9e5d9da44179b2680d3 (diff)
downloadllvm-76d5b489e33efd51b2387de3b64ef5c666754072.tar.gz
llvm-76d5b489e33efd51b2387de3b64ef5c666754072.tar.bz2
llvm-76d5b489e33efd51b2387de3b64ef5c666754072.tar.xz
* Pass the DSGraph around instead of the Function to printing fns
* Print the globals list in the node * Print the scalars in the scalar node * Eliminate Scalar "label" edges in the graph * Print fake edges lighter instead of dotted git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2880 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/DataStructure/Printer.cpp42
1 files changed, 26 insertions, 16 deletions
diff --git a/lib/Analysis/DataStructure/Printer.cpp b/lib/Analysis/DataStructure/Printer.cpp
index c0caaa07d7..ecd5486602 100644
--- a/lib/Analysis/DataStructure/Printer.cpp
+++ b/lib/Analysis/DataStructure/Printer.cpp
@@ -12,9 +12,10 @@
void DSNode::dump() const { print(std::cerr, 0); }
-std::string DSNode::getCaption(Function *F) const {
+std::string DSNode::getCaption(const DSGraph *G) const {
std::stringstream OS;
- WriteTypeSymbolic(OS, getType(), F ? F->getParent() : 0);
+ Module *M = G ? G->getFunction().getParent() : 0;
+ WriteTypeSymbolic(OS, getType(), M);
OS << " ";
if (NodeType & ScalarNode) OS << "S";
@@ -24,6 +25,21 @@ std::string DSNode::getCaption(Function *F) const {
if (NodeType & SubElement) OS << "E";
if (NodeType & CastNode ) OS << "C";
+ for (unsigned i = 0, e = Globals.size(); i != e; ++i) {
+ OS << "\n";
+ WriteAsOperand(OS, Globals[i], false, true, M);
+ }
+
+ if ((NodeType & ScalarNode) && G) {
+ const std::map<Value*, DSNodeHandle> &VM = G->getValueMap();
+ for (std::map<Value*, DSNodeHandle>::const_iterator I = VM.begin(),
+ E = VM.end(); I != E; ++I)
+ if (I->second == this) {
+ OS << "\n";
+ WriteAsOperand(OS, I->first, false, true, M);
+ }
+ }
+
return OS.str();
}
@@ -49,6 +65,7 @@ static void replaceIn(std::string &S, char From, const std::string &To) {
static string escapeLabel(const string &In) {
string Label(In);
replaceIn(Label, '\\', "\\\\"); // Escape caption...
+ replaceIn(Label, '\n', "\\n");
replaceIn(Label, ' ', "\\ ");
replaceIn(Label, '{', "\\{");
replaceIn(Label, '}', "\\}");
@@ -67,8 +84,8 @@ static void writeEdge(std::ostream &O, const void *SrcNode,
O << ";\n";
}
-void DSNode::print(std::ostream &O, Function *F) const {
- string Caption = escapeLabel(getCaption(F));
+void DSNode::print(std::ostream &O, const DSGraph *G) const {
+ string Caption = escapeLabel(getCaption(G));
O << "\tNode" << (void*)this << " [ label =\"{" << Caption;
@@ -97,22 +114,15 @@ void DSGraph::print(std::ostream &O) const {
// Output all of the nodes...
for (unsigned i = 0, e = Nodes.size(); i != e; ++i)
- Nodes[i]->print(O, &Func);
+ Nodes[i]->print(O, this);
O << "\n";
- // Output all of the nodes edges for scalar labels
- for (std::map<Value*, DSNodeHandle>::const_iterator I = ValueMap.begin(),
- E = ValueMap.end(); I != E; ++I) {
- O << "\tNode" << (void*)I->first << "[ shape=circle, label =\""
- << escapeLabel(getValueName(I->first, Func)) << "\",style=dotted];\n";
- writeEdge(O, I->first, "",-1, I->second.get(),"arrowtail=tee,style=dotted");
- }
// Output the returned value pointer...
if (RetNode != 0) {
- O << "\tNode0x1" << "[ shape=circle, label =\""
- << escapeLabel("Return") << "\"];\n";
- writeEdge(O, (void*)1, "", -1, RetNode, "arrowtail=tee,style=dotted");
+ O << "\tNode0x1" << "[ plaintext=circle, label =\""
+ << escapeLabel("returning") << "\"];\n";
+ writeEdge(O, (void*)1, "", -1, RetNode, "arrowtail=tee,color=gray63");
}
// Output all of the call nodes...
@@ -127,7 +137,7 @@ void DSGraph::print(std::ostream &O) const {
for (unsigned j = 0, e = Call.size(); j != e; ++j)
if (Call[j])
- writeEdge(O, &Call, ":g", j, Call[j]);
+ writeEdge(O, &Call, ":g", j, Call[j], "color=gray63");
}