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

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 6 10:54:10 PDT 2025


Author: Florian Mayer
Date: 2025-06-06T10:54:07-07:00
New Revision: 44a6a44573489501a4599425a02b4ba0c729244c

URL: https://github.com/llvm/llvm-project/commit/44a6a44573489501a4599425a02b4ba0c729244c
DIFF: https://github.com/llvm/llvm-project/commit/44a6a44573489501a4599425a02b4ba0c729244c.diff

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

Co-authored-by: Nikita Popov <npopov at redhat.com>

Added: 
    

Modified: 
    llvm/lib/Support/DebugCounter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/DebugCounter.cpp b/llvm/lib/Support/DebugCounter.cpp
index 9c4a4429ca0ee..6b65720440f30 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 LLVM build without assertions. This "
+            "is a no-op.\n";
+#endif
 
   // The strings should come in as counter=chunk_list
   auto CounterPair = StringRef(Val).split('=');


        


More information about the llvm-commits mailing list