-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[NFC] [DebugCounter] warn if --debug-counter is unused in NDEBUG #143057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NFC] [DebugCounter] warn if --debug-counter is unused in NDEBUG #143057
Conversation
Created using spr 1.3.4
@llvm/pr-subscribers-llvm-support Author: Florian Mayer (fmayer) ChangesFull diff: https://github.com/llvm/llvm-project/pull/143057.diff 1 Files Affected:
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('=');
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I was wondering whether we could just unconditionally enable debug counters, but doing that does have some meaningful overhead: https://llvm-compile-time-tracker.com/compare.php?from=100a1d0c4caad0d0f2ec26b07d3cc73f59b9a9a8&to=341c03268229f2982df1fd7ddb5e3db7a2e7731a&stat=instructions:u
Co-authored-by: Nikita Popov <[email protected]>
✅ With the latest revision this PR passed the C/C++ code formatter. |
…m#143057) Co-authored-by: Nikita Popov <[email protected]>
…m#143057) Co-authored-by: Nikita Popov <[email protected]>
…m#143057) Co-authored-by: Nikita Popov <[email protected]>
No description provided.