summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorFedor Sergeev <fedor.sergeev@azul.com>2018-04-05 10:29:37 +0000
committerFedor Sergeev <fedor.sergeev@azul.com>2018-04-05 10:29:37 +0000
commitd29884c7e6fac28d8af07ab6c818575c75664d3b (patch)
treec601cf05f93870f25ce0be44d33d4d6d4078054d /llvm/lib/IR
parent978502f4758216ef21ff478ea0d9eb5cc5b2369f (diff)
downloadbcm5719-llvm-d29884c7e6fac28d8af07ab6c818575c75664d3b.tar.gz
bcm5719-llvm-d29884c7e6fac28d8af07ab6c818575c75664d3b.zip
allow custom OptBisect classes set to LLVMContext
This patch introduces a way to set custom OptPassGate instances to LLVMContext. A new instance field OptBisector and a new method setOptBisect() are added to the LLVMContext classes. 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 OptPassGate to different LLVMContexts. So the different contexts can be used independently in several compiling threads of one process. One unit test is added. Patch by Yevgeny Rouban. Reviewers: andrew.w.kaylor, fedor.sergeev, vsk, dberlin, Eugene.Zelenko, reames, skatkov Reviewed By: andrew.w.kaylor, fedor.sergeev Differential Revision: https://reviews.llvm.org/D44464 llvm-svn: 329267
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/LLVMContext.cpp6
-rw-r--r--llvm/lib/IR/LLVMContextImpl.cpp10
-rw-r--r--llvm/lib/IR/LLVMContextImpl.h15
3 files changed, 25 insertions, 6 deletions
diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp
index 5b10854b6d2..62d9e387162 100644
--- a/llvm/lib/IR/LLVMContext.cpp
+++ b/llvm/lib/IR/LLVMContext.cpp
@@ -332,10 +332,14 @@ void LLVMContext::setDiscardValueNames(bool Discard) {
pImpl->DiscardValueNames = Discard;
}
-OptPassGate &LLVMContext::getOptPassGate() {
+OptPassGate &LLVMContext::getOptPassGate() const {
return pImpl->getOptPassGate();
}
+void LLVMContext::setOptPassGate(OptPassGate& OPG) {
+ pImpl->setOptPassGate(OPG);
+}
+
const DiagnosticHandler *LLVMContext::getDiagHandlerPtr() const {
return pImpl->DiagHandler.get();
}
diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp
index 7998f282a47..53dd4d57ab8 100644
--- a/llvm/lib/IR/LLVMContextImpl.cpp
+++ b/llvm/lib/IR/LLVMContextImpl.cpp
@@ -233,6 +233,12 @@ void LLVMContextImpl::getSyncScopeNames(
/// enabled in order to enable a consistent bisect count.
static ManagedStatic<OptBisect> OptBisector;
-OptPassGate &LLVMContextImpl::getOptPassGate() {
- return *OptBisector;
+OptPassGate &LLVMContextImpl::getOptPassGate() const {
+ if (!OPG)
+ OPG = &(*OptBisector);
+ return *OPG;
+}
+
+void LLVMContextImpl::setOptPassGate(OptPassGate& OPG) {
+ this->OPG = &OPG;
}
diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h
index 51ed118cb66..b2ba9d38a81 100644
--- a/llvm/lib/IR/LLVMContextImpl.h
+++ b/llvm/lib/IR/LLVMContextImpl.h
@@ -1355,9 +1355,18 @@ public:
/// Destroy the ConstantArrays if they are not used.
void dropTriviallyDeadConstantArrays();
- /// \brief Access the object which manages optimization bisection for failure
- /// analysis.
- OptPassGate &getOptPassGate();
+ mutable OptPassGate *OPG = nullptr;
+
+ /// \brief Access the object which can disable optional passes and individual
+ /// optimizations at compile time.
+ OptPassGate &getOptPassGate() const;
+
+ /// \brief Set the object which can disable optional passes and individual
+ /// optimizations at compile time.
+ ///
+ /// The lifetime of the object must be guaranteed to extend as long as the
+ /// LLVMContext is used by compilation.
+ void setOptPassGate(OptPassGate&);
};
} // end namespace llvm
OpenPOWER on IntegriCloud