13 class DebugCounterList :
public cl::list<std::string, DebugCounter> {
18 template <
class... Mods>
19 explicit DebugCounterList(Mods &&... Ms) :
Base(
std::forward<Mods>(Ms)...) {}
22 void printOptionInfo(
size_t GlobalWidth)
const override {
30 outs() <<
" -" << ArgStr;
33 Option::printHelpStr(HelpStr, GlobalWidth, ArgStr.size() + 6);
35 for (
auto Name : CounterInstance) {
37 CounterInstance.getCounterInfo(CounterInstance.getCounterId(
Name));
38 size_t NumSpaces = GlobalWidth -
Info.first.size() - 8;
49 cl::desc(
"Comma separated list of debug counter skip and count"),
54 cl::desc(
"Print out debug counter info after all counters accumulated"));
73 if (CounterPair.second.empty()) {
74 errs() <<
"DebugCounter Error: " << Val <<
" does not have an = in it\n";
80 if (CounterPair.second.getAsInteger(0, CounterVal)) {
81 errs() <<
"DebugCounter Error: " << CounterPair.second
82 <<
" is not a number\n";
87 if (CounterPair.first.endswith(
"-skip")) {
88 auto CounterName = CounterPair.first.drop_back(5);
89 unsigned CounterID = getCounterId(CounterName);
91 errs() <<
"DebugCounter Error: " << CounterName
92 <<
" is not a registered counter\n";
97 CounterInfo &Counter = Counters[CounterID];
98 Counter.Skip = CounterVal;
100 }
else if (CounterPair.first.endswith(
"-count")) {
101 auto CounterName = CounterPair.first.drop_back(6);
102 unsigned CounterID = getCounterId(CounterName);
104 errs() <<
"DebugCounter Error: " << CounterName
105 <<
" is not a registered counter\n";
110 CounterInfo &Counter = Counters[CounterID];
111 Counter.StopAfter = CounterVal;
112 Counter.IsSet =
true;
114 errs() <<
"DebugCounter Error: " << CounterPair.first
115 <<
" does not end with -skip or -count\n";
121 RegisteredCounters.end());
122 sort(CounterNames.begin(), CounterNames.end());
124 auto &Us = instance();
125 OS <<
"Counters and values:\n";
126 for (
auto &CounterName : CounterNames) {
127 unsigned CounterID = getCounterId(CounterName);
128 OS <<
left_justify(RegisteredCounters[CounterID], 32) <<
": {" 129 << Us.Counters[CounterID].Count <<
"," << Us.Counters[CounterID].Skip
130 <<
"," << 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.
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"))
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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.
This file declares helper objects for defining debug options that can be configured via the command l...
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)