LLVM  14.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 #include <limits>
21 
22 using namespace llvm;
23 
24 static cl::opt<int> OptBisectLimit("opt-bisect-limit", cl::Hidden,
26  cl::cb<void, int>([](int Limit) {
27  llvm::OptBisector->setLimit(Limit);
28  }),
29  cl::desc("Maximum optimization to perform"));
30 
31 static void printPassMessage(const StringRef &Name, int PassNum,
32  StringRef TargetDesc, bool Running) {
33  StringRef Status = Running ? "" : "NOT ";
34  errs() << "BISECT: " << Status << "running pass "
35  << "(" << PassNum << ") " << Name << " on " << TargetDesc << "\n";
36 }
37 
38 bool OptBisect::shouldRunPass(const Pass *P, StringRef IRDescription) {
39  assert(isEnabled());
40 
41  return checkPass(P->getPassName(), IRDescription);
42 }
43 
45  const StringRef TargetDesc) {
46  assert(isEnabled());
47 
48  int CurBisectNum = ++LastBisectNum;
49  bool ShouldRun = (BisectLimit == -1 || CurBisectNum <= BisectLimit);
50  printPassMessage(PassName, CurBisectNum, TargetDesc, ShouldRun);
51  return ShouldRun;
52 }
53 
54 const int OptBisect::Disabled;
55 
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
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
OptBisectLimit
static cl::opt< int > OptBisectLimit("opt-bisect-limit", cl::Hidden, cl::init(OptBisect::Disabled), cl::Optional, cl::cb< void, int >([](int Limit) { llvm::OptBisector->setLimit(Limit);}), cl::desc("Maximum optimization to perform"))
llvm::cl::cb
Definition: CommandLine.h:484
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
OptBisect.h
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:892
CommandLine.h
llvm::OptBisect::Disabled
static const int Disabled
Definition: OptBisect.h:84
llvm::ManagedStatic
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
Definition: ManagedStatic.h:83
llvm::cl::opt
Definition: CommandLine.h:1434
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:38
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:44
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Status
Definition: SIModeRegister.cpp:28
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
printPassMessage
static void printPassMessage(const StringRef &Name, int PassNum, StringRef TargetDesc, bool Running)
Definition: OptBisect.cpp:31
llvm::cl::Optional
@ Optional
Definition: CommandLine.h:119
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::OptBisector
ManagedStatic< OptBisect > OptBisector
Singleton instance of the OptBisect class, so multiple pass managers don't need to coordinate their u...
Definition: OptBisect.cpp:56
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:62
llvm::cl::desc
Definition: CommandLine.h:414
raw_ostream.h
PassName
static const char PassName[]
Definition: X86LowerAMXIntrinsics.cpp:669