[PATCH] D29998: Add initial support for debug counting

Daniel Berlin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 17 15:32:59 PST 2017


dberlin added inline comments.


================
Comment at: include/llvm/Support/DebugCounter.h:70-71
+// Compile to nothing when debugging is off
+#ifdef NDEBUG
+    return true;
+#else
----------------
davide wrote:
> Add a diagnostic? ("enable debug if you want counters!") or something?
We can't, really.
Because the shouldExecute call happens all the time, whether you are in debug mode or not. It just does nothing with debugging off.
(or at least, that's how GCC works)


================
Comment at: include/llvm/Support/DebugCounter.h:79-80
+      // is non-zero
+      if (CounterPair.first < 0)
+        return true;
+      if (CounterPair.first != 0) {
----------------
davide wrote:
> Can counter ever go below zero?
We use -1 to say "always execute".
I'll update.



https://reviews.llvm.org/D29998





More information about the llvm-commits mailing list