Fix printing of nonfunction graphs
authorChris Lattner <sabre@nondot.org>
Tue, 4 Feb 2003 00:03:18 +0000 (00:03 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 4 Feb 2003 00:03:18 +0000 (00:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5487 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/DataStructure/Printer.cpp

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