[SIL] Add support for delete notification handlers.

This commit adds the basic support for delete notification handlers. The SIL
Module is notified every time an instruction is deleted. The module will forward
notification messages to users who ask to be notified.  The motivation for this
work is described in the upcoming commit to OptimizerDesign.md.
This commit is contained in:
Nadav Rotem
2015-12-04 07:10:49 -08:00
parent 5ba9a3785b
commit 37991af1cf
4 changed files with 78 additions and 0 deletions

View File

@@ -37,6 +37,12 @@ SILBasicBlock::SILBasicBlock(SILFunction *parent, SILBasicBlock *afterBB)
}
}
SILBasicBlock::~SILBasicBlock() {
// Notify the delete handlers that the instructions in this block are
// being deleted.
for (auto I = begin(), E = end(); I != E; ++I) {
getModule().notifyDeleteHandlers(&*I);
}
// iplist's destructor is going to destroy the InstList.
}
@@ -69,6 +75,8 @@ void SILBasicBlock::push_front(SILInstruction *I) {
}
void SILBasicBlock::remove(SILInstruction *I) {
// Notify the delete handlers that this instruction is going away.
getModule().notifyDeleteHandlers(&*I);
InstList.remove(I);
}