Fix printing of nonfunction graphs

llvm-svn: 5487
This commit is contained in:
Chris Lattner 2003-02-04 00:03:18 +00:00
parent 7b9a9209fc
commit 2e3829c76d

View File

@ -29,7 +29,7 @@ void DSNode::dump() const { print(std::cerr, 0); }
static std::string getCaption(const DSNode *N, const DSGraph *G) { static std::string getCaption(const DSNode *N, const DSGraph *G) {
std::stringstream OS; std::stringstream OS;
Module *M = G && &G->getFunction() ? G->getFunction().getParent() : 0; Module *M = G && G->hasFunction() ? G->getFunction().getParent() : 0;
if (N->isNodeCompletelyFolded()) if (N->isNodeCompletelyFolded())
OS << "FOLDED"; OS << "FOLDED";
@ -86,13 +86,15 @@ struct DOTGraphTraits<const DSGraph*> : public DefaultDOTGraphTraits {
/// ///
static void addCustomGraphFeatures(const DSGraph *G, static void addCustomGraphFeatures(const DSGraph *G,
GraphWriter<const DSGraph*> &GW) { GraphWriter<const DSGraph*> &GW) {
Module *CurMod = G->hasFunction() ? G->getFunction().getParent() : 0;
// Add scalar nodes to the graph... // Add scalar nodes to the graph...
const hash_map<Value*, DSNodeHandle> &VM = G->getScalarMap(); const hash_map<Value*, DSNodeHandle> &VM = G->getScalarMap();
for (hash_map<Value*, DSNodeHandle>::const_iterator I = VM.begin(); for (hash_map<Value*, DSNodeHandle>::const_iterator I = VM.begin();
I != VM.end(); ++I) I != VM.end(); ++I)
if (!isa<GlobalValue>(I->first)) { if (!isa<GlobalValue>(I->first)) {
std::stringstream OS; std::stringstream OS;
WriteAsOperand(OS, I->first, false, true, G->getFunction().getParent()); WriteAsOperand(OS, I->first, false, true, CurMod);
GW.emitSimpleNode(I->first, "", OS.str()); GW.emitSimpleNode(I->first, "", OS.str());
// Add edge from return node to real destination // Add edge from return node to real destination