summaryrefslogtreecommitdiff
path: root/llvm/lib/Support/DebugCounter.cpp
AgeCommit message (Collapse)Author
2025-06-06[NFC] [DebugCounter] warn if --debug-counter is unused in NDEBUG (#143057)Florian Mayer
Co-authored-by: Nikita Popov <npopov@redhat.com>
2025-05-14[llvm] properly guard dump methods in Support lib classes (#139938)Andrew Rogers
## Purpose Add proper preprocessor guards for all `dump()` methods in the LLVM support library. This change ensures these methods are not part of the public ABI for release builds. ## Overview * Annotates all `dump` methods in Support and ADT source with the `LLVM_DUMP_METHOD` macro. * Conditionally includes all `dump` method definitions in Support and ADT source so they are only present on debug/assert builds and when `LLVM_ENABLE_DUMP` is explicitly defined. NOTE: For many of these `dump` methods, the implementation was already properly guarded but the declaration in the header file was not. ## Background This PR is a redo of #139804 with some changes to fix clang and unit test build breaks. This issue was raised in comments on #136629. I am addressing it as a separate change since it is independent from the changes being made in that PR. According to [this documentation](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/Compiler.h#L637), `dump` methods should be annotated with `LLVM_DUMP_METHOD` and conditionally included as follows: ``` #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void dump() const; #endif ``` ## Validation * Local release build succeeds. * CI
2025-05-14Revert "[llvm] properly guard dump methods in Support lib classes" (#139927)Andrew Rogers
Reverts llvm/llvm-project#139804
2025-05-14[llvm] properly guard dump methods in Support lib classes (#139804)Andrew Rogers
## Purpose Add proper preprocessor guards for all `dump()` methods in the LLVM support library. This change ensures these methods are not part of the public ABI for release builds. ## Overview * Annotates all `dump` methods in Support and ADT source with the `LLVM_DUMP_METHOD` macro. * Conditionally includes all `dump` method definitions in Support and ADT source so they are only present on debug/assert builds and when `LLVM_ENABLE_DUMP` is explicitly defined. NOTE: For many of these `dump` methods, the implementation was already properly guarded but the declaration in the header file was not. ## Background This issue was raised in comments on #136629. I am addressing it as a separate change since it is independent from the changes being made in that PR. According to [this documentation](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/Compiler.h#L637), `dump` methods should be annotated with `LLVM_DUMP_METHOD` and conditionally included as follows: ``` #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void dump() const; #endif ``` ## Validation * Local release build succeeds. * CI
2025-03-12[Support] Avoid repeated hash lookups (NFC) (#130891)Kazu Hirata
Co-authored-by: Nikita Popov <github@npopov.com>
2024-05-28[DebugCounter] Add support for non-continous ranges. (#89470)Ralender
2023-11-03[Support] Use StringRef::starts_with/ends_with instead of ↵Simon Pilgrim
startswith/endswith. NFC. startswith/endswith wrap starts_with/ends_with and will eventually go away (to more closely match string_view)
2022-10-30ManagedStatic: remove from DebugCounterNicolai Hähnle
[Re-submit after earlier revert due to a test failure. Commit dce78646f07 ("clang-tblgen build: avoid duplicate inclusion of libLLVMSupport") is believe to address the root cause of the test failure.] Follow the pattern used in MLIR for the cl::opt instances. v2: - make DebugCounter::isCountingEnabled public so that the DebugCounterOwner doesn't have to be a nested class. This simplifies later changes v3: - remove the indirection via DebugCounterOwner::instance() Differential Revision: https://reviews.llvm.org/D129116
2022-08-26Revert "ManagedStatic: remove from DebugCounter"Nicolai Hähnle
This reverts commit b5b6ef1500af29b6aba71330d8aaf82ecccb1f37.
2022-08-26ManagedStatic: remove from DebugCounterNicolai Hähnle
Follow the pattern used in MLIR for the cl::opt instances. v2: - make DebugCounter::isCountingEnabled public so that the DebugCounterOwner doesn't have to be a nested class. This simplifies later changes v3: - remove the indirection via DebugCounterOwner::instance() Differential Revision: https://reviews.llvm.org/D129116
2022-08-25Revert "ManagedStatic: remove from DebugCounter"Nicolai Hähnle
This reverts commit 51d82502d98d3c5d60606e63b6c23bb5759fdb91. There is a regression in the flang-aarch64-dylib buildbot which is most likely caused by this change. Reverting until I can investigate.
2022-08-25ManagedStatic: remove from DebugCounterNicolai Hähnle
Follow the pattern used in MLIR for the cl::opt instances. v2: - make DebugCounter::isCountingEnabled public so that the DebugCounterOwner doesn't have to be a nested class. This simplifies later changes Differential Revision: https://reviews.llvm.org/D129116
2022-06-05Remove unneeded cl::ZeroOrMore for cl::opt/cl::list optionsFangrui Song
2021-07-16Use ManagedStatic and lazy initialization of cl::opt in libSupport to make ↵Mehdi Amini
it free of global initializer We can build it with -Werror=global-constructors now. This helps in situation where libSupport is embedded as a shared library, potential with dlopen/dlclose scenario, and when command-line parsing or other facilities may not be involved. Avoiding the implicit construction of these cl::opt can avoid double-registration issues and other kind of behavior. Reviewed By: lattner, jpienaar Differential Revision: https://reviews.llvm.org/D105959
2021-07-16Revert "Use ManagedStatic and lazy initialization of cl::opt in libSupport ↵Mehdi Amini
to make it free of global initializer" This reverts commit af9321739b20becf170e6bb5060b8d780e1dc8dd. Still some specific config broken in some way that requires more investigation.
2021-07-16Use ManagedStatic and lazy initialization of cl::opt in libSupport to make ↵Mehdi Amini
it free of global initializer We can build it with -Werror=global-constructors now. This helps in situation where libSupport is embedded as a shared library, potential with dlopen/dlclose scenario, and when command-line parsing or other facilities may not be involved. Avoiding the implicit construction of these cl::opt can avoid double-registration issues and other kind of behavior. Reviewed By: lattner, jpienaar Differential Revision: https://reviews.llvm.org/D105959
2021-07-16Revert "Use ManagedStatic and lazy initialization of cl::opt in libSupport ↵Mehdi Amini
to make it free of global initializer" This reverts commit 42f588f39c5ce6f521e3709b8871d1fdd076292f. Broke some buildbots
2021-07-16Use ManagedStatic and lazy initialization of cl::opt in libSupport to make ↵Mehdi Amini
it free of global initializer We can build it with -Werror=global-constructors now. This helps in situation where libSupport is embedded as a shared library, potential with dlopen/dlclose scenario, and when command-line parsing or other facilities may not be involved. Avoiding the implicit construction of these cl::opt can avoid double-registration issues and other kind of behavior. Reviewed By: lattner, jpienaar Differential Revision: https://reviews.llvm.org/D105959
2021-01-17[llvm] Use llvm::sort (NFC)Kazu Hirata
2020-07-09DebugCounterList::printOptionInfo - use const auto& iterator in for-range-loop.Simon Pilgrim
Avoids unnecessary copies and silences clang tidy warning.
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-11-15Remove Support/Options.h, it is unusedReid Kleckner
It was added in 2014 in 732e0aa9fb84f1 with one use in Scalarizer.cpp. That one use was then removed when porting to the new pass manager in 2018 in b6f76002d9158628e78. While the RFC and the desire to get off of static initializers for cl::opt all still stand, this code is now dead, and I think we should delete this code until someone is ready to do the migration. There were many clients of CommandLine.h that were it transitively through LLVMContext.h, so I cleaned that up in 4c1a1d3cf97e1ede466. Reviewers: beanz Differential Revision: https://reviews.llvm.org/D70280
2018-10-23Print out DebugCounter info with -print-debug-counterZhizhou Yang
Summary: This patch will print out {Counter, Skip, StopAfter} info of all passes which have DebugCounter set at destruction. It can be used to monitor how many times does certain transformation happen in a pass, and also help check if -debug-counter option is set correctly. Please refer to this [[ http://lists.llvm.org/pipermail/llvm-dev/2018-July/124722.html | thread ]] for motivation. Reviewers: george.burgess.iv, davide, greened Reviewed By: greened Subscribers: kristina, llozano, mgorny, llvm-commits, mgrang Differential Revision: https://reviews.llvm.org/D50031 llvm-svn: 345085
2018-08-17[DebugCounters] don't do redundant map lookups; NFCGeorge Burgess IV
llvm-svn: 340104
2018-08-02[Support] Add an enable bit to our DebugCountersGeorge Burgess IV
r337748 made us start incrementing DebugCounters all of the time. This makes tsan unhappy in multithreaded environments. Since it doesn't make much sense to use DebugCounters with multiple threads, this patch makes us only count anything if the user passed a -debug-counter option or if some other piece of code explicitly asks for it (e.g. the pass in D50031). The amount of global state here makes writing a unittest for this behavior somewhat awkward. So, no test is provided. Differential Revision: https://reviews.llvm.org/D50150 llvm-svn: 338762
2018-07-23[DebugCounters] Keep track of total countsGeorge Burgess IV
This patch makes debug counters keep track of the total number of times we've called `shouldExecute` for each counter, so it's easier to build automated tooling on top of these. A patch to print these counts is coming soon. Patch by Zhizhou Yang! Differential Revision: https://reviews.llvm.org/D49560 llvm-svn: 337748
2018-04-01[DebugCounter] Make -debug-counter cl::Hidden.Craig Topper
llvm-svn: 328948
2017-06-14Hide dbgs() stream for when built with -fmodules.Frederich Munch
Summary: Make DebugCounter::print and dump methods to be const correct. Reviewers: aprantl Reviewed By: aprantl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34214 llvm-svn: 305408
2017-05-26Make helper functions static. NFC.Benjamin Kramer
llvm-svn: 304029
2017-03-04DebugCounter: Initialize skip to 0, not -1Daniel Berlin
llvm-svn: 296971
2017-02-19Add two files lost in rebase, causing build breakDaniel Berlin
llvm-svn: 295595