Switch over Transforms/Scalar to use the STATISTIC macro. For each statistic
authorChris Lattner <sabre@nondot.org>
Tue, 19 Dec 2006 21:40:18 +0000 (21:40 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 19 Dec 2006 21:40:18 +0000 (21:40 +0000)
converted, we lose a static initializer.  This also allows GCC to emit warnings
about unused statistics.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32690 91177308-0d34-0410-b5e6-96231b3b80d8

21 files changed:
lib/Transforms/Scalar/ADCE.cpp
lib/Transforms/Scalar/BasicBlockPlacement.cpp
lib/Transforms/Scalar/CondPropagate.cpp
lib/Transforms/Scalar/ConstantProp.cpp
lib/Transforms/Scalar/CorrelatedExprs.cpp
lib/Transforms/Scalar/DCE.cpp
lib/Transforms/Scalar/DeadStoreElimination.cpp
lib/Transforms/Scalar/GCSE.cpp
lib/Transforms/Scalar/IndVarSimplify.cpp
lib/Transforms/Scalar/InstructionCombining.cpp
lib/Transforms/Scalar/LICM.cpp
lib/Transforms/Scalar/LoopStrengthReduce.cpp
lib/Transforms/Scalar/LoopUnroll.cpp
lib/Transforms/Scalar/LoopUnswitch.cpp
lib/Transforms/Scalar/Reassociate.cpp
lib/Transforms/Scalar/Reg2Mem.cpp
lib/Transforms/Scalar/SCCP.cpp
lib/Transforms/Scalar/ScalarReplAggregates.cpp
lib/Transforms/Scalar/SimplifyCFG.cpp
lib/Transforms/Scalar/TailDuplication.cpp
lib/Transforms/Scalar/TailRecursionElimination.cpp

index 536b61f10808f9b7b59dff02e929723e1e8df5fd..825c7815362b65663a6d538f9acf4e2159143d6a 100644 (file)
@@ -13,6 +13,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "adce"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Constants.h"
 #include "llvm/Instructions.h"
 #include <algorithm>
 using namespace llvm;
 
-namespace {
-  Statistic NumBlockRemoved("adce", "Number of basic blocks removed");
-  Statistic NumInstRemoved ("adce", "Number of instructions removed");
-  Statistic NumCallRemoved ("adce", "Number of calls and invokes removed");
+STATISTIC(NumBlockRemoved, "Number of basic blocks removed");
+STATISTIC(NumInstRemoved , "Number of instructions removed");
+STATISTIC(NumCallRemoved , "Number of calls and invokes removed");
 
+namespace {
 //===----------------------------------------------------------------------===//
 // ADCE Class
 //
index 135d6b31d37c5669ff30723e3ad2b813e07fa6e0..020b2b2c52e543261522240660cfd62109febff0 100644 (file)
@@ -26,6 +26,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "block-placement"
 #include "llvm/Analysis/ProfileInfo.h"
 #include "llvm/Function.h"
 #include "llvm/Pass.h"
@@ -35,9 +36,9 @@
 #include <set>
 using namespace llvm;
 
-namespace {
-  Statistic NumMoved("block-placement", "Number of basic blocks moved");
+STATISTIC(NumMoved, "Number of basic blocks moved");
 
+namespace {
   struct BlockPlacement : public FunctionPass {
     virtual bool runOnFunction(Function &F);
 
index 4e076145f7621623ec9aed13e42877c2f194a289..49a849625b39949980f24f619b33b3ae9af7a6a7 100644 (file)
 #include "llvm/Support/Streams.h"
 using namespace llvm;
 
-namespace {
-  Statistic
-  NumBrThread("condprop", "Number of CFG edges threaded through branches");
-  Statistic
-  NumSwThread("condprop", "Number of CFG edges threaded through switches");
+STATISTIC(NumBrThread, "Number of CFG edges threaded through branches");
+STATISTIC(NumSwThread, "Number of CFG edges threaded through switches");
 
+namespace {
   struct CondProp : public FunctionPass {
     virtual bool runOnFunction(Function &F);
 
index 54ccccce7c116b7377bf2e09824a2d9f8a718696..d888a10c727f4453b5aba017bd92ee160728b040 100644 (file)
@@ -18,6 +18,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "constprop"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Constant.h"
@@ -28,9 +29,9 @@
 #include <set>
 using namespace llvm;
 
-namespace {
-  Statistic NumInstKilled("constprop", "Number of instructions killed");
+STATISTIC(NumInstKilled, "Number of instructions killed");
 
+namespace {
   struct ConstantPropagation : public FunctionPass {
     bool runOnFunction(Function &F);
 
index a796ff742eba071e89012f60aef36890c347a244..7ab999f9638ce85786210855f0df15f843c9f614 100644 (file)
@@ -26,6 +26,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "cee"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Constants.h"
 #include "llvm/Pass.h"
 #include <algorithm>
 using namespace llvm;
 
-namespace {
-  Statistic NumSetCCRemoved("cee", "Number of setcc instruction eliminated");
-  Statistic NumOperandsCann("cee", "Number of operands canonicalized");
-  Statistic BranchRevectors("cee", "Number of branches revectored");
+STATISTIC(NumSetCCRemoved, "Number of setcc instruction eliminated");
+STATISTIC(NumOperandsCann, "Number of operands canonicalized");
+STATISTIC(BranchRevectors, "Number of branches revectored");
 
+namespace {
   class ValueInfo;
   class Relation {
     Value *Val;                 // Relation to what value?
index 3304527d1eb3ae02ccd0285b69eacf4cf98316cf..cf1a7fc877d83844da71a95b4cc65deba7c405d9 100644 (file)
@@ -16,6 +16,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "dce"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Instruction.h"
 #include <set>
 using namespace llvm;
 
-namespace {
-  Statistic DIEEliminated("die", "Number of insts removed");
-  Statistic DCEEliminated("dce", "Number of insts removed");
+STATISTIC(DIEEliminated, "Number of insts removed by DIE pass");
+STATISTIC(DCEEliminated, "Number of insts removed");
 
+namespace {
   //===--------------------------------------------------------------------===//
   // DeadInstElimination pass implementation
   //
-
   struct DeadInstElimination : public BasicBlockPass {
     virtual bool runOnBasicBlock(BasicBlock &BB) {
       bool Changed = false;
@@ -58,11 +58,10 @@ FunctionPass *llvm::createDeadInstEliminationPass() {
 }
 
 
-//===----------------------------------------------------------------------===//
-// DeadCodeElimination pass implementation
-//
-
 namespace {
+  //===--------------------------------------------------------------------===//
+  // DeadCodeElimination pass implementation
+  //
   struct DCE : public FunctionPass {
     virtual bool runOnFunction(Function &F);
 
index 8057ebdc7273d10b99dc6b2172d89fc7ffa79e23..39f2506c1636866820de3bfdd5c08ce293e5e7d7 100644 (file)
@@ -15,6 +15,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "dse"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Function.h"
 #include "llvm/ADT/Statistic.h"
 using namespace llvm;
 
-namespace {
-  Statistic NumStores("dse", "Number of stores deleted");
-  Statistic NumOther ("dse", "Number of other instrs removed");
+STATISTIC(NumStores, "Number of stores deleted");
+STATISTIC(NumOther , "Number of other instrs removed");
 
+namespace {
   struct DSE : public FunctionPass {
 
     virtual bool runOnFunction(Function &F) {
index a6d57ce26b8aee6f3df041a380e87e92d67da337..80b9ae73a2b2ca336cc77c50dce5e74b442c6e2c 100644 (file)
@@ -14,6 +14,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "gcse"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Constant.h"
 #include <algorithm>
 using namespace llvm;
 
+STATISTIC(NumInstRemoved, "Number of instructions removed");
+STATISTIC(NumLoadRemoved, "Number of loads removed");
+STATISTIC(NumCallRemoved, "Number of calls removed");
+STATISTIC(NumNonInsts   , "Number of instructions removed due "
+                          "to non-instruction values");
+STATISTIC(NumArgsRepl   , "Number of function arguments replaced "
+                          "with constant values");
 namespace {
-  Statistic NumInstRemoved("gcse", "Number of instructions removed");
-  Statistic NumLoadRemoved("gcse", "Number of loads removed");
-  Statistic NumCallRemoved("gcse", "Number of calls removed");
-  Statistic NumNonInsts   ("gcse", "Number of instructions removed due "
-                             "to non-instruction values");
-  Statistic NumArgsRepl   ("gcse", "Number of function arguments replaced "
-                             "with constant values");
-
   struct GCSE : public FunctionPass {
     virtual bool runOnFunction(Function &F);
 
index e17faa1d37cf3cb40c8ce33831cbef757dadd936..91759dc9b5817fab7c150a07ea07a9265d60bcd4 100644 (file)
@@ -37,6 +37,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "indvars"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Constants.h"
 #include "llvm/ADT/Statistic.h"
 using namespace llvm;
 
-namespace {
-  Statistic NumRemoved ("indvars", "Number of aux indvars removed");
-  Statistic NumPointer ("indvars", "Number of pointer indvars promoted");
-  Statistic NumInserted("indvars", "Number of canonical indvars added");
-  Statistic NumReplaced("indvars", "Number of exit values replaced");
-  Statistic NumLFTR    ("indvars", "Number of loop exit tests replaced");
+STATISTIC(NumRemoved , "Number of aux indvars removed");
+STATISTIC(NumPointer , "Number of pointer indvars promoted");
+STATISTIC(NumInserted, "Number of canonical indvars added");
+STATISTIC(NumReplaced, "Number of exit values replaced");
+STATISTIC(NumLFTR    , "Number of loop exit tests replaced");
 
+namespace {
   class IndVarSimplify : public FunctionPass {
     LoopInfo        *LI;
     ScalarEvolution *SE;
index 66c57a9bac844add47ae7621fdf6be38fa9b0bc1..8b6f3703b05e951a4cf318b246ef351373f26979 100644 (file)
 using namespace llvm;
 using namespace llvm::PatternMatch;
 
-namespace {
-  Statistic NumCombined ("instcombine", "Number of insts combined");
-  Statistic NumConstProp("instcombine", "Number of constant folds");
-  Statistic NumDeadInst ("instcombine", "Number of dead inst eliminated");
-  Statistic NumDeadStore("instcombine", "Number of dead stores eliminated");
-  Statistic NumSunkInst ("instcombine", "Number of instructions sunk");
+STATISTIC(NumCombined , "Number of insts combined");
+STATISTIC(NumConstProp, "Number of constant folds");
+STATISTIC(NumDeadInst , "Number of dead inst eliminated");
+STATISTIC(NumDeadStore, "Number of dead stores eliminated");
+STATISTIC(NumSunkInst , "Number of instructions sunk");
 
+namespace {
   class VISIBILITY_HIDDEN InstCombiner
     : public FunctionPass,
       public InstVisitor<InstCombiner, Instruction*> {
index 4783388f3dc42a31710cbffe236464212db968c0..40f341cdb4d5317fd60f30f0cd089251a148fcd0 100644 (file)
 #include <algorithm>
 using namespace llvm;
 
+STATISTIC(NumSunk      , "Number of instructions sunk out of loop");
+STATISTIC(NumHoisted   , "Number of instructions hoisted out of loop");
+STATISTIC(NumMovedLoads, "Number of load insts hoisted or sunk");
+STATISTIC(NumMovedCalls, "Number of call insts hoisted or sunk");
+STATISTIC(NumPromoted  , "Number of memory locations promoted to registers");
+
 namespace {
   cl::opt<bool>
   DisablePromotion("disable-licm-promotion", cl::Hidden,
                    cl::desc("Disable memory promotion in LICM pass"));
 
-  Statistic NumSunk("licm", "Number of instructions sunk out of loop");
-  Statistic NumHoisted("licm", "Number of instructions hoisted out of loop");
-  Statistic NumMovedLoads("licm", "Number of load insts hoisted or sunk");
-  Statistic NumMovedCalls("licm", "Number of call insts hoisted or sunk");
-  Statistic NumPromoted("licm",
-                          "Number of memory locations promoted to registers");
-
   struct LICM : public FunctionPass {
     virtual bool runOnFunction(Function &F);
 
index 9426aa1a69dc3f6090dc18245179971bcc1b5a86..eb58b9e052ceac0dbc9c6dc27cf6774b18a8a154 100644 (file)
 #include <set>
 using namespace llvm;
 
-namespace {
-  Statistic NumReduced ("loop-reduce", "Number of GEPs strength reduced");
-  Statistic NumInserted("loop-reduce", "Number of PHIs inserted");
-  Statistic NumVariable("loop-reduce","Number of PHIs with variable strides");
+STATISTIC(NumReduced , "Number of GEPs strength reduced");
+STATISTIC(NumInserted, "Number of PHIs inserted");
+STATISTIC(NumVariable, "Number of PHIs with variable strides");
 
+namespace {
   /// IVStrideUse - Keep track of one use of a strided induction variable, where
   /// the stride is stored externally.  The Offset member keeps track of the 
   /// offset from the IV, User is the actual user of the operand, and 'Operand'
index 45a48994174b3c1f15976ee80447ea24c4002d96..603ba6adbb577bea88019f7f83525667f313ec45 100644 (file)
@@ -36,9 +36,9 @@
 #include <algorithm>
 using namespace llvm;
 
-namespace {
-  Statistic NumUnrolled("loop-unroll", "Number of loops completely unrolled");
+STATISTIC(NumUnrolled, "Number of loops completely unrolled");
 
+namespace {
   cl::opt<unsigned>
   UnrollThreshold("unroll-threshold", cl::init(100), cl::Hidden,
                   cl::desc("The cut-off point for loop unrolling"));
index 3079ce92b55ca05413726caff6d0b016a9a0f8c6..e1d4a33e71ebdd7512d395055d3ed942e3152121 100644 (file)
 #include <set>
 using namespace llvm;
 
+STATISTIC(NumBranches, "Number of branches unswitched");
+STATISTIC(NumSwitches, "Number of switches unswitched");
+STATISTIC(NumSelects , "Number of selects unswitched");
+STATISTIC(NumTrivial , "Number of unswitches that are trivial");
+STATISTIC(NumSimplify, "Number of simplifications of unswitched code");
+
 namespace {
-  Statistic NumBranches("loop-unswitch", "Number of branches unswitched");
-  Statistic NumSwitches("loop-unswitch", "Number of switches unswitched");
-  Statistic NumSelects ("loop-unswitch", "Number of selects unswitched");
-  Statistic NumTrivial ("loop-unswitch",
-                          "Number of unswitches that are trivial");
-  Statistic NumSimplify("loop-unswitch", 
-                          "Number of simplifications of unswitched code");
   cl::opt<unsigned>
   Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"),
             cl::init(10), cl::Hidden);
index 196cd3854a099a6d28641f30f62faebc35bd6ce1..69805f86bae5d890949784943a759f09bca87cbe 100644 (file)
 #include <algorithm>
 using namespace llvm;
 
-namespace {
-  Statistic NumLinear ("reassociate","Number of insts linearized");
-  Statistic NumChanged("reassociate","Number of insts reassociated");
-  Statistic NumSwapped("reassociate","Number of insts with operands swapped");
-  Statistic NumAnnihil("reassociate","Number of expr tree annihilated");
-  Statistic NumFactor ("reassociate","Number of multiplies factored");
+STATISTIC(NumLinear , "Number of insts linearized");
+STATISTIC(NumChanged, "Number of insts reassociated");
+STATISTIC(NumAnnihil, "Number of expr tree annihilated");
+STATISTIC(NumFactor , "Number of multiplies factored");
 
+namespace {
   struct ValueEntry {
     unsigned Rank;
     Value *Op;
index d43e5b33abc8befa9dad57aa57b67c5f5f2b5934..ee4a228dd1b28577ad3a9637353aa2592249716c 100644 (file)
@@ -16,6 +16,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "reg2mem"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Pass.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Instructions.h"
 #include "llvm/ADT/Statistic.h"
-
 #include <list>
-
 using namespace llvm;
 
+STATISTIC(NumDemoted, "Number of registers demoted");
+
 namespace {
-  Statistic NumDemoted("reg2mem", "Number of registers demoted");
-  
   struct RegToMem : public FunctionPass {
 
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
index 4f0607ef2944daaab5f3c7e0930ba2a227606f89..aa7c7833cfa67635b6940c8e9d1f62e68c88eef0 100644 (file)
 #include <set>
 using namespace llvm;
 
+STATISTIC(NumInstRemoved, "Number of instructions removed");
+STATISTIC(NumDeadBlocks , "Number of basic blocks unreachable");
+
+STATISTIC(IPNumInstRemoved, "Number ofinstructions removed by IPSCCP");
+STATISTIC(IPNumDeadBlocks , "Number of basic blocks unreachable by IPSCCP");
+STATISTIC(IPNumArgsElimed ,"Number of arguments constant propagated by IPSCCP");
+STATISTIC(IPNumGlobalConst, "Number of globals found to be constant by IPSCCP");
+
+
+
 // LatticeVal class - This class represents the different lattice values that an
 // instruction may occupy.  It is a simple class with value semantics.
 //
@@ -1081,9 +1091,6 @@ bool SCCPSolver::ResolveBranchesIn(Function &F) {
 
 
 namespace {
-  Statistic NumInstRemoved("sccp", "Number of instructions removed");
-  Statistic NumDeadBlocks ("sccp", "Number of basic blocks unreachable");
-
   //===--------------------------------------------------------------------===//
   //
   /// SCCP Class - This class uses the SCCPSolver to implement a per-function
@@ -1192,13 +1199,6 @@ bool SCCP::runOnFunction(Function &F) {
 }
 
 namespace {
-  Statistic IPNumInstRemoved("ipsccp", "Number of instructions removed");
-  Statistic IPNumDeadBlocks ("ipsccp", "Number of basic blocks unreachable");
-  Statistic IPNumArgsElimed ("ipsccp",
-                               "Number of arguments constant propagated");
-  Statistic IPNumGlobalConst("ipsccp",
-                               "Number of globals found to be constant");
-
   //===--------------------------------------------------------------------===//
   //
   /// IPSCCP Class - This class implements interprocedural Sparse Conditional
index 080d8115ff9ff4894c16a343ece15a7092ef6dcd..160128eba1d1f997eec1ab0a209a2eec89e1f420 100644 (file)
@@ -19,6 +19,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "scalarrepl"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/ADT/StringExtras.h"
 using namespace llvm;
 
-namespace {
-  Statistic NumReplaced("scalarrepl", "Number of allocas broken up");
-  Statistic NumPromoted("scalarrepl", "Number of allocas promoted");
-  Statistic NumConverted("scalarrepl",
-                           "Number of aggregates converted to scalar");
+STATISTIC(NumReplaced,  "Number of allocas broken up");
+STATISTIC(NumPromoted,  "Number of allocas promoted");
+STATISTIC(NumConverted, "Number of aggregates converted to scalar");
 
+namespace {
   struct VISIBILITY_HIDDEN SROA : public FunctionPass {
     bool runOnFunction(Function &F);
 
index 175dd3b3bf60615cf21e29e31458b4af93df9e14..f363a3a5c584bfd09de50187a6ea48d711155ff8 100644 (file)
@@ -18,6 +18,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "simplifycfg"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Constants.h"
@@ -29,9 +30,9 @@
 #include <set>
 using namespace llvm;
 
-namespace {
-  Statistic NumSimpl("cfgsimplify", "Number of blocks simplified");
+STATISTIC(NumSimpl, "Number of blocks simplified");
 
+namespace {
   struct CFGSimplifyPass : public FunctionPass {
     virtual bool runOnFunction(Function &F);
   };
index 6708418a678093e100f6bed202f1fef145449bcf..97e8b186e525d6fe25c9afbe746df6b0060a96c9 100644 (file)
 #include "llvm/ADT/Statistic.h"
 using namespace llvm;
 
+STATISTIC(NumEliminated, "Number of unconditional branches eliminated");
+
 namespace {
   cl::opt<unsigned>
   Threshold("taildup-threshold", cl::desc("Max block size to tail duplicate"),
             cl::init(6), cl::Hidden);
-  Statistic NumEliminated("tailduplicate",
-                            "Number of unconditional branches eliminated");
-  Statistic NumPHINodes("tailduplicate", "Number of phi nodes inserted");
-
   class TailDup : public FunctionPass {
     bool runOnFunction(Function &F);
   private:
index aca54306692f3e2569be3ba83410af1ba125f7c9..daa6200871a7625a72b94d904f7ac4a310d8e41d 100644 (file)
@@ -50,6 +50,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "tailcallelim"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/ADT/Statistic.h"
 using namespace llvm;
 
-namespace {
-  Statistic NumEliminated("tailcallelim", "Number of tail calls removed");
-  Statistic NumAccumAdded("tailcallelim","Number of accumulators introduced");
+STATISTIC(NumEliminated, "Number of tail calls removed");
+STATISTIC(NumAccumAdded, "Number of accumulators introduced");
 
+namespace {
   struct TailCallElim : public FunctionPass {
     virtual bool runOnFunction(Function &F);