Revert " [LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)"
[llvm-project.git] / llvm / lib / IR / OptBisect.cpp
blob893a5e59c86a69f7e75010345e5b4792acfb5b69
1 //===- llvm/IR/OptBisect/Bisect.cpp - LLVM Bisect support -----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 /// This file implements support for a bisecting optimizations based on a
11 /// command line option.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/IR/OptBisect.h"
16 #include "llvm/Pass.h"
17 #include "llvm/Support/CommandLine.h"
18 #include "llvm/Support/raw_ostream.h"
19 #include <cassert>
21 using namespace llvm;
23 static OptBisect &getOptBisector() {
24 static OptBisect OptBisector;
25 return OptBisector;
28 static cl::opt<int> OptBisectLimit("opt-bisect-limit", cl::Hidden,
29 cl::init(OptBisect::Disabled), cl::Optional,
30 cl::cb<void, int>([](int Limit) {
31 getOptBisector().setLimit(Limit);
32 }),
33 cl::desc("Maximum optimization to perform"));
35 static void printPassMessage(const StringRef &Name, int PassNum,
36 StringRef TargetDesc, bool Running) {
37 StringRef Status = Running ? "" : "NOT ";
38 errs() << "BISECT: " << Status << "running pass "
39 << "(" << PassNum << ") " << Name << " on " << TargetDesc << "\n";
42 bool OptBisect::shouldRunPass(const StringRef PassName,
43 StringRef IRDescription) {
44 assert(isEnabled());
46 int CurBisectNum = ++LastBisectNum;
47 bool ShouldRun = (BisectLimit == -1 || CurBisectNum <= BisectLimit);
48 printPassMessage(PassName, CurBisectNum, IRDescription, ShouldRun);
49 return ShouldRun;
52 const int OptBisect::Disabled;
54 OptPassGate &llvm::getGlobalPassGate() { return getOptBisector(); }