aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/IR/OptBisect.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/lib/IR/OptBisect.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/IR/OptBisect.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/contrib/llvm-project/llvm/lib/IR/OptBisect.cpp b/contrib/llvm-project/llvm/lib/IR/OptBisect.cpp
index 2cf2298e0005..55c0dbad5aab 100644
--- a/contrib/llvm-project/llvm/lib/IR/OptBisect.cpp
+++ b/contrib/llvm-project/llvm/lib/IR/OptBisect.cpp
@@ -22,14 +22,12 @@
using namespace llvm;
static cl::opt<int> OptBisectLimit("opt-bisect-limit", cl::Hidden,
- cl::init(std::numeric_limits<int>::max()),
- cl::Optional,
+ cl::init(OptBisect::Disabled), cl::Optional,
+ cl::cb<void, int>([](int Limit) {
+ llvm::OptBisector->setLimit(Limit);
+ }),
cl::desc("Maximum optimization to perform"));
-OptBisect::OptBisect() : OptPassGate() {
- BisectEnabled = OptBisectLimit != std::numeric_limits<int>::max();
-}
-
static void printPassMessage(const StringRef &Name, int PassNum,
StringRef TargetDesc, bool Running) {
StringRef Status = Running ? "" : "NOT ";
@@ -38,19 +36,21 @@ static void printPassMessage(const StringRef &Name, int PassNum,
}
bool OptBisect::shouldRunPass(const Pass *P, StringRef IRDescription) {
- assert(BisectEnabled);
+ assert(isEnabled());
return checkPass(P->getPassName(), IRDescription);
}
bool OptBisect::checkPass(const StringRef PassName,
const StringRef TargetDesc) {
- assert(BisectEnabled);
+ assert(isEnabled());
int CurBisectNum = ++LastBisectNum;
- bool ShouldRun = (OptBisectLimit == -1 || CurBisectNum <= OptBisectLimit);
+ bool ShouldRun = (BisectLimit == -1 || CurBisectNum <= BisectLimit);
printPassMessage(PassName, CurBisectNum, TargetDesc, ShouldRun);
return ShouldRun;
}
+const int OptBisect::Disabled;
+
ManagedStatic<OptBisect> llvm::OptBisector;