Changes For Bug 352
[oota-llvm.git] / lib / Analysis / DataStructure / IPModRef.cpp
index 01b5bd0023aa38bccee461218c91882bd5911019..ccc15f74e499937f479ced2d1e6ac9b5a123ab44 100644 (file)
@@ -7,20 +7,18 @@
 // 
 //===----------------------------------------------------------------------===//
 //
-// See high-level comments in include/llvm/Analysis/IPModRef.h
+// See high-level comments in IPModRef.h
 // 
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Analysis/IPModRef.h"
-#include "llvm/Analysis/DataStructure.h"
-#include "llvm/Analysis/DSGraph.h"
+#include "IPModRef.h"
+#include "llvm/Analysis/DataStructure/DataStructure.h"
+#include "llvm/Analysis/DataStructure/DSGraph.h"
 #include "llvm/Module.h"
-#include "llvm/Function.h"
-#include "llvm/iMemory.h"
-#include "llvm/iOther.h"
-#include "Support/Statistic.h"
-#include "Support/STLExtras.h"
-#include "Support/StringExtras.h"
+#include "llvm/Instructions.h"
+#include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
 #include <vector>
 
 namespace llvm {
@@ -63,8 +61,10 @@ FunctionModRefInfo::FunctionModRefInfo(const Function& func,
     funcTDGraph(tdgClone),
     funcModRefInfo(tdgClone->getGraphSize())
 {
-  for (unsigned i=0, N = funcTDGraph->getGraphSize(); i < N; ++i)
-    NodeIds[funcTDGraph->getNodes()[i]] = i;
+  unsigned i = 0;
+  for (DSGraph::node_iterator NI = funcTDGraph->node_begin(),
+         E = funcTDGraph->node_end(); NI != E; ++NI)
+    NodeIds[*NI] = i++;
 }
 
 
@@ -95,13 +95,12 @@ void FunctionModRefInfo::computeModRef(const Function &func)
 {
   // Mark all nodes in the graph that are marked MOD as being mod
   // and all those marked REF as being ref.
-  for (unsigned i = 0, N = funcTDGraph->getGraphSize(); i < N; ++i)
-    {
-      if (funcTDGraph->getNodes()[i]->isModified())
-        funcModRefInfo.setNodeIsMod(i);
-      if (funcTDGraph->getNodes()[i]->isRead())
-        funcModRefInfo.setNodeIsRef(i);
-    }
+  unsigned i = 0;
+  for (DSGraph::node_iterator NI = funcTDGraph->node_begin(),
+         E = funcTDGraph->node_end(); NI != E; ++NI, ++i) {
+    if ((*NI)->isModified()) funcModRefInfo.setNodeIsMod(i);
+    if ((*NI)->isRead())     funcModRefInfo.setNodeIsRef(i);
+  }
 
   // Compute the Mod/Ref info for all call sites within the function.
   // The call sites are recorded in the TD graph.
@@ -214,18 +213,15 @@ FunctionModRefInfo::computeModRef(CallSite CS)
     }
 
   // For all nodes in the graph, extract the mod/ref information
-  const std::vector<DSNode*>& csgNodes = csgp->getNodes();
-  const std::vector<DSNode*>& origNodes = funcTDGraph->getNodes();
-  assert(csgNodes.size() == origNodes.size());
-  for (unsigned i=0, N = origNodes.size(); i < N; ++i)
-    { 
-      DSNode* csgNode = NodeMap[origNodes[i]].getNode();
-      assert(csgNode && "Inlined and original graphs do not correspond!");
-      if (csgNode->isModified())
-        callModRefInfo->setNodeIsMod(getNodeId(origNodes[i]));
-      if (csgNode->isRead())
-        callModRefInfo->setNodeIsRef(getNodeId(origNodes[i]));
-    }
+  for (DSGraph::node_iterator NI = funcTDGraph->node_begin(),
+         E = funcTDGraph->node_end(); NI != E; ++NI) { 
+    DSNode* csgNode = NodeMap[*NI].getNode();
+    assert(csgNode && "Inlined and original graphs do not correspond!");
+    if (csgNode->isModified())
+      callModRefInfo->setNodeIsMod(getNodeId(*NI));
+    if (csgNode->isRead())
+      callModRefInfo->setNodeIsRef(getNodeId(*NI));
+  }
 
   // Drop nodemap before we delete the graph...
   NodeMap.clear();
@@ -295,8 +291,10 @@ public:
 
                 O << std::string((j < NV-1)? "; " : "\n");
               }
+#if 0
           else
             tdGraph.getNodes()[i]->print(O, /*graph*/ NULL);
+#endif
         }
   }
 };
@@ -333,7 +331,7 @@ void FunctionModRefInfo::print(std::ostream &O) const
          CI = callSiteModRefInfo.begin(), CE = callSiteModRefInfo.end();
        CI != CE; ++CI)
     {
-      O << "  ----Mod/Ref information for call site\n" << CI->first;
+      O << "  ----Mod/Ref information for call site\n" << *CI->first;
 
       O << "    --Objects modified at call site:\n";
       DPH.printValuesInBitVec(O, CI->second->getModSet());