14class DebugCounterList :
public cl::list<std::string, DebugCounter> {
19 template <
class... Mods>
20 explicit DebugCounterList(Mods &&... Ms) :
Base(
std::forward<Mods>(Ms)...) {}
23 void printOptionInfo(
size_t GlobalWidth)
const override {
36 for (
const auto &
Name : CounterInstance) {
38 CounterInstance.getCounterInfo(CounterInstance.getCounterId(
Name));
39 size_t NumSpaces = GlobalWidth -
Info.first.size() - 8;
50struct DebugCounterOwner {
52 DebugCounterList DebugCounterOption{
54 cl::desc(
"Comma separated list of debug counter skip and count"),
58 cl::desc(
"Print out debug counter info after all counters accumulated")};
67 ~DebugCounterOwner() {
78 static DebugCounterOwner O;
89 if (CounterPair.second.empty()) {
90 errs() <<
"DebugCounter Error: " << Val <<
" does not have an = in it\n";
96 if (CounterPair.second.getAsInteger(0, CounterVal)) {
97 errs() <<
"DebugCounter Error: " << CounterPair.second
98 <<
" is not a number\n";
103 if (CounterPair.first.endswith(
"-skip")) {
104 auto CounterName = CounterPair.first.drop_back(5);
105 unsigned CounterID =
getCounterId(std::string(CounterName));
107 errs() <<
"DebugCounter Error: " << CounterName
108 <<
" is not a registered counter\n";
113 CounterInfo &Counter = Counters[CounterID];
114 Counter.Skip = CounterVal;
115 Counter.IsSet =
true;
116 }
else if (CounterPair.first.endswith(
"-count")) {
117 auto CounterName = CounterPair.first.drop_back(6);
118 unsigned CounterID =
getCounterId(std::string(CounterName));
120 errs() <<
"DebugCounter Error: " << CounterName
121 <<
" is not a registered counter\n";
126 CounterInfo &Counter = Counters[CounterID];
127 Counter.StopAfter = CounterVal;
128 Counter.IsSet =
true;
130 errs() <<
"DebugCounter Error: " << CounterPair.first
131 <<
" does not end with -skip or -count\n";
137 RegisteredCounters.
end());
141 OS <<
"Counters and values:\n";
142 for (
auto &CounterName : CounterNames) {
143 unsigned CounterID =
getCounterId(std::string(CounterName));
145 << Us.Counters[CounterID].Count <<
"," << Us.Counters[CounterID].Skip
146 <<
"," << Us.Counters[CounterID].StopAfter <<
"}\n";
Analysis containing CSE Info
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file provides an implementation of debug counters.
void push_back(const std::string &)
static bool isCountingEnabled()
unsigned getCounterId(const std::string &Name) const
static void enableAllCounters()
static DebugCounter & instance()
Returns a reference to the singleton instance.
void print(raw_ostream &OS) const
LLVM_DUMP_METHOD void dump() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
iterator end()
Return an iterator to the end of the vector.
iterator begin()
Return an iterator to the start of the vector.
static void printHelpStr(StringRef HelpStr, size_t Indent, size_t FirstLineIndentedBy)
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
initializer< Ty > init(const Ty &Val)
LocationClass< Ty > location(Ty &L)
This is an optimization pass for GlobalISel generic memory operations.
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
void initDebugCounterOptions()
void sort(IteratorTy Start, IteratorTy End)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
FormattedString left_justify(StringRef Str, unsigned Width)
left_justify - append spaces after string so total output is Width characters.