[llvm] [OptBisect] Add support for selecting ranges of passes and refactor DebugCounter to use a shared Range API. (PR #152393)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 5 08:03:27 PDT 2025
================
@@ -30,12 +33,55 @@ static OptDisable &getOptDisabler() {
return OptDisabler;
}
-static cl::opt<int> OptBisectLimit("opt-bisect-limit", cl::Hidden,
- cl::init(OptBisect::Disabled), cl::Optional,
- cl::cb<void, int>([](int Limit) {
- getOptBisector().setLimit(Limit);
- }),
- cl::desc("Maximum optimization to perform"));
+static cl::opt<int> OptBisectLimit(
+ "opt-bisect-limit", cl::Hidden, cl::init(-1), cl::Optional,
+ cl::cb<void, int>([](int Limit) {
+ if (Limit == -1) {
+ // -1 means run all passes
+ getOptBisector().setRanges({{1, std::numeric_limits<int>::max()}});
+ } else if (Limit == 0) {
+ // 0 means run no passes
+ getOptBisector().setRanges({{0, 0}});
+ } else if (Limit > 0) {
+ // Convert limit to range 1-Limit
+ std::string RangeStr = Limit == 1 ? "1" : "1-" + llvm::utostr(Limit);
+ auto Ranges = RangeUtils::parseRanges(RangeStr);
----------------
nikic wrote:
Going through a string and then parsing it here is redundant? You can directly create the range.
https://github.com/llvm/llvm-project/pull/152393
More information about the llvm-commits
mailing list