43#ifndef LLVM_SUPPORT_DEBUGCOUNTER_H
44#define LLVM_SUPPORT_DEBUGCOUNTER_H
70 return instance().addCounter(std::string(
Name), std::string(Desc));
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;
133 return std::make_pair(RegisteredCounters[
ID], Counters.
lookup(
ID).Desc);
139 return RegisteredCounters.
begin();
160 unsigned addCounter(
const std::string &
Name,
const std::string &Desc) {
161 unsigned Result = RegisteredCounters.
insert(
Name);
162 Counters[Result] = {};
163 Counters[Result].Desc = Desc;
170 int64_t StopAfter = -1;
174 DenseMap<unsigned, CounterInfo> Counters;
179 bool Enabled =
false;
182#define DEBUG_COUNTER(VARNAME, COUNTERNAME, DESC) \
183 static const unsigned VARNAME = \
184 DebugCounter::registerCounter(COUNTERNAME, DESC)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file defines the DenseMap class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void setCounterValue(unsigned ID, int64_t Count)
CounterVector::const_iterator end() const
CounterVector::const_iterator begin() const
static bool isCounterSet(unsigned ID)
static bool shouldExecute(unsigned CounterName)
std::pair< std::string, std::string > getCounterInfo(unsigned ID) const
void push_back(const std::string &)
static bool isCountingEnabled()
unsigned getCounterId(const std::string &Name) const
static unsigned registerCounter(StringRef Name, StringRef Desc)
UniqueVector< std::string > CounterVector
static void enableAllCounters()
static DebugCounter & instance()
Returns a reference to the singleton instance.
static int64_t getCounterValue(unsigned ID)
void print(raw_ostream &OS) const
LLVM_DUMP_METHOD void dump() const
unsigned int getNumCounters() const
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...
StringRef - Represent a constant reference to a string, i.e.
UniqueVector - This class produces a sequential ID number (base 1) for each unique entry that is adde...
typename VectorType::const_iterator const_iterator
unsigned insert(const T &Entry)
insert - Append entry to the vector if it doesn't already exist.
size_t size() const
size - Returns the number of entries in the vector.
iterator end()
Return an iterator to the end of the vector.
unsigned idFor(const T &Entry) const
idFor - return the ID for an existing entry.
iterator begin()
Return an iterator to the start of the vector.
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.