Go to the documentation of this file.
43 #ifndef LLVM_SUPPORT_DEBUGCOUNTER_H
44 #define LLVM_SUPPORT_DEBUGCOUNTER_H
72 return instance().addCounter(std::string(
Name), std::string(Desc));
75 if (!isCountingEnabled())
79 auto Result = Us.Counters.find(CounterName);
80 if (Result != Us.Counters.end()) {
81 auto &CounterInfo = Result->second;
87 if (CounterInfo.Skip < 0)
89 if (CounterInfo.Skip >= CounterInfo.Count)
91 if (CounterInfo.StopAfter < 0)
93 return CounterInfo.StopAfter + CounterInfo.Skip >= CounterInfo.Count;
109 auto Result = Us.Counters.find(
ID);
110 assert(Result != Us.Counters.end() &&
"Asking about a non-set counter");
111 return Result->second.Count;
117 Us.Counters[
ID].Count = Count;
135 return std::make_pair(RegisteredCounters[
ID], Counters.
lookup(
ID).Desc);
141 return RegisteredCounters.
begin();
153 static bool isCountingEnabled() {
162 unsigned addCounter(
const std::string &
Name,
const std::string &Desc) {
163 unsigned Result = RegisteredCounters.
insert(
Name);
164 Counters[Result] = {};
165 Counters[
Result].Desc = Desc;
172 int64_t StopAfter = -1;
176 DenseMap<unsigned, CounterInfo> Counters;
181 bool Enabled =
false;
184 #define DEBUG_COUNTER(VARNAME, COUNTERNAME, DESC) \
185 static const unsigned VARNAME = \
186 DebugCounter::registerCounter(COUNTERNAME, DESC)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This is an optimization pass for GlobalISel generic memory operations.
static void enableAllCounters()
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...
typename VectorType::const_iterator const_iterator
std::pair< std::string, std::string > getCounterInfo(unsigned ID) const
UniqueVector< std::string > CounterVector
static int64_t getCounterValue(unsigned ID)
unsigned idFor(const T &Entry) const
idFor - return the ID for an existing entry.
static bool isCounterSet(unsigned ID)
static DebugCounter & instance()
Returns a reference to the singleton instance.
static unsigned registerCounter(StringRef Name, StringRef Desc)
CounterVector::const_iterator end() const
static bool shouldExecute(unsigned CounterName)
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.
static void setCounterValue(unsigned ID, int64_t Count)
void push_back(const std::string &)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
iterator end()
Return an iterator to the end of the vector.
unsigned int getNumCounters() const
StringRef - Represent a constant reference to a string, i.e.
size_t size() const
size - Returns the number of entries in the vector.
CounterVector::const_iterator begin() const
void print(raw_ostream &OS) const
unsigned getCounterId(const std::string &Name) const
iterator begin()
Return an iterator to the start of the vector.
LLVM_DUMP_METHOD void dump() const
unsigned insert(const T &Entry)
insert - Append entry to the vector if it doesn't already exist.