From 4e0cc51d7974029aa2bbffce08e2c878f529f98a Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Mon, 28 Apr 2014 18:19:25 +0000 Subject: [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207430 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/Pass.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/IR/Pass.cpp') diff --git a/lib/IR/Pass.cpp b/lib/IR/Pass.cpp index bb55d2af7c..58ae821db2 100644 --- a/lib/IR/Pass.cpp +++ b/lib/IR/Pass.cpp @@ -17,6 +17,7 @@ #include "llvm/IR/Function.h" #include "llvm/IR/IRPrintingPasses.h" #include "llvm/IR/LegacyPassNameParser.h" +#include "llvm/IR/LLVMContext.h" #include "llvm/PassRegistry.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" @@ -242,6 +243,18 @@ void PassRegistrationListener::enumeratePasses() { PassRegistry::getPassRegistry()->enumerateWith(this); } +//===----------------------------------------------------------------------===// +// PassRunListener implementation +// + +// PassRunListener ctor - Add the current object to the list of +// PassRunListeners... +PassRunListener::PassRunListener(LLVMContext *C) { + C->addRunListener(this); +} + +PassRunListener::~PassRunListener() {} + PassNameParser::~PassNameParser() {} //===----------------------------------------------------------------------===// -- cgit v1.2.3