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";
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();
}
static string escapeLabel(const string &In) {
string Label(In);
replaceIn(Label, '\\', "\\\\"); // Escape caption...
+ replaceIn(Label, '\n', "\\n");
replaceIn(Label, ' ', "\\ ");
replaceIn(Label, '{', "\\{");
replaceIn(Label, '}', "\\}");
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;
// 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...
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");
}