diff options
| author | Ralf Luther <luther.ralf@gmail.com> | 2019-03-27 20:23:17 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit2@aicp-server-3> | 2019-03-27 20:23:17 +0000 |
| commit | 1ce3a9d272e564b22a1333a1e36a3d3ab7cfab01 (patch) | |
| tree | 391382eadd4fec5bb480f2e8934fa352770221d1 /clang-r353983/include/llvm/IR/OptBisect.h | |
| parent | d1d48b140bafaa8a50107292f5fce95562575765 (diff) | |
| parent | 4f56932d3416ac03f646bc1a611b3135fec2fe08 (diff) | |
Merge "Update prebuilt Clang to r353983." into p9.0HEADp9.0-backupp9.0
Diffstat (limited to 'clang-r353983/include/llvm/IR/OptBisect.h')
| -rw-r--r-- | clang-r353983/include/llvm/IR/OptBisect.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/clang-r353983/include/llvm/IR/OptBisect.h b/clang-r353983/include/llvm/IR/OptBisect.h new file mode 100644 index 00000000..8d51b685 --- /dev/null +++ b/clang-r353983/include/llvm/IR/OptBisect.h @@ -0,0 +1,88 @@ +//===- llvm/IR/OptBisect.h - LLVM Bisect support ----------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// This file declares the interface for bisecting optimizations. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_IR_OPTBISECT_H +#define LLVM_IR_OPTBISECT_H + +#include "llvm/ADT/StringRef.h" + +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 : public OptPassGate { +public: + /// Default constructor, initializes the OptBisect state based on the + /// -opt-bisect-limit command line argument. + /// + /// By default, bisection is disabled. + /// + /// Clients should not instantiate this class directly. All access should go + /// through LLVMContext. + OptBisect(); + + virtual ~OptBisect() = default; + + /// Checks the bisect limit to determine if the specified pass should run. + /// + /// 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 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 exceeded or false if it has. + /// + /// 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); + + bool BisectEnabled = false; + unsigned LastBisectNum = 0; +}; + +} // end namespace llvm + +#endif // LLVM_IR_OPTBISECT_H |
