Add special case handling for calloc and realloc
[oota-llvm.git] / lib / Analysis / DataStructure / Printer.cpp
index f568c8d96717c4df0eea7a1d81de280f640aa65e..87fc1f76cc9344dcbbc9e2d59f4d99b4a17b0fc7 100644 (file)
@@ -8,6 +8,7 @@
 #include "llvm/Analysis/DSGraph.h"
 #include "llvm/Analysis/DSGraphTraits.h"
 #include "llvm/Module.h"
+#include "llvm/Constants.h"
 #include "llvm/Assembly/Writer.h"
 #include "Support/CommandLine.h"
 #include "Support/GraphWriter.h"
@@ -35,7 +36,7 @@ static std::string getCaption(const DSNode *N, const DSGraph *G) {
     M = G->getReturnNodes().begin()->first->getParent();
 
   if (N->isNodeCompletelyFolded())
-    OS << "FOLDED";
+    OS << "COLLAPSED";
   else {
     WriteTypeSymbolic(OS, N->getType(), M);
     if (N->isArray())
@@ -68,14 +69,9 @@ template<>
 struct DOTGraphTraits<const DSGraph*> : public DefaultDOTGraphTraits {
   static std::string getGraphName(const DSGraph *G) {
     switch (G->getReturnNodes().size()) {
-    case 0: return "Global graph";
-    case 1: return "Function " + G->getReturnNodes().begin()->first->getName();
-    default:
-      std::string Return = "Functions: ";
-      for (DSGraph::ReturnNodesTy::const_iterator I=G->getReturnNodes().begin();
-           I != G->getReturnNodes().end(); ++I)
-        Return += I->first->getName() + " ";
-      return Return;
+    case 0: return G->getFunctionNames();
+    case 1: return "Function " + G->getFunctionNames();
+    default: return "Functions: " + G->getFunctionNames();
     }
   }
 
@@ -104,7 +100,7 @@ struct DOTGraphTraits<const DSGraph*> : public DefaultDOTGraphTraits {
     // Add scalar nodes to the graph...
     const DSGraph::ScalarMapTy &VM = G->getScalarMap();
     for (DSGraph::ScalarMapTy::const_iterator I = VM.begin(); I != VM.end();++I)
-      if (!isa<GlobalValue>(I->first)) {
+      if (!isa<GlobalValue>(I->first) && !isa<ConstantPointerRef>(I->first)) {
         std::stringstream OS;
         WriteAsOperand(OS, I->first, false, true, CurMod);
         GW.emitSimpleNode(I->first, "", OS.str());