24    for (
auto E : Chunks) {
 
 
   37  auto ConsumeInt = [&]() -> int64_t {
 
   39        Remaining.
take_until([](
char c) { 
return c < 
'0' || c > 
'9'; });
 
   41    if (
Number.getAsInteger(10, Res)) {
 
   42      errs() << 
"Failed to parse int at : " << Remaining << 
"\n";
 
   50    int64_t Num = ConsumeInt();
 
   53    if (!Chunks.
empty() && Num <= Chunks[Chunks.
size() - 1].End) {
 
   54      errs() << 
"Expected Chunks to be in increasing order " << Num
 
   55             << 
" <= " << Chunks[Chunks.
size() - 1].End << 
"\n";
 
   60      int64_t Num2 = ConsumeInt();
 
   64        errs() << 
"Expected " << Num << 
" < " << Num2 << 
" in " << Num << 
"-" 
   77    if (Remaining.
empty())
 
   79    errs() << 
"Failed to parse at : " << Remaining;
 
 
   91class DebugCounterList : 
public cl::list<std::string, DebugCounter> {
 
   96  template <
class... Mods>
 
   97  explicit DebugCounterList(Mods &&... Ms) : 
Base(
std::forward<Mods>(Ms)...) {}
 
  100  void printOptionInfo(
size_t GlobalWidth)
 const override {
 
  108    outs() << 
"  -" << ArgStr;
 
  111    Option::printHelpStr(HelpStr, GlobalWidth, ArgStr.size() + 6);
 
  113    for (
const auto &Name : CounterInstance) {
 
  115          CounterInstance.getCounterInfo(CounterInstance.getCounterId(Name));
 
  116      size_t NumSpaces = GlobalWidth - 
Info.first.size() - 8;
 
  128  DebugCounterList DebugCounterOption{
 
  130      cl::desc(
"Comma separated list of debug counter skip and count"),
 
  132  cl::opt<bool, true> PrintDebugCounter{
 
  133      "print-debug-counter",
 
  138      cl::desc(
"Print out debug counter info after all counters accumulated")};
 
  139  cl::opt<bool, true> PrintDebugCounterQueries{
 
  140      "print-debug-counter-queries",
 
  145      cl::desc(
"Print out each query of an enabled debug counter")};
 
  146  cl::opt<bool, true> BreakOnLastCount{
 
  147      "debug-counter-break-on-last",
 
  152      cl::desc(
"Insert a break point on the last enabled count of a " 
  155  DebugCounterOwner() {
 
  162  ~DebugCounterOwner() {
 
  163    if (ShouldPrintCounter)
 
  173  static DebugCounterOwner O;
 
 
  184  errs() << 
"Requested --debug-counter in LLVM build without assertions. This " 
  190  if (CounterPair.second.empty()) {
 
  191    errs() << 
"DebugCounter Error: " << Val << 
" does not have an = in it\n";
 
  194  StringRef CounterName = CounterPair.first;
 
  201  unsigned CounterID = 
getCounterId(std::string(CounterName));
 
  203    errs() << 
"DebugCounter Error: " << CounterName
 
  204           << 
" is not a registered counter\n";
 
  210  Counter.
IsSet = 
true;
 
  211  Counter.
Chunks = std::move(Chunks);
 
 
  220  OS << 
"Counters and values:\n";
 
  221  for (
auto &CounterName : CounterNames) {
 
  222    unsigned CounterID = 
getCounterId(std::string(CounterName));
 
 
  232  int64_t CurrCount = Info.Count++;
 
  233  uint64_t CurrIdx = Info.CurrChunkIdx;
 
  235  if (Info.Chunks.empty())
 
  237  if (CurrIdx >= Info.Chunks.size())
 
  240  bool Res = Info.Chunks[CurrIdx].contains(CurrCount);
 
  241  if (
BreakOnLast && CurrIdx == (Info.Chunks.size() - 1) &&
 
  242      CurrCount == Info.Chunks[CurrIdx].End) {
 
  245  if (CurrCount > Info.Chunks[CurrIdx].End) {
 
  249    if (Info.CurrChunkIdx < Info.Chunks.size() &&
 
  250        CurrCount == Info.Chunks[Info.CurrChunkIdx].Begin)
 
 
  258  auto Result = Us.Counters.find(CounterName);
 
  259  if (Result != Us.Counters.end()) {
 
  263      dbgs() << 
"DebugCounter " << Us.RegisteredCounters[CounterName] << 
"=" 
 
  272#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
Analysis containing CSE Info
#define LLVM_BUILTIN_DEBUGTRAP
LLVM_BUILTIN_DEBUGTRAP - On compilers which support it, expands to an expression which causes the pro...
#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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
empty - Check if the array is empty.
static LLVM_ABI void printChunks(raw_ostream &OS, ArrayRef< Chunk >)
DenseMap< unsigned, CounterInfo > Counters
bool handleCounterIncrement(CounterInfo &Info)
CounterVector RegisteredCounters
LLVM_ABI void push_back(const std::string &)
unsigned getCounterId(const std::string &Name) const
static LLVM_ABI bool shouldExecuteImpl(unsigned CounterName)
static void enableAllCounters()
static LLVM_ABI bool parseChunks(StringRef Str, SmallVector< Chunk > &Res)
Return true on parsing error and print the error message on the llvm::errs()
static LLVM_ABI DebugCounter & instance()
Returns a reference to the singleton instance.
LLVM_ABI void print(raw_ostream &OS) const
LLVM_DUMP_METHOD void dump() const
void push_back(const T &Elt)
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.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
StringRef take_until(function_ref< bool(char)> F) const
Return the longest prefix of 'this' such that no character in the prefix satisfies the given predicat...
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.
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
LocationClass< Ty > location(Ty &L)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
void initDebugCounterOptions()
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI 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.
Implement std::hash so that hash_code can be used in STL containers.
LLVM_ABI void print(llvm::raw_ostream &OS)
SmallVector< Chunk > Chunks