[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Printer.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Mar 25 12:55:01 PST 2005



Changes in directory llvm/lib/Analysis/DataStructure:

Printer.cpp updated: 1.80 -> 1.81
---
Log message:

no really, don't double count these nodes either!


---
Diffs of the changes:  (+19 -14)

 Printer.cpp |   33 +++++++++++++++++++--------------
 1 files changed, 19 insertions(+), 14 deletions(-)


Index: llvm/lib/Analysis/DataStructure/Printer.cpp
diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.80 llvm/lib/Analysis/DataStructure/Printer.cpp:1.81
--- llvm/lib/Analysis/DataStructure/Printer.cpp:1.80	Fri Mar 25 14:37:32 2005
+++ llvm/lib/Analysis/DataStructure/Printer.cpp	Fri Mar 25 14:54:45 2005
@@ -285,34 +285,39 @@
       DSGraph &Gr = C.getDSGraph((Function&)*I);
       unsigned NumCalls = Gr.shouldPrintAuxCalls() ?
         Gr.getAuxFunctionCalls().size() : Gr.getFunctionCalls().size();
+      bool IsDuplicateGraph = false;
 
       if (I->getName() == "main" || !OnlyPrintMain) {
         Function *SCCFn = Gr.retnodes_begin()->first;
         if (&*I == SCCFn) {
-          TotalNumNodes += Gr.getGraphSize();
-          TotalCallNodes += NumCalls;
-
           Gr.writeGraphToFile(O, Prefix+I->getName());
         } else {
-          // Don't double count node/call nodes.
+          IsDuplicateGraph = true; // Don't double count node/call nodes.
           O << "Didn't write '" << Prefix+I->getName()
             << ".dot' - Graph already emitted to '" << Prefix+SCCFn->getName()
             << "\n";
         }
       } else {
-        TotalNumNodes += Gr.getGraphSize();
-        TotalCallNodes += NumCalls;
-        O << "Skipped Writing '" << Prefix+I->getName() << ".dot'... ["
-          << Gr.getGraphSize() << "+" << NumCalls << "]\n";
+        Function *SCCFn = Gr.retnodes_begin()->first;
+        if (&*I == SCCFn) {
+          O << "Skipped Writing '" << Prefix+I->getName() << ".dot'... ["
+            << Gr.getGraphSize() << "+" << NumCalls << "]\n";
+        } else {
+          IsDuplicateGraph = true; // Don't double count node/call nodes.
+        }
       }
 
-      unsigned GraphSize = Gr.getGraphSize();
-      if (MaxGraphSize < GraphSize) MaxGraphSize = GraphSize;
+      if (!IsDuplicateGraph) {
+        unsigned GraphSize = Gr.getGraphSize();
+        if (MaxGraphSize < GraphSize) MaxGraphSize = GraphSize;
 
-      for (DSGraph::node_iterator NI = Gr.node_begin(), E = Gr.node_end();
-           NI != E; ++NI)
-        if (NI->isNodeCompletelyFolded())
-          ++NumFoldedNodes;
+        TotalNumNodes += Gr.getGraphSize();
+        TotalCallNodes += NumCalls;
+        for (DSGraph::node_iterator NI = Gr.node_begin(), E = Gr.node_end();
+             NI != E; ++NI)
+          if (NI->isNodeCompletelyFolded())
+            ++NumFoldedNodes;
+      }
     }
 
   DSGraph &GG = C.getGlobalsGraph();






More information about the llvm-commits mailing list