]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/IR/OptBisect.h
Merge content currently under test from ^/vendor/NetBSD/tests/dist/@r312123
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / IR / OptBisect.h
1 //===----------- llvm/IR/OptBisect.h - LLVM Bisect support -------------===//
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 namespace llvm {
19
20 class Pass;
21 class StringRef;
22 class Twine;
23
24 /// This class implements a mechanism to disable passes and individual
25 /// optimizations at compile time based on a command line option
26 /// (-opt-bisect-limit) in order to perform a bisecting search for
27 /// optimization-related problems.
28 class OptBisect {
29 public:
30   /// \brief Default constructor, initializes the OptBisect state based on the
31   /// -opt-bisect-limit command line argument.
32   ///
33   /// By default, bisection is disabled.
34   ///
35   /// Clients should not instantiate this class directly.  All access should go
36   /// through LLVMContext.
37   OptBisect();
38
39   /// Checks the bisect limit to determine if the specified pass should run.
40   ///
41   /// This function will immediate return true if bisection is disabled. If the
42   /// bisect limit is set to -1, the function will print a message describing
43   /// the pass and the bisect number assigned to it and return true.  Otherwise,
44   /// the function will print a message with the bisect number assigned to the
45   /// pass and indicating whether or not the pass will be run and return true if
46   /// the bisect limit has not yet been exceded or false if it has.
47   ///
48   /// Most passes should not call this routine directly.  Instead, it is called
49   /// through a helper routine provided by the pass base class.  For instance,
50   /// function passes should call FunctionPass::skipFunction().
51   template <class UnitT>
52   bool shouldRunPass(const Pass *P, const UnitT &U);
53
54   /// Checks the bisect limit to determine if the optimization described by the
55   /// /p Desc argument should run.
56   ///
57   /// This function will immediate return true if bisection is disabled. If the
58   /// bisect limit is set to -1, the function will print a message with the
59   /// bisect number assigned to the optimization along with the /p Desc
60   /// description and return true.  Otherwise, the function will print a message
61   /// with the bisect number assigned to the optimization and indicating whether
62   /// or not the pass will be run and return true if the bisect limit has not
63   /// yet been exceded or false if it has.
64   ///
65   /// Passes may call this function to provide more fine grained control over
66   /// individual optimizations performed by the pass.  Passes which cannot be
67   /// skipped entirely (such as non-optional code generation passes) may still
68   /// call this function to control whether or not individual optional
69   /// transformations are performed.
70   bool shouldRunCase(const Twine &Desc);
71
72 private:
73   bool checkPass(const StringRef PassName, const StringRef TargetDesc);
74
75   bool BisectEnabled = false;
76   unsigned LastBisectNum = 0;
77 };
78
79 } // end namespace llvm
80
81 #endif // LLVM_IR_OPTBISECT_H