Eliminate static ctors due to Statistic objects
authorChris Lattner <sabre@nondot.org>
Tue, 19 Dec 2006 22:09:18 +0000 (22:09 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 19 Dec 2006 22:09:18 +0000 (22:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32693 91177308-0d34-0410-b5e6-96231b3b80d8

16 files changed:
lib/Transforms/IPO/ArgumentPromotion.cpp
lib/Transforms/IPO/ConstantMerge.cpp
lib/Transforms/IPO/DeadArgumentElimination.cpp
lib/Transforms/IPO/DeadTypeElimination.cpp
lib/Transforms/IPO/FunctionResolution.cpp
lib/Transforms/IPO/GlobalDCE.cpp
lib/Transforms/IPO/GlobalOpt.cpp
lib/Transforms/IPO/IPConstantPropagation.cpp
lib/Transforms/IPO/IndMemRemoval.cpp
lib/Transforms/IPO/Inliner.cpp
lib/Transforms/IPO/Internalize.cpp
lib/Transforms/IPO/LoopExtractor.cpp
lib/Transforms/IPO/LowerSetJmp.cpp
lib/Transforms/IPO/PruneEH.cpp
lib/Transforms/IPO/RaiseAllocations.cpp
lib/Transforms/IPO/SimplifyLibCalls.cpp

index 2a06310065b1468bba319be85b6c410e4c335a10..ab52baf850a0afbcd8f7d6efb91247526d8172ff 100644 (file)
 #include <set>
 using namespace llvm;
 
-namespace {
-  Statistic NumArgumentsPromoted("argpromotion",
-                                   "Number of pointer arguments promoted");
-  Statistic NumAggregatesPromoted("argpromotion",
-                                    "Number of aggregate arguments promoted");
-  Statistic NumArgumentsDead("argpromotion",
-                               "Number of dead pointer args eliminated");
+STATISTIC(NumArgumentsPromoted , "Number of pointer arguments promoted");
+STATISTIC(NumAggregatesPromoted, "Number of aggregate arguments promoted");
+STATISTIC(NumArgumentsDead     , "Number of dead pointer args eliminated");
 
+namespace {
   /// ArgPromotion - The 'by reference' to 'by value' argument promotion pass.
   ///
   struct ArgPromotion : public CallGraphSCCPass {
index 7ba7b32a7e30cf546138e508c8164292f98d87a9..291653376ed0d081c0dce35ccc1f7bb67a4a4c67 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "constmerge"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Module.h"
 #include "llvm/Pass.h"
 #include "llvm/ADT/Statistic.h"
 using namespace llvm;
 
-namespace {
-  Statistic NumMerged("constmerge", "Number of global constants merged");
+STATISTIC(NumMerged, "Number of global constants merged");
 
+namespace {
   struct ConstantMerge : public ModulePass {
     // run - For this pass, process all of the globals in the module,
     // eliminating duplicate constants.
index dbcc5018906cc140a23ad889e2248c4426e7a611..9d88a8879fcddec8a1411d0e65255164191dca7f 100644 (file)
 #include <set>
 using namespace llvm;
 
-namespace {
-  Statistic NumArgumentsEliminated("deadargelim",
-                                     "Number of unread args removed");
-  Statistic NumRetValsEliminated("deadargelim",
-                                   "Number of unused return values removed");
+STATISTIC(NumArgumentsEliminated, "Number of unread args removed");
+STATISTIC(NumRetValsEliminated  , "Number of unused return values removed");
 
+namespace {
   /// DAE - The dead argument elimination pass.
   ///
   class DAE : public ModulePass {
index e30e0ed38c4c92da69d89526ffdba1624cb6f6d3..8199f746a2b04c49d0f5fb174b6eefa276ffcf54 100644 (file)
@@ -12,6 +12,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "deadtypeelim"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Analysis/FindUsedTypes.h"
 #include "llvm/Module.h"
@@ -20,6 +21,8 @@
 #include "llvm/ADT/Statistic.h"
 using namespace llvm;
 
+STATISTIC(NumKilled, "Number of unused typenames removed from symtab");
+
 namespace {
   struct DTE : public ModulePass {
     // doPassInitialization - For this pass, it removes global symbol table
@@ -37,8 +40,6 @@ namespace {
     }
   };
   RegisterPass<DTE> X("deadtypeelim", "Dead Type Elimination");
-  Statistic
-  NumKilled("deadtypeelim", "Number of unused typenames removed from symtab");
 }
 
 ModulePass *llvm::createDeadTypeEliminationPass() {
index 6f1eea0276730e0685b7446d92a16552abc30232..2ffbc7b9ae8c9c559741fa0391ada16130b00132 100644 (file)
@@ -18,6 +18,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "funcresolve"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Module.h"
 #include "llvm/DerivedTypes.h"
 #include <algorithm>
 using namespace llvm;
 
-namespace {
-  Statistic NumResolved("funcresolve", "Number of varargs functions resolved");
-  Statistic NumGlobals("funcresolve", "Number of global variables resolved");
+STATISTIC(NumResolved, "Number of varargs functions resolved");
+STATISTIC(NumGlobals, "Number of global variables resolved");
 
+namespace {
   struct FunctionResolvingPass : public ModulePass {
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.addRequired<TargetData>();
index ac23760bf20183def828d0abcf9a6d2199e42b13..17dcb31859c9251b025de3c00e4836e8409a67c6 100644 (file)
@@ -15,6 +15,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "globaldce"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Constants.h"
 #include "llvm/Module.h"
 #include <set>
 using namespace llvm;
 
-namespace {
-  Statistic NumFunctions("globaldce","Number of functions removed");
-  Statistic NumVariables("globaldce","Number of global variables removed");
+STATISTIC(NumFunctions, "Number of functions removed");
+STATISTIC(NumVariables, "Number of global variables removed");
 
+namespace {
   struct GlobalDCE : public ModulePass {
     // run - Do the GlobalDCE pass on the specified module, optionally updating
     // the specified callgraph to reflect the changes.
index cf9cdaa74447e6d8e66703244331037c6c5300ed..425bcc588bdfbe8a0d1ed0c0128598cc7699aea9 100644 (file)
 #include <set>
 using namespace llvm;
 
-namespace {
-  Statistic NumMarked   ("globalopt", "Number of globals marked constant");
-  Statistic NumSRA      ("globalopt", "Number of aggregate globals broken "
-                           "into scalars");
-  Statistic NumHeapSRA  ("globalopt", "Number of heap objects SRA'd");
-  Statistic NumSubstitute("globalopt",
-                        "Number of globals with initializers stored into them");
-  Statistic NumDeleted  ("globalopt", "Number of globals deleted");
-  Statistic NumFnDeleted("globalopt", "Number of functions deleted");
-  Statistic NumGlobUses ("globalopt", "Number of global uses devirtualized");
-  Statistic NumLocalized("globalopt", "Number of globals localized");
-  Statistic NumShrunkToBool("globalopt",
-                              "Number of global vars shrunk to booleans");
-  Statistic NumFastCallFns("globalopt",
-                             "Number of functions converted to fastcc");
-  Statistic NumCtorsEvaluated("globalopt","Number of static ctors evaluated");
+STATISTIC(NumMarked    , "Number of globals marked constant");
+STATISTIC(NumSRA       , "Number of aggregate globals broken into scalars");
+STATISTIC(NumHeapSRA   , "Number of heap objects SRA'd");
+STATISTIC(NumSubstitute,"Number of globals with initializers stored into them");
+STATISTIC(NumDeleted   , "Number of globals deleted");
+STATISTIC(NumFnDeleted , "Number of functions deleted");
+STATISTIC(NumGlobUses  , "Number of global uses devirtualized");
+STATISTIC(NumLocalized , "Number of globals localized");
+STATISTIC(NumShrunkToBool  , "Number of global vars shrunk to booleans");
+STATISTIC(NumFastCallFns   , "Number of functions converted to fastcc");
+STATISTIC(NumCtorsEvaluated, "Number of static ctors evaluated");
 
+namespace {
   struct GlobalOpt : public ModulePass {
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.addRequired<TargetData>();
index 3f673ae85ead6ae313dc1f5c8aa8ce32432162a4..be18f002e8cb28f28f4dc1fb6e857575143a570f 100644 (file)
@@ -15,6 +15,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "ipconstprop"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Constants.h"
 #include "llvm/Instructions.h"
 #include "llvm/ADT/Statistic.h"
 using namespace llvm;
 
-namespace {
-  Statistic NumArgumentsProped("ipconstprop",
-                                 "Number of args turned into constants");
-  Statistic NumReturnValProped("ipconstprop",
-                              "Number of return values turned into constants");
+STATISTIC(NumArgumentsProped, "Number of args turned into constants");
+STATISTIC(NumReturnValProped, "Number of return values turned into constants");
 
+namespace {
   /// IPCP - The interprocedural constant propagation pass
   ///
   struct IPCP : public ModulePass {
index 9ad25dd9fa0714f4f4af089906dc2983fb396a89..82aa992a09c51b0765634bc3f53e67206185d699 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "indmemrem"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Pass.h"
 #include "llvm/Module.h"
-#include "llvm/Function.h"
 #include "llvm/Instructions.h"
 #include "llvm/Type.h"
-#include "llvm/Support/Debug.h"
 #include "llvm/ADT/Statistic.h"
-#include <fstream>
-#include <set>
 using namespace llvm;
 
-namespace {
-  Statistic NumBounceSites("indmemrem", "Number of sites modified");
-  Statistic NumBounce  ("indmemrem", "Number of bounce functions created");
+STATISTIC(NumBounceSites, "Number of sites modified");
+STATISTIC(NumBounce     , "Number of bounce functions created");
 
+namespace {
   class IndMemRemPass : public ModulePass {
-
   public:
-    IndMemRemPass();
     virtual bool runOnModule(Module &M);
   };
   RegisterPass<IndMemRemPass> X("indmemrem","Indirect Malloc and Free Removal");
 } // end anonymous namespace
 
 
-IndMemRemPass::IndMemRemPass()
-{
-}
-
 bool IndMemRemPass::runOnModule(Module &M) {
   //in Theory, all direct calls of malloc and free should be promoted
   //to intrinsics.  Therefor, this goes through and finds where the
index bd5fb98416d3399d9025c5e0228e9947297da6cc..27dbf8ba50fd3e1f292efb3b89b527e9636bdb38 100644 (file)
@@ -13,6 +13,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "inline"
 #include "Inliner.h"
 #include "llvm/Module.h"
 #include "llvm/Instructions.h"
 #include <set>
 using namespace llvm;
 
+STATISTIC(NumInlined, "Number of functions inlined");
+STATISTIC(NumDeleted, "Number of functions deleted because all callers found");
+
 namespace {
-  Statistic NumInlined("inline", "Number of functions inlined");
-  Statistic NumDeleted("inline",
-                       "Number of functions deleted because all callers found");
   cl::opt<unsigned>             // FIXME: 200 is VERY conservative
   InlineLimit("inline-threshold", cl::Hidden, cl::init(200),
         cl::desc("Control the amount of inlining to perform (default = 200)"));
index f43a27f6984d89d84364cdedf3f23ad22e432a68..bf99235fb8b00b1057777894ca60aa6388ac91ef 100644 (file)
@@ -13,6 +13,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "internalize"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Pass.h"
 #include "llvm/Module.h"
 #include <set>
 using namespace llvm;
 
+STATISTIC(NumFunctions, "Number of functions internalized");
+STATISTIC(NumGlobals  , "Number of global vars internalized");
+
 namespace {
-  Statistic NumFunctions("internalize", "Number of functions internalized");
-  Statistic NumGlobals  ("internalize", "Number of global vars internalized");
 
   // APIFile - A file which contains a list of symbols that should not be marked
   // external.
index f77f9f32576fb2034a63ee2895d7181543fdc2cf..5a6e7671d1b9cf3b452f4b6810c2d0ca271b637d 100644 (file)
@@ -14,6 +14,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "loop-extract"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Instructions.h"
 #include "llvm/Module.h"
@@ -25,9 +26,9 @@
 #include "llvm/ADT/Statistic.h"
 using namespace llvm;
 
-namespace {
-  Statistic NumExtracted("loop-extract", "Number of loops extracted");
+STATISTIC(NumExtracted, "Number of loops extracted");
 
+namespace {
   // FIXME: This is not a function pass, but the PassManager doesn't allow
   // Module passes to require FunctionPasses, so we can't get loop info if we're
   // not a function pass.
index 0417a5cc2749c373447675df231c85d27a35438b..d7f22fb9cb75d5ff2cbb89335a244e32ea10cf32 100644 (file)
@@ -33,6 +33,7 @@
 // pass invokable via the "opt" command at will.
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "lowersetjmp"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/ADT/VectorExtras.h"
 using namespace llvm;
 
-namespace {
-  Statistic LongJmpsTransformed("lowersetjmp",
-                                  "Number of longjmps transformed");
-  Statistic SetJmpsTransformed("lowersetjmp",
-                                 "Number of setjmps transformed");
-  Statistic CallsTransformed("lowersetjmp",
-                               "Number of calls invokified");
-  Statistic InvokesTransformed("lowersetjmp",
-                                 "Number of invokes modified");
+STATISTIC(LongJmpsTransformed, "Number of longjmps transformed");
+STATISTIC(SetJmpsTransformed , "Number of setjmps transformed");
+STATISTIC(CallsTransformed   , "Number of calls invokified");
+STATISTIC(InvokesTransformed , "Number of invokes modified");
 
+namespace {
   //===--------------------------------------------------------------------===//
   // LowerSetJmp pass implementation.
   class LowerSetJmp : public ModulePass,
index 1dec7d70470d5ae68e7658698faeb9def69715eb..14daf13ecde8cabeeb0fd4cb9a9727b1da0c9c6f 100644 (file)
@@ -14,6 +14,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "prune-eh"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/CallGraphSCCPass.h"
 #include "llvm/Constants.h"
 #include <algorithm>
 using namespace llvm;
 
-namespace {
-  Statistic NumRemoved("prune-eh", "Number of invokes removed");
-  Statistic NumUnreach("prune-eh", "Number of noreturn calls optimized");
+STATISTIC(NumRemoved, "Number of invokes removed");
+STATISTIC(NumUnreach, "Number of noreturn calls optimized");
 
+namespace {
   struct PruneEH : public CallGraphSCCPass {
     /// DoesNotUnwind - This set contains all of the functions which we have
     /// determined cannot unwind.
index 46c6815994f7af9c67c30a21e2bd427b938f06b9..58f0d1b0a3049cc5d63b3d6a34121d242f9d8b46 100644 (file)
@@ -12,6 +12,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "raiseallocs"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
@@ -22,9 +23,9 @@
 #include "llvm/ADT/Statistic.h"
 using namespace llvm;
 
-namespace {
-  Statistic NumRaised("raiseallocs", "Number of allocations raised");
+STATISTIC(NumRaised, "Number of allocations raised");
 
+namespace {
   // RaiseAllocations - Turn %malloc and %free calls into the appropriate
   // instruction.
   //
index 2c3b66600b6f89aae5a4e3476b72793c8574f726..08ae1994a6ef369013e3ed20adb53a80d04cbdc7 100644 (file)
 #include "llvm/Transforms/IPO.h"
 using namespace llvm;
 
-namespace {
-
 /// This statistic keeps track of the total number of library calls that have
 /// been simplified regardless of which call it is.
-Statistic SimplifiedLibCalls("simplify-libcalls",
-  "Number of library calls simplified");
-
-// Forward declarations
-class LibCallOptimization;
-class SimplifyLibCalls;
+STATISTIC(SimplifiedLibCalls, "Number of library calls simplified");
 
+namespace {
+  // Forward declarations
+  class LibCallOptimization;
+  class SimplifyLibCalls;
+  
 /// This list is populated by the constructor for LibCallOptimization class.
 /// Therefore all subclasses are registered here at static initialization time
 /// and this list is what the SimplifyLibCalls pass uses to apply the individual