diff options
author | George Burgess IV <george.burgess.iv@gmail.com> | 2018-07-23 21:49:36 +0000 |
---|---|---|
committer | George Burgess IV <george.burgess.iv@gmail.com> | 2018-07-23 21:49:36 +0000 |
commit | b00fb46479a3f9217408e007b02bb2200e7d6a19 (patch) | |
tree | c95676d9b91ee4d21db4b3995ac91e28a94f0098 /llvm/lib/Support/DebugCounter.cpp | |
parent | d9c254771dcdb8bd5e39aada5b8336a4bff52195 (diff) | |
download | bcm5719-llvm-b00fb46479a3f9217408e007b02bb2200e7d6a19.tar.gz bcm5719-llvm-b00fb46479a3f9217408e007b02bb2200e7d6a19.zip |
[DebugCounters] Keep track of total counts
This patch makes debug counters keep track of the total number of times
we've called `shouldExecute` for each counter, so it's easier to build
automated tooling on top of these.
A patch to print these counts is coming soon.
Patch by Zhizhou Yang!
Differential Revision: https://reviews.llvm.org/D49560
llvm-svn: 337748
Diffstat (limited to 'llvm/lib/Support/DebugCounter.cpp')
-rw-r--r-- | llvm/lib/Support/DebugCounter.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/llvm/lib/Support/DebugCounter.cpp b/llvm/lib/Support/DebugCounter.cpp index 4a439746541..5a9cecfc56d 100644 --- a/llvm/lib/Support/DebugCounter.cpp +++ b/llvm/lib/Support/DebugCounter.cpp @@ -66,7 +66,7 @@ void DebugCounter::push_back(const std::string &Val) { } // Now we have counter=value. // First, process value. - long CounterVal; + int64_t CounterVal; if (CounterPair.second.getAsInteger(0, CounterVal)) { errs() << "DebugCounter Error: " << CounterPair.second << " is not a number\n"; @@ -76,26 +76,24 @@ void DebugCounter::push_back(const std::string &Val) { // add it to the counter values. if (CounterPair.first.endswith("-skip")) { auto CounterName = CounterPair.first.drop_back(5); - unsigned CounterID = RegisteredCounters.idFor(CounterName); + unsigned CounterID = getCounterId(CounterName); if (!CounterID) { errs() << "DebugCounter Error: " << CounterName << " is not a registered counter\n"; return; } - - auto Res = Counters.insert({CounterID, {0, -1}}); - Res.first->second.first = CounterVal; + Counters[CounterID].Skip = CounterVal; + Counters[CounterID].IsSet = true; } else if (CounterPair.first.endswith("-count")) { auto CounterName = CounterPair.first.drop_back(6); - unsigned CounterID = RegisteredCounters.idFor(CounterName); + unsigned CounterID = getCounterId(CounterName); if (!CounterID) { errs() << "DebugCounter Error: " << CounterName << " is not a registered counter\n"; return; } - - auto Res = Counters.insert({CounterID, {0, -1}}); - Res.first->second.second = CounterVal; + Counters[CounterID].StopAfter = CounterVal; + Counters[CounterID].IsSet = true; } else { errs() << "DebugCounter Error: " << CounterPair.first << " does not end with -skip or -count\n"; @@ -106,7 +104,8 @@ void DebugCounter::print(raw_ostream &OS) const { OS << "Counters and values:\n"; for (const auto &KV : Counters) OS << left_justify(RegisteredCounters[KV.first], 32) << ": {" - << KV.second.first << "," << KV.second.second << "}\n"; + << KV.second.Count << "," << KV.second.Skip << "," + << KV.second.StopAfter << "}\n"; } LLVM_DUMP_METHOD void DebugCounter::dump() const { |