[llvm] [NFC] [DebugCounter] warn if --debug-counter is unused in NDEBUG (PR #143057)
Florian Mayer via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 6 09:51:27 PDT 2025
https://github.com/fmayer updated https://github.com/llvm/llvm-project/pull/143057
>From fcb2062d4f3f0af9cfa797e7cc9d97a27aa41edf Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Thu, 5 Jun 2025 18:30:09 -0700
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
=?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
---
llvm/lib/Support/DebugCounter.cpp | 5 +++++
1 file changed, 5 insertions(+)
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('=');
>From d67c37f75b85bee74a2a395797d836836ea27e29 Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Fri, 6 Jun 2025 09:51:18 -0700
Subject: [PATCH 2/2] Update llvm/lib/Support/DebugCounter.cpp
Co-authored-by: Nikita Popov <npopov at redhat.com>
---
llvm/lib/Support/DebugCounter.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Support/DebugCounter.cpp b/llvm/lib/Support/DebugCounter.cpp
index 1fbd700afa1d7..41776db630077 100644
--- a/llvm/lib/Support/DebugCounter.cpp
+++ b/llvm/lib/Support/DebugCounter.cpp
@@ -174,7 +174,7 @@ void DebugCounter::push_back(const std::string &Val) {
return;
#ifdef NDEBUG
// isCountingEnabled is hardcoded to false in NDEBUG.
- errs() << "Requested --debug-counter in non-debug LLVM build. This is a "
+ errs() << "Requested --debug-counter in LLVM build without assertions. This is a "
"no-op.\n";
#endif
More information about the llvm-commits
mailing list