[PATCH] D44464: OptBisect is improved to be overridden in LLVMContext
Yevgeny Rouban via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 14 05:07:52 PDT 2018
yrouban created this revision.
yrouban added reviewers: andrew.w.kaylor, vsk, dberlin, Eugene.Zelenko, fedor.sergeev, reames, skatkov.
This patch changes the OptBisect class to allow overriding its main method checkPass() in subclasses. A new instance field OptBisector and a new method SetOptBisect() are added to the LLVMContext class. These changes allow to set a custom OptBisect class that can make its own decisions on skipping optional passes. Another important feature of this change is ability to set different instances of OptBisect to different LLVMContexts. So the different contexts can be used independently in several compiling threads of one process.
https://reviews.llvm.org/D44464
Files:
include/llvm/IR/LLVMContext.h
include/llvm/IR/OptBisect.h
lib/IR/LLVMContext.cpp
lib/IR/LLVMContextImpl.cpp
lib/IR/LLVMContextImpl.h
Index: lib/IR/LLVMContextImpl.h
===================================================================
--- lib/IR/LLVMContextImpl.h
+++ lib/IR/LLVMContextImpl.h
@@ -1355,9 +1355,15 @@
/// Destroy the ConstantArrays if they are not used.
void dropTriviallyDeadConstantArrays();
+ OptBisect *OptBisector;
+
/// \brief Access the object which manages optimization bisection for failure
/// analysis.
OptBisect &getOptBisect();
+
+ /// \brief Set the object which manages optimization bisection for failure
+ /// analysis.
+ void setOptBisect(OptBisect&);
};
} // end namespace llvm
Index: lib/IR/LLVMContextImpl.cpp
===================================================================
--- lib/IR/LLVMContextImpl.cpp
+++ lib/IR/LLVMContextImpl.cpp
@@ -39,7 +39,8 @@
Int16Ty(C, 16),
Int32Ty(C, 32),
Int64Ty(C, 64),
- Int128Ty(C, 128) {}
+ Int128Ty(C, 128),
+ OptBisector(nullptr) {}
LLVMContextImpl::~LLVMContextImpl() {
// NOTE: We need to delete the contents of OwnedModules, but Module's dtor
@@ -234,5 +235,11 @@
static ManagedStatic<OptBisect> OptBisector;
OptBisect &LLVMContextImpl::getOptBisect() {
+ if (!OptBisector)
+ OptBisector = &(*::OptBisector);
return *OptBisector;
}
+
+void LLVMContextImpl::setOptBisect(OptBisect& OB) {
+ OptBisector = &OB;
+}
Index: lib/IR/LLVMContext.cpp
===================================================================
--- lib/IR/LLVMContext.cpp
+++ lib/IR/LLVMContext.cpp
@@ -335,6 +335,9 @@
OptBisect &LLVMContext::getOptBisect() {
return pImpl->getOptBisect();
}
+void LLVMContext::setOptBisect(OptBisect& OB) {
+ pImpl->setOptBisect(OB);
+}
const DiagnosticHandler *LLVMContext::getDiagHandlerPtr() const {
return pImpl->DiagHandler.get();
Index: include/llvm/IR/OptBisect.h
===================================================================
--- include/llvm/IR/OptBisect.h
+++ include/llvm/IR/OptBisect.h
@@ -36,6 +36,8 @@
/// through LLVMContext.
OptBisect();
+ virtual ~OptBisect() {}
+
/// Checks the bisect limit to determine if the specified pass should run.
///
/// This function will immediate return true if bisection is disabled. If the
@@ -51,8 +53,8 @@
template <class UnitT>
bool shouldRunPass(const Pass *P, const UnitT &U);
-private:
- bool checkPass(const StringRef PassName, const StringRef TargetDesc);
+protected:
+ virtual bool checkPass(const StringRef PassName, const StringRef TargetDesc);
bool BisectEnabled = false;
unsigned LastBisectNum = 0;
Index: include/llvm/IR/LLVMContext.h
===================================================================
--- include/llvm/IR/LLVMContext.h
+++ include/llvm/IR/LLVMContext.h
@@ -318,6 +318,11 @@
/// \brief Access the object which manages optimization bisection for failure
/// analysis.
OptBisect &getOptBisect();
+
+ /// \brief Set the object which manages optimization bisection for failure
+ /// analysis.
+ void setOptBisect(OptBisect&);
+
private:
// Module needs access to the add/removeModule methods.
friend class Module;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44464.138330.patch
Type: text/x-patch
Size: 3072 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180314/6e4e54eb/attachment.bin>
More information about the llvm-commits
mailing list