diff options
author | Chris Lattner <sabre@nondot.org> | 2006-12-06 17:46:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-12-06 17:46:33 +0000 |
commit | ac0b6ae358944ae8b2b5a11dc08f52c3ed89f2da (patch) | |
tree | cba006a0f0e329a969ce29b7d10ba0dc244f4f90 | |
parent | 2b4e98cb20c9391399b2601a793b6ea689da3cee (diff) |
Detemplatize the Statistic class. The only type it is instantiated with
is 'unsigned'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32279 91177308-0d34-0410-b5e6-96231b3b80d8
97 files changed, 252 insertions, 255 deletions
diff --git a/include/llvm/ADT/Statistic.h b/include/llvm/ADT/Statistic.h index 99160da106..332a57d121 100644 --- a/include/llvm/ADT/Statistic.h +++ b/include/llvm/ADT/Statistic.h @@ -8,17 +8,19 @@ //===----------------------------------------------------------------------===// // // This file defines the 'Statistic' class, which is designed to be an easy way -// to expose various success metrics from passes. These statistics are printed -// at the end of a run, when the -stats command line option is enabled on the -// command line. +// to expose various metrics from passes. These statistics are printed at the +// end of a run (from llvm_shutdown), when the -stats command line option is +// passed on the command line. // // This is useful for reporting information like the number of instructions // simplified, optimized or removed by various transformations, like this: // -// static Statistic<> NumInstsKilled("gcse", "Number of instructions killed"); +// static Statistic NumInstsKilled("gcse", "Number of instructions killed"); // // Later, in the code: ++NumInstsKilled; // +// NOTE: Statistics *must* be declared as global variables. +// //===----------------------------------------------------------------------===// #ifndef LLVM_ADT_STATISTIC_H @@ -29,7 +31,7 @@ namespace llvm { -// StatisticBase - Nontemplated base class for Statistic<> class... +// StatisticBase - Nontemplated base class for Statistic class... class StatisticBase { const char *Name; const char *Desc; @@ -55,39 +57,36 @@ protected: }; // Statistic Class - templated on the data type we are monitoring... -template <typename DataType=unsigned> class Statistic : private StatisticBase { - DataType Value; + unsigned Value; virtual void printValue(std::ostream &o) const { o << Value; } - virtual bool hasSomeData() const { return Value != DataType(); } + virtual bool hasSomeData() const { return Value != 0; } public: // Normal constructor, default initialize data item... Statistic(const char *name, const char *desc) - : StatisticBase(name, desc), Value(DataType()) {} + : StatisticBase(name, desc), Value(0) {} // Constructor to provide an initial value... - Statistic(const DataType &Val, const char *name, const char *desc) + Statistic(const unsigned &Val, const char *name, const char *desc) : StatisticBase(name, desc), Value(Val) {} // Print information when destroyed, iff command line option is specified ~Statistic() { destroy(); } // Allow use of this class as the value itself... - operator DataType() const { return Value; } - const Statistic &operator=(DataType Val) { Value = Val; return *this; } + operator unsigned() const { return Value; } + const Statistic &operator=(unsigned Val) { Value = Val; return *this; } const Statistic &operator++() { ++Value; return *this; } - DataType operator++(int) { return Value++; } + unsigned operator++(int) { return Value++; } const Statistic &operator--() { --Value; return *this; } - DataType operator--(int) { return Value--; } - const Statistic &operator+=(const DataType &V) { Value += V; return *this; } - const Statistic &operator-=(const DataType &V) { Value -= V; return *this; } - const Statistic &operator*=(const DataType &V) { Value *= V; return *this; } - const Statistic &operator/=(const DataType &V) { Value /= V; return *this; } + unsigned operator--(int) { return Value--; } + const Statistic &operator+=(const unsigned &V) { Value += V; return *this; } + const Statistic &operator-=(const unsigned &V) { Value -= V; return *this; } + const Statistic &operator*=(const unsigned &V) { Value *= V; return *this; } + const Statistic &operator/=(const unsigned &V) { Value /= V; return *this; } }; -EXTERN_TEMPLATE_INSTANTIATION(class Statistic<unsigned>); - } // End llvm namespace #endif diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp index 19b3ec1533..f5ca5fd6f5 100644 --- a/lib/Analysis/DataStructure/BottomUpClosure.cpp +++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp @@ -26,9 +26,9 @@ using namespace llvm; namespace { - Statistic<> MaxSCC("budatastructure", "Maximum SCC Size in Call Graph"); - Statistic<> NumBUInlines("budatastructures", "Number of graphs inlined"); - Statistic<> NumCallEdges("budatastructures", "Number of 'actual' call edges"); + Statistic MaxSCC("budatastructure", "Maximum SCC Size in Call Graph"); + Statistic NumBUInlines("budatastructures", "Number of graphs inlined"); + Statistic NumCallEdges("budatastructures", "Number of 'actual' call edges"); cl::opt<bool> AddGlobals("budatastructures-annotate-calls", cl::Hidden, diff --git a/lib/Analysis/DataStructure/CallTargets.cpp b/lib/Analysis/DataStructure/CallTargets.cpp index 5850749c6f..5ed4457418 100644 --- a/lib/Analysis/DataStructure/CallTargets.cpp +++ b/lib/Analysis/DataStructure/CallTargets.cpp @@ -29,10 +29,10 @@ using namespace llvm; namespace { - Statistic<> DirCall("calltarget", "Number of direct calls"); - Statistic<> IndCall("calltarget", "Number of indirect calls"); - Statistic<> CompleteInd("calltarget", "Number of complete indirect calls"); - Statistic<> CompleteEmpty("calltarget", "Number of complete empty calls"); + Statistic DirCall("calltarget", "Number of direct calls"); + Statistic IndCall("calltarget", "Number of indirect calls"); + Statistic CompleteInd("calltarget", "Number of complete indirect calls"); + Statistic CompleteEmpty("calltarget", "Number of complete empty calls"); RegisterPass<CallTargetFinder> X("calltarget","Find Call Targets (uses DSA)"); } diff --git a/lib/Analysis/DataStructure/CompleteBottomUp.cpp b/lib/Analysis/DataStructure/CompleteBottomUp.cpp index aea113d97d..af33e0d741 100644 --- a/lib/Analysis/DataStructure/CompleteBottomUp.cpp +++ b/lib/Analysis/DataStructure/CompleteBottomUp.cpp @@ -26,7 +26,7 @@ using namespace llvm; namespace { RegisterPass<CompleteBUDataStructures> X("cbudatastructure", "'Complete' Bottom-up Data Structure Analysis"); - Statistic<> NumCBUInlines("cbudatastructures", "Number of graphs inlined"); + Statistic NumCBUInlines("cbudatastructures", "Number of graphs inlined"); } diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index 6eee541aeb..80237c4f0b 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -34,12 +34,12 @@ using namespace llvm; #define COLLAPSE_ARRAYS_AGGRESSIVELY 0 namespace { - Statistic<> NumFolds ("dsa", "Number of nodes completely folded"); - Statistic<> NumCallNodesMerged("dsa", "Number of call nodes merged"); - Statistic<> NumNodeAllocated ("dsa", "Number of nodes allocated"); - Statistic<> NumDNE ("dsa", "Number of nodes removed by reachability"); - Statistic<> NumTrivialDNE ("dsa", "Number of nodes trivially removed"); - Statistic<> NumTrivialGlobalDNE("dsa", "Number of globals trivially removed"); + Statistic NumFolds ("dsa", "Number of nodes completely folded"); + Statistic NumCallNodesMerged("dsa", "Number of call nodes merged"); + Statistic NumNodeAllocated ("dsa", "Number of nodes allocated"); + Statistic NumDNE ("dsa", "Number of nodes removed by reachability"); + Statistic NumTrivialDNE ("dsa", "Number of nodes trivially removed"); + Statistic NumTrivialGlobalDNE("dsa", "Number of globals trivially removed"); static cl::opt<unsigned> DSAFieldLimit("dsa-field-limit", cl::Hidden, cl::desc("Number of fields to track before collapsing a node"), diff --git a/lib/Analysis/DataStructure/DataStructureOpt.cpp b/lib/Analysis/DataStructure/DataStructureOpt.cpp index 56748832ab..85da1763ac 100644 --- a/lib/Analysis/DataStructure/DataStructureOpt.cpp +++ b/lib/Analysis/DataStructure/DataStructureOpt.cpp @@ -22,9 +22,9 @@ using namespace llvm; namespace { - Statistic<> + Statistic NumGlobalsConstanted("ds-opt", "Number of globals marked constant"); - Statistic<> + Statistic NumGlobalsIsolated("ds-opt", "Number of globals with references dropped"); class DSOpt : public ModulePass { diff --git a/lib/Analysis/DataStructure/DataStructureStats.cpp b/lib/Analysis/DataStructure/DataStructureStats.cpp index 469ab2e719..f7fbe3b33c 100644 --- a/lib/Analysis/DataStructure/DataStructureStats.cpp +++ b/lib/Analysis/DataStructure/DataStructureStats.cpp @@ -23,19 +23,19 @@ using namespace llvm; namespace { - Statistic<> TotalNumCallees("totalcallees", + Statistic TotalNumCallees("totalcallees", "Total number of callee functions at all indirect call sites"); - Statistic<> NumIndirectCalls("numindirect", + Statistic NumIndirectCalls("numindirect", "Total number of indirect call sites in the program"); - Statistic<> NumPoolNodes("numpools", + Statistic NumPoolNodes("numpools", "Number of allocation nodes that could be pool allocated"); // Typed/Untyped memory accesses: If DSA can infer that the types the loads // and stores are accessing are correct (ie, the node has not been collapsed), // increment the appropriate counter. - Statistic<> NumTypedMemAccesses("numtypedmemaccesses", + Statistic NumTypedMemAccesses("numtypedmemaccesses", "Number of loads/stores which are fully typed"); - Statistic<> NumUntypedMemAccesses("numuntypedmemaccesses", + Statistic NumUntypedMemAccesses("numuntypedmemaccesses", "Number of loads/stores which are untyped"); class DSGraphStats : public FunctionPass, public InstVisitor<DSGraphStats> { diff --git a/lib/Analysis/DataStructure/EquivClassGraphs.cpp b/lib/Analysis/DataStructure/EquivClassGraphs.cpp index 38aaf0b93c..49c93ffc4f 100644 --- a/lib/Analysis/DataStructure/EquivClassGraphs.cpp +++ b/lib/Analysis/DataStructure/EquivClassGraphs.cpp @@ -31,9 +31,9 @@ using namespace llvm; namespace { RegisterPass<EquivClassGraphs> X("eqdatastructure", "Equivalence-class Bottom-up Data Structure Analysis"); - Statistic<> NumEquivBUInlines("equivdatastructures", + Statistic NumEquivBUInlines("equivdatastructures", "Number of graphs inlined"); - Statistic<> NumFoldGraphInlines("Inline equiv-class graphs bottom up", + Statistic NumFoldGraphInlines("Inline equiv-class graphs bottom up", "Number of graphs inlined |