12 class DebugCounterList :
public cl::list<std::string, DebugCounter> {
17 template <
class... Mods>
18 explicit DebugCounterList(Mods &&... Ms) :
Base(
std::forward<Mods>(Ms)...) {}
21 void printOptionInfo(
size_t GlobalWidth)
const override {
29 outs() <<
" -" << ArgStr;
32 Option::printHelpStr(HelpStr, GlobalWidth, ArgStr.size() + 6);
34 for (
auto Name : CounterInstance) {
36 CounterInstance.getCounterInfo(CounterInstance.getCounterId(
Name));
37 size_t NumSpaces = GlobalWidth -
Info.first.size() - 8;
48 cl::desc(
"Comma separated list of debug counter skip and count"),
53 cl::desc(
"Print out debug counter info after all counters accumulated"));
72 if (CounterPair.second.empty()) {
73 errs() <<
"DebugCounter Error: " << Val <<
" does not have an = in it\n";
79 if (CounterPair.second.getAsInteger(0, CounterVal)) {
80 errs() <<
"DebugCounter Error: " << CounterPair.second
81 <<
" is not a number\n";
86 if (CounterPair.first.endswith(
"-skip")) {
87 auto CounterName = CounterPair.first.drop_back(5);
88 unsigned CounterID = getCounterId(CounterName);
90 errs() <<
"DebugCounter Error: " << CounterName
91 <<
" is not a registered counter\n";
96 CounterInfo &Counter = Counters[CounterID];
97 Counter.Skip = CounterVal;
99 }
else if (CounterPair.first.endswith(
"-count")) {
100 auto CounterName = CounterPair.first.drop_back(6);
101 unsigned CounterID = getCounterId(CounterName);
103 errs() <<
"DebugCounter Error: " << CounterName
104 <<
" is not a registered counter\n";
109 CounterInfo &Counter = Counters[CounterID];
110 Counter.StopAfter = CounterVal;
111 Counter.IsSet =
true;
113 errs() <<
"DebugCounter Error: " << CounterPair.first
114 <<
" does not end with -skip or -count\n";
120 RegisteredCounters.end());
121 sort(CounterNames.begin(), CounterNames.end());
123 auto &Us = instance();
124 OS <<
"Counters and values:\n";
125 for (
auto &CounterName : CounterNames) {
126 unsigned CounterID = getCounterId(CounterName);
127 OS <<
left_justify(RegisteredCounters[CounterID], 32) <<
": {" 128 << Us.Counters[CounterID].Count <<
"," << Us.Counters[CounterID].Skip
129 <<
"," << Us.Counters[CounterID].StopAfter <<
"}\n";
FormattedString left_justify(StringRef Str, unsigned Width)
left_justify - append spaces after string so total output is Width characters.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_DUMP_METHOD void dump() const
This class represents lattice values for constants.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
static DebugCounter & instance()
Returns a reference to the singleton instance.
static cl::opt< bool > PrintDebugCounter("print-debug-counter", cl::Hidden, cl::init(false), cl::Optional, cl::desc("Print out debug counter info after all counters accumulated"))
static ManagedStatic< DebugCounter > DC
This file provides an implementation of debug counters.
Analysis containing CSE Info
raw_ostream & outs()
This returns a reference to a raw_ostream for standard output.
initializer< Ty > init(const Ty &Val)
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
void sort(IteratorTy Start, IteratorTy End)
static DebugCounterList DebugCounterOption("debug-counter", cl::Hidden, cl::desc("Comma separated list of debug counter skip and count"), cl::CommaSeparated, cl::ZeroOrMore, cl::location(DebugCounter::instance()))
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
void print(raw_ostream &OS) const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void push_back(const std::string &)
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.
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
LocationClass< Ty > location(Ty &L)