summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/LLVMContextImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/LLVMContextImpl.cpp')
-rw-r--r--llvm/lib/IR/LLVMContextImpl.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp
index 30a1ca28c57..50740a0c348 100644
--- a/llvm/lib/IR/LLVMContextImpl.cpp
+++ b/llvm/lib/IR/LLVMContextImpl.cpp
@@ -15,11 +15,32 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Module.h"
+#include "llvm/PassSupport.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Regex.h"
#include <algorithm>
using namespace llvm;
+/// Notify that we finished running a pass.
+void LLVMContextImpl::notifyPassRun(LLVMContext *C, Pass *P, Module *M,
+ Function *F, BasicBlock *BB) {
+ for (auto const &L : RunListeners)
+ L->passRun(C, P, M, F, BB);
+}
+/// Register the given PassRunListener to receive notifyPassRun()
+/// callbacks whenever a pass ran.
+void LLVMContextImpl::addRunListener(PassRunListener *L) {
+ RunListeners.push_back(L);
+}
+/// Unregister a PassRunListener so that it no longer receives
+/// notifyPassRun() callbacks.
+void LLVMContextImpl::removeRunListener(PassRunListener *L) {
+ auto I = std::find(RunListeners.begin(), RunListeners.end(), L);
+ assert(I != RunListeners.end() && "RunListener not registered!");
+ delete *I;
+ RunListeners.erase(I);
+}
+
LLVMContextImpl::LLVMContextImpl(LLVMContext &C)
: TheTrueVal(nullptr), TheFalseVal(nullptr),
VoidTy(C, Type::VoidTyID),
@@ -188,6 +209,11 @@ LLVMContextImpl::~LLVMContextImpl() {
// Destroy MDStrings.
DeleteContainerSeconds(MDStringCache);
+
+ // Destroy all run listeners.
+ for (auto &L : RunListeners)
+ delete L;
+ RunListeners.clear();
}
// ConstantsContext anchors
OpenPOWER on IntegriCloud