LLVM  16.0.0git
OptBisect.cpp
Go to the documentation of this file.
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.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "llvm/IR/OptBisect.h"
16 #include "llvm/Pass.h"
19 #include <cassert>
20 
21 using namespace llvm;
22 
23 static cl::opt<int> OptBisectLimit("opt-bisect-limit", cl::Hidden,
25  cl::cb<void, int>([](int Limit) {
27  }),
28  cl::desc("Maximum optimization to perform"));
29 
30 static void printPassMessage(const StringRef &Name, int PassNum,
31  StringRef TargetDesc, bool Running) {
32  StringRef Status = Running ? "" : "NOT ";
33  errs() << "BISECT: " << Status << "running pass "
34  << "(" << PassNum << ") " << Name << " on " << TargetDesc << "\n";
35 }
36 
37 bool OptBisect::shouldRunPass(const Pass *P, StringRef IRDescription) {
38  assert(isEnabled());
39 
40  return checkPass(P->getPassName(), IRDescription);
41 }
42 
44  const StringRef TargetDesc) {
45  assert(isEnabled());
46 
47  int CurBisectNum = ++LastBisectNum;
48  bool ShouldRun = (BisectLimit == -1 || CurBisectNum <= BisectLimit);
49  printPassMessage(PassName, CurBisectNum, TargetDesc, ShouldRun);
50  return ShouldRun;
51 }
52 
53 const int OptBisect::Disabled;
54 
56  static OptBisect OptBisector;
57  return OptBisector;
58 }
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
Pass.h
llvm::cl::cb
Definition: CommandLine.h:478
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:139
OptBisect.h
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:893
CommandLine.h
llvm::OptBisect::Disabled
static const int Disabled
Definition: OptBisect.h:83
llvm::OptBisect
This class implements a mechanism to disable passes and individual optimizations at compile time base...
Definition: OptBisect.h:44
llvm::cl::opt
Definition: CommandLine.h:1399
llvm::OptBisect::shouldRunPass
bool shouldRunPass(const Pass *P, StringRef IRDescription) override
Checks the bisect limit to determine if the specified pass should run.
Definition: OptBisect.cpp:37
llvm::OptBisect::checkPass
bool checkPass(const StringRef PassName, const StringRef TargetDesc)
Checks the bisect limit to determine if the specified pass should run.
Definition: OptBisect.cpp:43
llvm::getOptBisector
OptBisect & getOptBisector()
Singleton instance of the OptBisect class, so multiple pass managers don't need to coordinate their u...
Definition: OptBisect.cpp:55
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:439
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Status
Definition: SIModeRegister.cpp:29
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
printPassMessage
static void printPassMessage(const StringRef &Name, int PassNum, StringRef TargetDesc, bool Running)
Definition: OptBisect.cpp:30
llvm::cl::Optional
@ Optional
Definition: CommandLine.h:115
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
llvm::Pass
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:91
llvm::OptBisect::isEnabled
bool isEnabled() const override
isEnabled() should return true before calling shouldRunPass().
Definition: OptBisect.h:61
llvm::cl::desc
Definition: CommandLine.h:412
raw_ostream.h
llvm::OptBisect::setLimit
void setLimit(int Limit)
Set the new optimization limit and reset the counter.
Definition: OptBisect.h:65
OptBisectLimit
static cl::opt< int > OptBisectLimit("opt-bisect-limit", cl::Hidden, cl::init(OptBisect::Disabled), cl::Optional, cl::cb< void, int >([](int Limit) { llvm::getOptBisector().setLimit(Limit);}), cl::desc("Maximum optimization to perform"))
PassName
static const char PassName[]
Definition: X86LowerAMXIntrinsics.cpp:671