Start using retnodes_* for iteration.
authorChris Lattner <sabre@nondot.org>
Tue, 15 Mar 2005 16:55:04 +0000 (16:55 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 15 Mar 2005 16:55:04 +0000 (16:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20618 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/DataStructure/BottomUpClosure.cpp
lib/Analysis/DataStructure/CompleteBottomUp.cpp
lib/Analysis/DataStructure/DataStructure.cpp
lib/Analysis/DataStructure/EquivClassGraphs.cpp
lib/Analysis/DataStructure/Printer.cpp
lib/Analysis/DataStructure/TopDownClosure.cpp

index 5fca3ad43310c7e59b48d4f8b830821811dd6439..6c26602889cf99f5347c44826f40a56e12c8ee3f 100644 (file)
@@ -228,8 +228,8 @@ unsigned BUDataStructures::calculateGraphs(Function *F,
                               SCCGraph->getReturnNodes(), NodeMap);
         }
         // Update the DSInfo map and delete the old graph...
-        for (DSGraph::ReturnNodesTy::iterator I = G.getReturnNodes().begin(),
-               E = G.getReturnNodes().end(); I != E; ++I)
+        for (DSGraph::retnodes_iterator I = G.retnodes_begin(),
+               E = G.retnodes_end(); I != E; ++I)
           DSInfo[I->first] = SCCGraph;
         delete &G;
       }
