summaryrefslogtreecommitdiff
path: root/include/llvm/IR/OptBisect.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/IR/OptBisect.h')
-rw-r--r--include/llvm/IR/OptBisect.h48
1 files changed, 37 insertions, 11 deletions
diff --git a/include/llvm/IR/OptBisect.h b/include/llvm/IR/OptBisect.h
index 09e67aa79246..aa24c94c0130 100644
--- a/include/llvm/IR/OptBisect.h
+++ b/include/llvm/IR/OptBisect.h
@@ -20,14 +20,34 @@
namespace llvm {
class Pass;
+class Module;
+class Function;
+class BasicBlock;
+class Region;
+class Loop;
+class CallGraphSCC;
+
+/// Extensions to this class implement mechanisms to disable passes and
+/// individual optimizations at compile time.
+class OptPassGate {
+public:
+ virtual ~OptPassGate() = default;
+
+ virtual bool shouldRunPass(const Pass *P, const Module &U) { return true; }
+ virtual bool shouldRunPass(const Pass *P, const Function &U) {return true; }
+ virtual bool shouldRunPass(const Pass *P, const BasicBlock &U) { return true; }
+ virtual bool shouldRunPass(const Pass *P, const Region &U) { return true; }
+ virtual bool shouldRunPass(const Pass *P, const Loop &U) { return true; }
+ virtual bool shouldRunPass(const Pass *P, const CallGraphSCC &U) { return true; }
+};
/// This class implements a mechanism to disable passes and individual
/// optimizations at compile time based on a command line option
/// (-opt-bisect-limit) in order to perform a bisecting search for
/// optimization-related problems.
-class OptBisect {
+class OptBisect : public OptPassGate {
public:
- /// \brief Default constructor, initializes the OptBisect state based on the
+ /// Default constructor, initializes the OptBisect state based on the
/// -opt-bisect-limit command line argument.
///
/// By default, bisection is disabled.
@@ -36,20 +56,26 @@ public:
/// through LLVMContext.
OptBisect();
+ virtual ~OptBisect() = default;
+
/// Checks the bisect limit to determine if the specified pass should run.
///
- /// This function will immediate return true if bisection is disabled. If the
- /// bisect limit is set to -1, the function will print a message describing
+ /// These functions immediately return true if bisection is disabled. If the
+ /// bisect limit is set to -1, the functions print a message describing
/// the pass and the bisect number assigned to it and return true. Otherwise,
- /// the function will print a message with the bisect number assigned to the
+ /// the functions print a message with the bisect number assigned to the
/// pass and indicating whether or not the pass will be run and return true if
- /// the bisect limit has not yet been exceded or false if it has.
+ /// the bisect limit has not yet been exceeded or false if it has.
///
- /// Most passes should not call this routine directly. Instead, it is called
- /// through a helper routine provided by the pass base class. For instance,
- /// function passes should call FunctionPass::skipFunction().
- template <class UnitT>
- bool shouldRunPass(const Pass *P, const UnitT &U);
+ /// Most passes should not call these routines directly. Instead, they are
+ /// called through helper routines provided by the pass base classes. For
+ /// instance, function passes should call FunctionPass::skipFunction().
+ bool shouldRunPass(const Pass *P, const Module &U) override;
+ bool shouldRunPass(const Pass *P, const Function &U) override;
+ bool shouldRunPass(const Pass *P, const BasicBlock &U) override;
+ bool shouldRunPass(const Pass *P, const Region &U) override;
+ bool shouldRunPass(const Pass *P, const Loop &U) override;
+ bool shouldRunPass(const Pass *P, const CallGraphSCC &U) override;
private:
bool checkPass(const StringRef PassName, const StringRef TargetDesc);