Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
329098d
opt bisect skip
YonahGoldberg Aug 6, 2025
723514d
format
YonahGoldberg Aug 6, 2025
431c13b
comment
YonahGoldberg Aug 6, 2025
ec6842e
newline
YonahGoldberg Aug 6, 2025
6b3ed99
renaming
YonahGoldberg Aug 20, 2025
895a1bb
format
YonahGoldberg Aug 20, 2025
4b38209
range support
YonahGoldberg Sep 3, 2025
d3f5add
small changes
YonahGoldberg Sep 3, 2025
6f20867
remove opt-disable-indices
YonahGoldberg Sep 3, 2025
5f87193
remove
YonahGoldberg Sep 3, 2025
8ab62b3
cleanup
YonahGoldberg Sep 3, 2025
c3e5c7d
format
YonahGoldberg Sep 3, 2025
4cf5a99
use Expect for Range
YonahGoldberg Sep 3, 2025
0eefd68
format
YonahGoldberg Sep 3, 2025
a159538
fix hang
YonahGoldberg Sep 3, 2025
3215304
fix error handling tests
YonahGoldberg Sep 3, 2025
af7873f
format
YonahGoldberg Sep 4, 2025
c27ce56
cleanup
YonahGoldberg Sep 4, 2025
6c4fea1
clang format
YonahGoldberg Sep 4, 2025
5e1d443
fix minor formatting bug
YonahGoldberg Sep 4, 2025
466991d
small bug
YonahGoldberg Sep 4, 2025
0eaab13
format
YonahGoldberg Sep 4, 2025
5ce4228
allow -opt-bisect=0 and -opt-bisect=-1
YonahGoldberg Sep 4, 2025
095c358
comment change
YonahGoldberg Sep 4, 2025
dce302a
format
YonahGoldberg Sep 4, 2025
2b779d3
cleanup
YonahGoldberg Sep 5, 2025
5a80bfb
format
YonahGoldberg Sep 5, 2025
3616aa6
more cleanup
YonahGoldberg Sep 5, 2025
5882584
format
YonahGoldberg Sep 5, 2025
0f0499c
range test cleanup
YonahGoldberg Sep 5, 2025
1615205
format
YonahGoldberg Sep 5, 2025
98b2256
move range from struct -> class
YonahGoldberg Sep 5, 2025
debce85
better range size function
YonahGoldberg Sep 5, 2025
7db719f
range size checks
YonahGoldberg Sep 5, 2025
7f44558
format
YonahGoldberg Sep 5, 2025
6924b7b
format
YonahGoldberg Sep 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion llvm/include/llvm/IR/OptBisect.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#ifndef LLVM_IR_OPTBISECT_H
#define LLVM_IR_OPTBISECT_H

#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Compiler.h"
Expand Down Expand Up @@ -67,7 +68,13 @@ class LLVM_ABI OptBisect : public OptPassGate {
StringRef IRDescription) const override;

/// isEnabled() should return true before calling shouldRunPass().
bool isEnabled() const override { return BisectLimit != Disabled; }
bool isEnabled() const override {
return BisectLimit != Disabled || !BisectSkipNumbers.empty();
}

/// Add pass at index Index to the list of passes to skip
/// during bisection.
void disablePassAtIndex(int Index) { BisectSkipNumbers.insert(Index); }

/// Set the new optimization limit and reset the counter. Passing
/// OptBisect::Disabled disables the limiting.
Expand All @@ -81,6 +88,7 @@ class LLVM_ABI OptBisect : public OptPassGate {
private:
int BisectLimit = Disabled;
mutable int LastBisectNum = 0;
SmallSet<int, 4> BisectSkipNumbers;
};

/// This class implements a mechanism to disable passes and individual
Expand Down
12 changes: 11 additions & 1 deletion llvm/lib/IR/OptBisect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ static cl::opt<int> OptBisectLimit("opt-bisect-limit", cl::Hidden,
}),
cl::desc("Maximum optimization to perform"));

static cl::list<int>
OptDisableIndices("opt-disable-indices", cl::Hidden, cl::CommaSeparated,
cl::Optional, cl::cb<void, int>([](int Index) {
getOptBisector().disablePassAtIndex(Index);
}),
cl::desc("Disable passes at the given indices in the "
"optimization pipeline (comma-separated list)"));

static cl::opt<bool> OptBisectVerbose(
"opt-bisect-verbose",
cl::desc("Show verbose output when opt-bisect-limit is set"), cl::Hidden,
Expand Down Expand Up @@ -66,7 +74,9 @@ bool OptBisect::shouldRunPass(StringRef PassName,
assert(isEnabled());

int CurBisectNum = ++LastBisectNum;
bool ShouldRun = (BisectLimit == -1 || CurBisectNum <= BisectLimit);
bool ShouldRun = (BisectLimit == -1 || BisectLimit == Disabled ||
CurBisectNum <= BisectLimit) &&
!BisectSkipNumbers.contains(CurBisectNum);
if (OptBisectVerbose)
printPassMessage(PassName, CurBisectNum, IRDescription, ShouldRun);
return ShouldRun;
Expand Down