LLVM  8.0.0svn
OptBisect.h
Go to the documentation of this file.
1 //===- llvm/IR/OptBisect.h - LLVM Bisect support ----------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// This file declares the interface for bisecting optimizations.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_IR_OPTBISECT_H
16 #define LLVM_IR_OPTBISECT_H
17 
18 #include "llvm/ADT/StringRef.h"
19 
20 namespace llvm {
21 
22 class Pass;
23 class Module;
24 class Function;
25 class BasicBlock;
26 class Region;
27 class Loop;
28 class CallGraphSCC;
29 
30 /// Extensions to this class implement mechanisms to disable passes and
31 /// individual optimizations at compile time.
32 class OptPassGate {
33 public:
34  virtual ~OptPassGate() = default;
35 
36  virtual bool shouldRunPass(const Pass *P, const Module &U) { return true; }
37  virtual bool shouldRunPass(const Pass *P, const Function &U) {return true; }
38  virtual bool shouldRunPass(const Pass *P, const BasicBlock &U) { return true; }
39  virtual bool shouldRunPass(const Pass *P, const Region &U) { return true; }
40  virtual bool shouldRunPass(const Pass *P, const Loop &U) { return true; }
41  virtual bool shouldRunPass(const Pass *P, const CallGraphSCC &U) { return true; }
42 };
43 
44 /// This class implements a mechanism to disable passes and individual
45 /// optimizations at compile time based on a command line option
46 /// (-opt-bisect-limit) in order to perform a bisecting search for
47 /// optimization-related problems.
48 class OptBisect : public OptPassGate {
49 public:
50  /// Default constructor, initializes the OptBisect state based on the
51  /// -opt-bisect-limit command line argument.
52  ///
53  /// By default, bisection is disabled.
54  ///
55  /// Clients should not instantiate this class directly. All access should go
56  /// through LLVMContext.
57  OptBisect();
58 
59  virtual ~OptBisect() = default;
60 
61  /// Checks the bisect limit to determine if the specified pass should run.
62  ///
63  /// These functions immediately return true if bisection is disabled. If the
64  /// bisect limit is set to -1, the functions print a message describing
65  /// the pass and the bisect number assigned to it and return true. Otherwise,
66  /// the functions print a message with the bisect number assigned to the
67  /// pass and indicating whether or not the pass will be run and return true if
68  /// the bisect limit has not yet been exceeded or false if it has.
69  ///
70  /// Most passes should not call these routines directly. Instead, they are
71  /// called through helper routines provided by the pass base classes. For
72  /// instance, function passes should call FunctionPass::skipFunction().
73  bool shouldRunPass(const Pass *P, const Module &U) override;
74  bool shouldRunPass(const Pass *P, const Function &U) override;
75  bool shouldRunPass(const Pass *P, const BasicBlock &U) override;
76  bool shouldRunPass(const Pass *P, const Region &U) override;
77  bool shouldRunPass(const Pass *P, const Loop &U) override;
78  bool shouldRunPass(const Pass *P, const CallGraphSCC &U) override;
79 
80 private:
81  bool checkPass(const StringRef PassName, const StringRef TargetDesc);
82 
83  bool BisectEnabled = false;
84  unsigned LastBisectNum = 0;
85 };
86 
87 } // end namespace llvm
88 
89 #endif // LLVM_IR_OPTBISECT_H
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:81
virtual ~OptPassGate()=default
This class represents lattice values for constants.
Definition: AllocatorList.h:24
Various leaf nodes.
Definition: ISDOpcodes.h:60
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
Extensions to this class implement mechanisms to disable passes and individual optimizations at compi...
Definition: OptBisect.h:32
virtual bool shouldRunPass(const Pass *P, const Region &U)
Definition: OptBisect.h:39
virtual bool shouldRunPass(const Pass *P, const Module &U)
Definition: OptBisect.h:36
This class implements a mechanism to disable passes and individual optimizations at compile time base...
Definition: OptBisect.h:48
#define P(N)
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
virtual bool shouldRunPass(const Pass *P, const Loop &U)
Definition: OptBisect.h:40
print lazy value Lazy Value Info Printer Pass
virtual bool shouldRunPass(const Pass *P, const BasicBlock &U)
Definition: OptBisect.h:38
virtual bool shouldRunPass(const Pass *P, const CallGraphSCC &U)
Definition: OptBisect.h:41
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:465
CallGraphSCC - This is a single SCC that a CallGraphSCCPass is run on.
virtual bool shouldRunPass(const Pass *P, const Function &U)
Definition: OptBisect.h:37
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49