[llvm-commits] CVS: llvm/lib/Transforms/IPO/ConstantMerge.cpp DeadTypeElimination.cpp FunctionResolution.cpp GlobalDCE.cpp Internalize.cpp MutateStructTypes.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Oct 1 17:39:03 PDT 2002


Changes in directory llvm/lib/Transforms/IPO:

ConstantMerge.cpp updated: 1.16 -> 1.17
DeadTypeElimination.cpp updated: 1.40 -> 1.41
FunctionResolution.cpp updated: 1.11 -> 1.12
GlobalDCE.cpp updated: 1.21 -> 1.22
Internalize.cpp updated: 1.9 -> 1.10
MutateStructTypes.cpp updated: 1.30 -> 1.31

---
Log message:

Updates to work with recent Statistic's changes:

    * Renamed StatisticReporter.h/cpp to Statistic.h/cpp
    * Broke constructor to take two const char * arguments instead of one, so
      that indendation can be taken care of automatically.
    * Sort the list by pass name when printing
    * Make sure to print all statistics as a group, instead of randomly when
      the statistics dtors are called.
    * Updated ProgrammersManual with new semantics.



---
Diffs of the changes:

Index: llvm/lib/Transforms/IPO/ConstantMerge.cpp
diff -u llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.16 llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.17
--- llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.16	Mon Sep 23 18:00:46 2002
+++ llvm/lib/Transforms/IPO/ConstantMerge.cpp	Tue Oct  1 17:38:35 2002
@@ -14,7 +14,7 @@
 #include "llvm/Module.h"
 #include "llvm/Constants.h"
 #include "llvm/Pass.h"
-#include "Support/StatisticReporter.h"
+#include "Support/Statistic.h"
 
 namespace {
   struct ConstantMerge : public Pass {
@@ -28,7 +28,7 @@
     void replaceConstantWith(Constant *Old, Constant *New);
   };
 
-  Statistic<> NumMerged("constmerge\t\t- Number of global constants merged");
+  Statistic<> NumMerged("constmerge", "Number of global constants merged");
   RegisterOpt<ConstantMerge> X("constmerge","Merge Duplicate Global Constants");
 }
 


Index: llvm/lib/Transforms/IPO/DeadTypeElimination.cpp
diff -u llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.40 llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.41
--- llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.40	Sun Sep  8 16:47:54 2002
+++ llvm/lib/Transforms/IPO/DeadTypeElimination.cpp	Tue Oct  1 17:38:36 2002
@@ -10,7 +10,7 @@
 #include "llvm/Module.h"
 #include "llvm/SymbolTable.h"
 #include "llvm/DerivedTypes.h"
-#include "Support/StatisticReporter.h"
+#include "Support/Statistic.h"
 
 using std::vector;
 
@@ -31,7 +31,8 @@
     }
   };
   RegisterOpt<DTE> X("deadtypeelim", "Dead Type Elimination");