@@ -496,7 +496,7 @@ void BUDataStructures::copyValue(Value *From, Value *To) {
     assert(NG->getReturnNodes().size() == 1 && "Cannot copy SCC's yet!");
 
     // Change the Function* is the returnnodes map to the ToF.
-    DSNodeHandle Ret = NG->getReturnNodes().begin()->second;
+    DSNodeHandle Ret = NG->retnodes_begin()->second;
     NG->getReturnNodes().clear();
     NG->getReturnNodes()[ToF] = Ret;
     return;
index e38aebfb81394118922318f993d0d47ef7a08b6a..4dcfc354833e026b0f289ad5d126a2086eea7808 100644 (file)
@@ -127,8 +127,8 @@ DSGraph &CompleteBUDataStructures::getOrCreateGraph(Function &F) {
 
   // Make sure to update the DSInfo map for all of the functions currently in
   // this graph!
-  for (DSGraph::ReturnNodesTy::iterator I = Graph->getReturnNodes().begin();
-       I != Graph->getReturnNodes().end(); ++I)
+  for (DSGraph::retnodes_iterator I = Graph->retnodes_begin();
+       I != Graph->retnodes_end(); ++I)
     DSInfo[I->first] = Graph;
 
   return *Graph;
@@ -180,8 +180,8 @@ unsigned CompleteBUDataStructures::calculateSCCGraphs(DSGraph &FG,
     FG.cloneInto(*NG, FG.getScalarMap(), FG.getReturnNodes(), NodeMap);
 
     // Update the DSInfo map and delete the old graph...
-    for (DSGraph::ReturnNodesTy::iterator I = NG->getReturnNodes().begin();
-         I != NG->getReturnNodes().end(); ++I)
+    for (DSGraph::retnodes_iterator I = NG->retnodes_begin();
+         I != NG->retnodes_end(); ++I)
       DSInfo[I->first] = &FG;
 
     // Remove NG from the ValMap since the pointer may get recycled.
index ac2abb308b92ca53cc21757afe16b7fef44029d1..aa962763247bf30dc43b3e0ff04c306abc9b6762 100644 (file)
@@ -547,8 +547,8 @@ bool DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset,
   }
 
   Module *M = 0;
-  if (getParentGraph()->getReturnNodes().size())
-    M = getParentGraph()->getReturnNodes().begin()->first->getParent();
+  if (getParentGraph()->retnodes_begin() != getParentGraph()->retnodes_end())
+    M = getParentGraph()->retnodes_begin()->first->getParent();
   DEBUG(std::cerr << "MergeTypeInfo Folding OrigTy: ";
         WriteTypeSymbolic(std::cerr, Ty, M) << "\n due to:";
         WriteTypeSymbolic(std::cerr, NewTy, M) << " @ " << Offset << "!\n"
@@ -1058,11 +1058,11 @@ void DSCallSite::InitNH(DSNodeHandle &NH, const DSNodeHandle &Src,
 std::string DSGraph::getFunctionNames() const {
   switch (getReturnNodes().size()) {
   case 0: return "Globals graph";
-  case 1: return getReturnNodes().begin()->first->getName();
+  case 1: return retnodes_begin()->first->getName();
   default:
     std::string Return;
-    for (DSGraph::ReturnNodesTy::const_iterator I = getReturnNodes().begin();
-         I != getReturnNodes().end(); ++I)
+    for (DSGraph::retnodes_iterator I = retnodes_begin();
+         I != retnodes_end(); ++I)
       Return += I->first->getName() + " ";
     Return.erase(Return.end()-1, Return.end());   // Remove last space character
     return Return;
@@ -1233,8 +1233,8 @@ void DSGraph::cloneInto(const DSGraph &G, DSScalarMap &OldValMap,
   }
 
   // Map the return node pointers over...
-  for (ReturnNodesTy::const_iterator I = G.getReturnNodes().begin(),
-         E = G.getReturnNodes().end(); I != E; ++I) {
+  for (retnodes_iterator I = G.retnodes_begin(),
+         E = G.retnodes_end(); I != E; ++I) {
     const DSNodeHandle &Ret = I->second;
     DSNodeHandle &MappedRet = OldNodeMap[Ret.getNode()];
     DSNode *MappedRetN = MappedRet.getNode();
index bc8f6a6b8c57aea1d110758e99f3f401fa0b3fc3..daefb673cbc1157f3a3d1e230c9d536259058325 100644 (file)
@@ -45,7 +45,7 @@ static void CheckAllGraphs(Module *M, GT &ECGraphs) {
   for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
     if (!I->isExternal()) {
       DSGraph &G = ECGraphs.getDSGraph(*I);
-      if (G.getReturnNodes().begin()->first != I)
+      if (G.retnodes_begin()->first != I)
         continue;  // Only check a graph once.
 
       DSGraph::NodeMapTy GlobalsGraphNodeMapping;
@@ -181,9 +181,8 @@ void EquivClassGraphs::buildIndirectFunctionSets(Module &M) {
     // Currently, that is just the functions in the same call-graph-SCC as F.
     // 
     DSGraph& funcDSGraph = CBU->getDSGraph(*I->second);
-    const DSGraph::ReturnNodesTy &RetNodes = funcDSGraph.getReturnNodes();
-    for (DSGraph::ReturnNodesTy::const_iterator RI=RetNodes.begin(),
-           RE=RetNodes.end(); RI != RE; ++RI)
+    for (DSGraph::retnodes_iterator RI = funcDSGraph.retnodes_begin(),
+           RE = funcDSGraph.retnodes_end(); RI != RE; ++RI)
       FuncECs.unionSetsWith(FirstFunc, RI->first);
   }
 
@@ -235,10 +234,8 @@ void EquivClassGraphs::buildIndirectFunctionSets(Module &M) {
           continue;
         
         // Record the "folded" graph for the function.
-        for (DSGraph::ReturnNodesTy::iterator
-               I = CBUGraph.getReturnNodes().begin(),
-               E = CBUGraph.getReturnNodes().end();
-             I != E; ++I) {
+        for (DSGraph::retnodes_iterator I = CBUGraph.retnodes_begin(),
+               E = CBUGraph.retnodes_end(); I != E; ++I) {
           assert(DSInfo[I->first] == 0 && "Graph already exists for Fn!");
           DSInfo[I->first] = &MergedG;
         }
@@ -284,8 +281,8 @@ DSGraph &EquivClassGraphs::getOrCreateGraph(Function &F) {
   Graph->setPrintAuxCalls();
 
   // Make sure to update the DSInfo map for all functions in the graph!
-  for (DSGraph::ReturnNodesTy::iterator I = Graph->getReturnNodes().begin();
-       I != Graph->getReturnNodes().end(); ++I)
+  for (DSGraph::retnodes_iterator I = Graph->retnodes_begin();
+       I != Graph->retnodes_end(); ++I)
     if (I->first != &F) {
       DSGraph *&FG = DSInfo[I->first];
       assert(FG == 0 && "Merging function in SCC twice?");
@@ -342,8 +339,8 @@ processSCC(DSGraph &FG, std::vector<DSGraph*> &Stack, unsigned &NextID,
     FG.cloneInto(*NG, FG.getScalarMap(), FG.getReturnNodes(), NodeMap);
 
     // Update the DSInfo map and delete the old graph...
-    for (DSGraph::ReturnNodesTy::iterator I = NG->getReturnNodes().begin();
-         I != NG->getReturnNodes().end(); ++I)
+    for (DSGraph::retnodes_iterator I = NG->retnodes_begin();
+         I != NG->retnodes_end(); ++I)
       DSInfo[I->first] = &FG;
     
     // Remove NG from the ValMap since the pointer may get recycled.
index ee143f6689a14618c9d0bd9d7a80010eb0276805..05fba215d51d1073658eda9c5a179f843bfda245 100644 (file)
@@ -44,8 +44,8 @@ static std::string getCaption(const DSNode *N, const DSGraph *G) {
   if (!G) G = N->getParentGraph();
 
   // Get the module from ONE of the functions in the graph it is available.
-  if (G && !G->getReturnNodes().empty())
-    M = G->getReturnNodes().begin()->first->getParent();
+  if (G && G->retnodes_begin() != G->retnodes_end())
+    M = G->retnodes_begin()->first->getParent();
   if (M == 0 && G) {
     // If there is a global in the graph, we can use it to find the module.
     const DSScalarMap &SM = G->getScalarMap();
@@ -126,8 +126,8 @@ struct DOTGraphTraits<const DSGraph*> : public DefaultDOTGraphTraits {
   static void addCustomGraphFeatures(const DSGraph *G,
                                      GraphWriter<const DSGraph*> &GW) {
     Module *CurMod = 0;
-    if (!G->getReturnNodes().empty())
-      CurMod = G->getReturnNodes().begin()->first->getParent();
+    if (G->retnodes_begin() != G->retnodes_end())
+      CurMod = G->retnodes_begin()->first->getParent();
     else {
       // If there is a global in the graph, we can use it to find the module.
       const DSScalarMap &SM = G->getScalarMap();
@@ -154,12 +154,11 @@ struct DOTGraphTraits<const DSGraph*> : public DefaultDOTGraphTraits {
 
 
     // Output the returned value pointer...
-    const DSGraph::ReturnNodesTy &RetNodes = G->getReturnNodes();
-    for (DSGraph::ReturnNodesTy::const_iterator I = RetNodes.begin(),
-           E = RetNodes.end(); I != E; ++I)
+    for (DSGraph::retnodes_iterator I = G->retnodes_begin(),
+           E = G->retnodes_end(); I != E; ++I)
       if (I->second.getNode()) {
         std::string Label;
-        if (RetNodes.size() == 1)
+        if (G->getReturnNodes().size() == 1)
           Label = "returning";
         else
           Label = I->first->getName() + " ret node";
@@ -276,7 +275,7 @@ static void printCollection(const Collection &C, std::ostream &O,
 
       TotalCallNodes += NumCalls;
       if (I->getName() == "main" || !OnlyPrintMain) {
-        Function *SCCFn = Gr.getReturnNodes().begin()->first;
+        Function *SCCFn = Gr.retnodes_begin()->first;
         if (&*I == SCCFn)
           Gr.writeGraphToFile(O, Prefix+I->getName());
         else
index bbce45b568d70ffbd0095ea7a902808bbe257fc7..580f22884f5131c32bbda7e47570bb0e3b7eb447 100644 (file)
@@ -179,9 +179,8 @@ void TDDataStructures::inlineGraphIntoCallees(DSGraph &Graph) {
   // If any of the functions has incomplete incoming arguments, don't mark any
   // of them as complete.
   bool HasIncompleteArgs = false;
-  const DSGraph::ReturnNodesTy &GraphReturnNodes = Graph.getReturnNodes();
-  for (DSGraph::ReturnNodesTy::const_iterator I = GraphReturnNodes.begin(),
-         E = GraphReturnNodes.end(); I != E; ++I)
+  for (DSGraph::retnodes_iterator I = Graph.retnodes_begin(),
+         E = Graph.retnodes_end(); I != E; ++I)
     if (ArgsRemainIncomplete.count(I->first)) {
       HasIncompleteArgs = true;
       break;
@@ -330,7 +329,7 @@ void TDDataStructures::copyValue(Value *From, Value *To) {
     assert(NG->getReturnNodes().size() == 1 && "Cannot copy SCC's yet!");
 
     // Change the Function* is the returnnodes map to the ToF.
-    DSNodeHandle Ret = NG->getReturnNodes().begin()->second;
+    DSNodeHandle Ret = NG->retnodes_begin()->second;
     NG->getReturnNodes().clear();
     NG->getReturnNodes()[ToF] = Ret;
     return;