44 #ifndef LLVM_SUPPORT_DEBUGCOUNTER_H 45 #define LLVM_SUPPORT_DEBUGCOUNTER_H 72 return instance().addCounter(Name, 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;
127 return RegisteredCounters.
idFor(Name);
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;
177 CounterVector RegisteredCounters;
181 bool Enabled =
false;
184 #define DEBUG_COUNTER(VARNAME, COUNTERNAME, DESC) \ 185 static const unsigned VARNAME = \ 186 DebugCounter::registerCounter(COUNTERNAME, DESC) LLVM_DUMP_METHOD void dump() const
This class represents lattice values for constants.
static void enableAllCounters()
UniqueVector< std::string > CounterVector
static DebugCounter & instance()
Returns a reference to the singleton instance.
static unsigned registerCounter(StringRef Name, StringRef Desc)
std::pair< std::string, std::string > getCounterInfo(unsigned ID) const
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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.