aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/LLVMContext.cpp
diff options
context:
space:
mode:
authorJuergen Ributzka <juergen@apple.com>2014-04-28 18:19:25 +0000
committerJuergen Ributzka <juergen@apple.com>2014-04-28 18:19:25 +0000
commit4989255432a7954ce8c3937a3561595891edf83d (patch)
tree3708381fd96f0ffcca677eb497a7bb1745af51a8 /llvm/lib/IR/LLVMContext.cpp
parent4482dcd0721794fc7560b6b5022e47a69df901c2 (diff)
downloadllvm-4989255432a7954ce8c3937a3561595891edf83d.zip
llvm-4989255432a7954ce8c3937a3561595891edf83d.tar.gz
llvm-4989255432a7954ce8c3937a3561595891edf83d.tar.bz2
[PM] Add pass run listeners to the pass manager.
This commit provides the necessary C/C++ APIs and infastructure to enable fine- grain progress report and safe suspension points after each pass in the pass manager. Clients can provide a callback function to the pass manager to call after each pass. This can be used in a variety of ways (progress report, dumping of IR between passes, safe suspension of threads, etc). The run listener list is maintained in the LLVMContext, which allows a multi- threaded client to be only informed for it's own thread. This of course assumes that the client created a LLVMContext for each thread. This fixes <rdar://problem/16728690> llvm-svn: 207430
Diffstat (limited to 'llvm/lib/IR/LLVMContext.cpp')
-rw-r--r--llvm/lib/IR/LLVMContext.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp
index 588e121..b2d3bc9 100644
--- a/llvm/lib/IR/LLVMContext.cpp
+++ b/llvm/lib/IR/LLVMContext.cpp
@@ -214,3 +214,23 @@ void LLVMContext::getMDKindNames(SmallVectorImpl<StringRef> &Names) const {
E = pImpl->CustomMDKindNames.end(); I != E; ++I)
Names[I->second] = I->first();
}
+
+//===----------------------------------------------------------------------===//
+// Pass Run Listeners
+//===----------------------------------------------------------------------===//
+/// Notify that we finished running a pass.
+void LLVMContext::notifyPassRun(Pass *P, Module *M, Function *F, BasicBlock *BB)
+{
+ pImpl->notifyPassRun(this, P, M, F, BB);
+}
+/// Register the given PassRunListener to receive notifyPassRun() callbacks
+/// whenever a pass ran. The context will take ownership of the listener and
+/// free it when the context is destroyed.
+void LLVMContext::addRunListener(PassRunListener *L) {
+ pImpl->addRunListener(L);
+}
+/// Unregister a PassRunListener so that it no longer receives notifyPassRun()
+/// callbacks. Remove and free the listener from the context.
+void LLVMContext::removeRunListener(PassRunListener *L) {
+ pImpl->removeRunListener(L);
+}