-  Statistic<> NumKilled("deadtypeelim\t- Number of unused typenames removed from symtab");
+  Statistic<>
+  NumKilled("deadtypeelim", "Number of unused typenames removed from symtab");
 }
 
 Pass *createDeadTypeEliminationPass() {


Index: llvm/lib/Transforms/IPO/FunctionResolution.cpp
diff -u llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.11 llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.12
--- llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.11	Tue Sep 10 12:02:57 2002
+++ llvm/lib/Transforms/IPO/FunctionResolution.cpp	Tue Oct  1 17:38:36 2002
@@ -18,7 +18,7 @@
 #include "llvm/Pass.h"
 #include "llvm/iOther.h"
 #include "llvm/Constant.h"
-#include "Support/StatisticReporter.h"
+#include "Support/Statistic.h"
 #include <algorithm>
 
 using std::vector;
@@ -26,7 +26,7 @@
 using std::cerr;
 
 namespace {
-  Statistic<>NumResolved("funcresolve\t- Number of varargs functions resolved");
+  Statistic<>NumResolved("funcresolve", "Number of varargs functions resolved");
 
   struct FunctionResolvingPass : public Pass {
     bool run(Module &M);


Index: llvm/lib/Transforms/IPO/GlobalDCE.cpp
diff -u llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.21 llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.22
--- llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.21	Sat Aug 17 20:28:30 2002
+++ llvm/lib/Transforms/IPO/GlobalDCE.cpp	Tue Oct  1 17:38:36 2002
@@ -9,54 +9,53 @@
 #include "llvm/Module.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
-#include "llvm/GlobalVariable.h"
 #include "llvm/Analysis/CallGraph.h"
 #include "Support/DepthFirstIterator.h"
-#include "Support/StatisticReporter.h"
+#include "Support/Statistic.h"
 #include <algorithm>
 
-static Statistic<> NumFunctions("globaldce\t- Number of functions removed");
-static Statistic<> NumVariables("globaldce\t- Number of global variables removed");
-static Statistic<> NumCPRs("globaldce\t- Number of const pointer refs removed");
-static Statistic<> NumConsts("globaldce\t- Number of init constants removed");
-
-static bool RemoveUnreachableFunctions(Module &M, CallGraph &CallGraph) {
-  // Calculate which functions are reachable from the external functions in the
-  // call graph.
-  //
-  std::set<CallGraphNode*> ReachableNodes(df_begin(&CallGraph),
-                                          df_end(&CallGraph));
-
-  // Loop over the functions in the module twice.  The first time is used to
-  // drop references that functions have to each other before they are deleted.
-  // The second pass removes the functions that need to be removed.
-  //
-  std::vector<CallGraphNode*> FunctionsToDelete;   // Track unused functions
-  for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
-    CallGraphNode *N = CallGraph[I];
-
-    if (!ReachableNodes.count(N)) {              // Not reachable??
-      I->dropAllReferences();
-      N->removeAllCalledFunctions();
-      FunctionsToDelete.push_back(N);
-      ++NumFunctions;
+namespace {
+  Statistic<> NumFunctions("globaldce","Number of functions removed");
+  Statistic<> NumVariables("globaldce","Number of global variables removed");
+  Statistic<> NumCPRs("globaldce", "Number of const pointer refs removed");
+  Statistic<> NumConsts("globaldce", "Number of init constants removed");
+
+  bool RemoveUnreachableFunctions(Module &M, CallGraph &CallGraph) {
+    // Calculate which functions are reachable from the external functions in
+    // the call graph.
+    //
+    std::set<CallGraphNode*> ReachableNodes(df_begin(&CallGraph),
+                                            df_end(&CallGraph));
+
+    // Loop over the functions in the module twice.  The first time is used to
+    // drop references that functions have to each other before they are
+    // deleted.  The second pass removes the functions that need to be removed.
+    //
+    std::vector<CallGraphNode*> FunctionsToDelete;   // Track unused functions
+    for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
+      CallGraphNode *N = CallGraph[I];
+      
+      if (!ReachableNodes.count(N)) {              // Not reachable??
+        I->dropAllReferences();
+        N->removeAllCalledFunctions();
+        FunctionsToDelete.push_back(N);
+        ++NumFunctions;
+      }
     }
+    
+    // Nothing to do if no unreachable functions have been found...
+    if (FunctionsToDelete.empty()) return false;
+    
+    // Unreachables functions have been found and should have no references to
+    // them, delete them now.
+    //
+    for (std::vector<CallGraphNode*>::iterator I = FunctionsToDelete.begin(),
+           E = FunctionsToDelete.end(); I != E; ++I)
+      delete CallGraph.removeFunctionFromModule(*I);
+    
+    return true;
   }
-
-  // Nothing to do if no unreachable functions have been found...
-  if (FunctionsToDelete.empty()) return false;
-
-  // Unreachables functions have been found and should have no references to
-  // them, delete them now.
-  //
-  for (std::vector<CallGraphNode*>::iterator I = FunctionsToDelete.begin(),
-	 E = FunctionsToDelete.end(); I != E; ++I)
-    delete CallGraph.removeFunctionFromModule(*I);
-
-  return true;
-}
-
-namespace {
+  
   struct GlobalDCE : public Pass {
     // run - Do the GlobalDCE pass on the specified module, optionally updating
     // the specified callgraph to reflect the changes.


Index: llvm/lib/Transforms/IPO/Internalize.cpp
diff -u llvm/lib/Transforms/IPO/Internalize.cpp:1.9 llvm/lib/Transforms/IPO/Internalize.cpp:1.10
--- llvm/lib/Transforms/IPO/Internalize.cpp:1.9	Tue Jul 30 14:48:44 2002
+++ llvm/lib/Transforms/IPO/Internalize.cpp	Tue Oct  1 17:38:36 2002
@@ -9,12 +9,11 @@
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Pass.h"
 #include "llvm/Module.h"
-#include "Support/StatisticReporter.h"
+#include "Support/Statistic.h"
 
 namespace {
-  Statistic<> NumFunctions("internalize\t- Number of functions internalized");
-  Statistic<> NumGlobals  ("internalize\t- Number of global vars internalized");
-
+  Statistic<> NumFunctions("internalize", "Number of functions internalized");
+  Statistic<> NumGlobals  ("internalize", "Number of global vars internalized");
 
   class InternalizePass : public Pass {
     virtual bool run(Module &M) {


Index: llvm/lib/Transforms/IPO/MutateStructTypes.cpp
diff -u llvm/lib/Transforms/IPO/MutateStructTypes.cpp:1.30 llvm/lib/Transforms/IPO/MutateStructTypes.cpp:1.31
--- llvm/lib/Transforms/IPO/MutateStructTypes.cpp:1.30	Fri Sep 13 21:06:53 2002
+++ llvm/lib/Transforms/IPO/MutateStructTypes.cpp	Tue Oct  1 17:38:36 2002
@@ -19,12 +19,11 @@
 #include "llvm/iMemory.h"
 #include "llvm/iTerminators.h"
 #include "llvm/iOther.h"
-#include "llvm/Argument.h"
 #include "llvm/Constants.h"
 #include "Support/STLExtras.h"
-#include "Support/StatisticReporter.h"
+#include "Support/Statistic.h"
 #include <algorithm>
-#include <iostream>
+
 using std::map;
 using std::vector;
 





More information about the llvm-commits mailing list