mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-20 16:17:38 +00:00
[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> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207430 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user