[llvm] [NFC] [DebugCounter] warn if --debug-counter is unused in NDEBUG (PR #143057)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 5 18:31:09 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Florian Mayer (fmayer)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/143057.diff


1 Files Affected:

- (modified) llvm/lib/Support/DebugCounter.cpp (+5) 


``````````diff
diff --git a/llvm/lib/Support/DebugCounter.cpp b/llvm/lib/Support/DebugCounter.cpp
index 9c4a4429ca0ee..1fbd700afa1d7 100644
--- a/llvm/lib/Support/DebugCounter.cpp
+++ b/llvm/lib/Support/DebugCounter.cpp
@@ -172,6 +172,11 @@ DebugCounter &DebugCounter::instance() {
 void DebugCounter::push_back(const std::string &Val) {
   if (Val.empty())
     return;
+#ifdef NDEBUG
+  // isCountingEnabled is hardcoded to false in NDEBUG.
+  errs() << "Requested --debug-counter in non-debug LLVM build. This is a "
+            "no-op.\n";
+#endif
 
   // The strings should come in as counter=chunk_list
   auto CounterPair = StringRef(Val).split('=');

``````````

</details>


https://github.com/llvm/llvm-project/pull/143057


More information about the llvm-commits mailing list