44 #ifndef LLVM_SUPPORT_DEBUGCOUNTER_H 45 #define LLVM_SUPPORT_DEBUGCOUNTER_H 70 return instance().addCounter(Name, Desc);
73 if (!isCountingEnabled())
77 auto Result = Us.Counters.find(CounterName);
78 if (
Result != Us.Counters.end()) {
79 auto &CounterInfo =
Result->second;
85 if (CounterInfo.Skip < 0)
87 if (CounterInfo.Skip >= CounterInfo.Count)
89 if (CounterInfo.StopAfter < 0)
91 return CounterInfo.StopAfter + CounterInfo.Skip >= CounterInfo.Count;
107 auto Result = Us.Counters.find(ID);
108 assert(
Result != Us.Counters.end() &&
"Asking about a non-set counter");
109 return Result->second.Count;
115 Us.Counters[
ID].Count = Count;
125 return RegisteredCounters.
idFor(Name);
133 return std::make_pair(RegisteredCounters[ID], Counters.
lookup(ID).Desc);
139 return RegisteredCounters.
begin();
151 static bool isCountingEnabled() {
160 unsigned addCounter(
const std::string &
Name,
const std::string &Desc) {
162 Counters[Result] = {};
163 Counters[Result].Desc = Desc;
170 int64_t StopAfter = -1;
175 CounterVector RegisteredCounters;
179 bool Enabled =
false;
182 #define DEBUG_COUNTER(VARNAME, COUNTERNAME, DESC) \ 183 static const unsigned VARNAME = \ 184 DebugCounter::registerCounter(COUNTERNAME, DESC) LLVM_DUMP_METHOD void dump() const
Compute iterated dominance frontiers using a linear time algorithm.
static void enableAllCounters()
UniqueVector< std::string > CounterVector
static DebugCounter & instance()
Returns a reference to the singleton instance.
static unsigned registerCounter(StringRef Name, StringRef Desc)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
std::pair< std::string, std::string > getCounterInfo(unsigned ID) const
unsigned idFor(const T &Entry) const
idFor - return the ID for an existing entry.
CounterVector::const_iterator end() const
static bool isCounterSet(unsigned ID)
unsigned int getNumCounters() const
typename VectorType::const_iterator const_iterator
static void setCounterValue(unsigned ID, int64_t Count)
static int64_t getCounterValue(unsigned ID)
iterator begin()
Return an iterator to the start of the vector.
static bool shouldExecute(unsigned CounterName)
size_t size() const
size - Returns the number of entries in the vector.
iterator end()
Return an iterator to the end of the vector.
void print(raw_ostream &OS) const
CounterVector::const_iterator begin() const
unsigned getCounterId(const std::string &Name) const
void push_back(const std::string &)
unsigned insert(const T &Entry)
insert - Append entry to the vector if it doesn't already exist.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.