Lots of bug fixes, add BottomUpClosure, which has bugs, but is a start.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2945 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/DataStructure/Printer.cpp b/lib/Analysis/DataStructure/Printer.cpp
index 15f8df1..4a58c69 100644
--- a/lib/Analysis/DataStructure/Printer.cpp
+++ b/lib/Analysis/DataStructure/Printer.cpp
@@ -9,10 +9,11 @@
 #include "llvm/Assembly/Writer.h"
 #include <fstream>
 #include <sstream>
+using std::string;
 
 void DSNode::dump() const { print(std::cerr, 0); }
 
-std::string DSNode::getCaption(const DSGraph *G) const {
+string DSNode::getCaption(const DSGraph *G) const {
   std::stringstream OS;
   Module *M = G ? G->getFunction().getParent() : 0;
   WriteTypeSymbolic(OS, getType(), M);
@@ -24,6 +25,7 @@
   if (NodeType & GlobalNode) OS << "G";
   if (NodeType & SubElement) OS << "E";
   if (NodeType & CastNode  ) OS << "C";
+  if (NodeType & Incomplete) OS << "I";
 
   for (unsigned i = 0, e = Globals.size(); i != e; ++i) {
     OS << "\n";
@@ -43,7 +45,7 @@
   return OS.str();
 }
 
-static std::string getValueName(Value *V, Function &F) {
+static string getValueName(Value *V, Function &F) {
   std::stringstream OS;
   WriteAsOperand(OS, V, true, true, F.getParent());
   return OS.str();
@@ -51,7 +53,7 @@
 
 
 
-static void replaceIn(std::string &S, char From, const std::string &To) {
+static void replaceIn(string &S, char From, const string &To) {
   for (unsigned i = 0; i < S.size(); )
     if (S[i] == From) {
       S.replace(S.begin()+i, S.begin()+i+1,
@@ -144,23 +146,32 @@
   O << "}\n";
 }
 
-
-
-
-// print - Print out the analysis results...
-void LocalDataStructures::print(std::ostream &O, Module *M) const {
+template <typename Collection>
+static void printCollection(const Collection &C, std::ostream &O, Module *M,
+                            const string &Prefix) {
   for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
     if (!I->isExternal()) {
-      std::string Filename = "ds." + I->getName() + ".dot";
+      string Filename = Prefix + "." + I->getName() + ".dot";
       O << "Writing '" << Filename << "'...";
       std::ofstream F(Filename.c_str());
-
+      
       if (F.good()) {
-        DSGraph &Graph = getDSGraph(*I);
+        DSGraph &Graph = C.getDSGraph(*I);
         Graph.print(F);
-        O << " [" << Graph.getGraphSize() << "]\n";
+        O << " [" << Graph.getGraphSize() << "+"
+          << Graph.getFunctionCalls().size() << "]\n";
       } else {
         O << "  error opening file for writing!\n";
       }
     }
 }
+
+
+// print - Print out the analysis results...
+void LocalDataStructures::print(std::ostream &O, Module *M) const {
+  printCollection(*this, O, M, "ds");
+}
+
+void BUDataStructures::print(std::ostream &O, Module *M) const {
+  printCollection(*this, O, M, "bu");
+}