void Graph::toDotLines(std::string s, raw_ostream *stream) { Instruction *A; StringRef File; OpNode *op; VarNode *va; CallNode *ca; ostringstream label; MDNode *N; unsigned Line; (*stream) << "digraph \"DFG for \'" << s << "\' \"{\n"; (*stream) << "label=\"DFG for \'" << s << "\' \";\n"; std::map<GraphNode*, int> DefinedNodes; for (std::set<GraphNode*>::iterator node = nodes.begin(), end = nodes.end(); node != end; node++) { label.str(""); if ((op = dyn_cast<OpNode>((*node)))) { if (op->getValue() != NULL) { if ((A = dyn_cast<Instruction>(op->getValue()))) { if ((N = A->getMetadata("dbg"))) { DILocation Loc(N); File = Loc.getFilename(); Line = Loc.getLineNumber(); label << File.str() << " " << Line; } else { label << "null"; } } }else label << "null"; }else if ((va = dyn_cast<VarNode>((*node)))) { if (va->getValue() != NULL) { if ((A = dyn_cast<Instruction>(va->getValue()))) { if ((N = A->getMetadata("dbg"))) { DILocation Loc(N); File = Loc.getFilename(); Line = Loc.getLineNumber(); label << File.str() << " " << Line; } else { label << "null"; } } }else label << "null"; }else if ((ca = dyn_cast<CallNode>((*node)))) { if (ca->getValue() != NULL) { if ((A = dyn_cast<Instruction>(ca->getValue()))) { if ((N = A->getMetadata("dbg"))) { DILocation Loc(N); File = Loc.getFilename(); Line = Loc.getLineNumber(); label << File.str() << " " << Line; } else { label << "null"; } } }else label << "null"; } if (DefinedNodes.count(*node) == 0) { (*stream) << (*node)->getName() << "[shape=" << (*node)->getShape() << ",style=" << (*node)->getStyle() << ",label=\"" << label.str() << "\"]\n"; DefinedNodes[*node] = 1; } std::map<GraphNode*, edgeType> succs = (*node)->getSuccessors(); for (std::map<GraphNode*, edgeType>::iterator succ = succs.begin(), s_end = succs.end(); succ != s_end; succ++) { label.str(""); if ((op = dyn_cast<OpNode>((succ->first)))) { if (op->getValue() != NULL) { if ((A = dyn_cast<Instruction>(op->getValue()))) { if ((N = A->getMetadata("dbg"))) { DILocation Loc(N); File = Loc.getFilename(); Line = Loc.getLineNumber(); label << File.str() << " " << Line; } else { label << "null"; } } }else label << "null"; }else if ((va = dyn_cast<VarNode>((succ->first)))) { if (va->getValue() != NULL) { if ((A = dyn_cast<Instruction>(va->getValue()))) { if ((N = A->getMetadata("dbg"))) { DILocation Loc(N); File = Loc.getFilename(); Line = Loc.getLineNumber(); label << File.str() << " " << Line; } else { label << "null"; } } }else label << "null"; }else if ((ca = dyn_cast<CallNode>((succ->first)))) { if (ca->getValue() != NULL) { if ((A = dyn_cast<Instruction>(ca->getValue()))) { if ((N = A->getMetadata("dbg"))) { DILocation Loc(N); File = Loc.getFilename(); Line = Loc.getLineNumber(); label << File.str() << " " << Line; } else { label << "null"; } } }else label << "null"; } if (DefinedNodes.count(succ->first) == 0) { (*stream) << (succ->first)->getName() << "[shape=" << (succ->first)->getShape() << ",style=" << (succ->first)->getStyle() << ",label=\"" << label.str() << "\"]\n"; DefinedNodes[succ->first] = 1; } //Source (*stream) << "\"" << (*node)->getName() << "\""; (*stream) << "->"; //Destination (*stream) << "\"" << (succ->first)->getName() << "\""; if (succ->second == etControl) (*stream) << " [style=dashed]"; (*stream) << "\n"; } } (*stream) << "}\n\n"; }