LLVM  13.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,
27  cl::desc("Maximum optimization to perform"));
28 
30  BisectEnabled = OptBisectLimit != std::numeric_limits<int>::max();
31 }
32 
33 static void printPassMessage(const StringRef &Name, int PassNum,
34  StringRef TargetDesc, bool Running) {
35  StringRef Status = Running ? "" : "NOT ";
36  errs() << "BISECT: " << Status << "running pass "
37  << "(" << PassNum << ") " << Name << " on " << TargetDesc << "\n";
38 }
39 
40 bool OptBisect::shouldRunPass(const Pass *P, StringRef IRDescription) {
41  assert(BisectEnabled);
42 
43  return checkPass(P->getPassName(), IRDescription);
44 }
45 
47  const StringRef TargetDesc) {
48  assert(BisectEnabled);
49 
50  int CurBisectNum = ++LastBisectNum;
51  bool ShouldRun = (OptBisectLimit == -1 || CurBisectNum <= OptBisectLimit);
52  printPassMessage(PassName, CurBisectNum, TargetDesc, ShouldRun);
53  return ShouldRun;
54 }
55 
llvm::OptBisect::OptBisect
OptBisect()
Default constructor, initializes the OptBisect state based on the -opt-bisect-limit command line argu...
Definition: OptBisect.cpp:29
llvm
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
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::OptPassGate
Extensions to this class implement mechanisms to disable passes and individual optimizations at compi...
Definition: OptBisect.h:26
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:1422
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:40
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:46
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:33
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::max
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:340
llvm::cl::desc
Definition: CommandLine.h:414
raw_ostream.h
OptBisectLimit
static cl::opt< int > OptBisectLimit("opt-bisect-limit", cl::Hidden, cl::init(std::numeric_limits< int >::max()), cl::Optional, cl::desc("Maximum optimization to perform"))
PassName
static const char PassName[]
Definition: X86LowerAMXIntrinsics.cpp:669