Fix eraseFromParentWithdebugInsts to call a callback.

The recursivelyDeleteTriviallyDeadInstructions utility takes a
callBack to be called for every deleted instruction. However, it
wasn't passing this callBack to eraseFromParentWithdebugInsts. The
callback was used to update an iterator in some cases, so not calling
it resulted in iterator invalidation.

Doing this also cleans up the both APIs:
recursivelyDeleteTriviallyDeadInstructions and eraseFromParentWithdebugInsts.
This commit is contained in:
Andrew Trick
2019-05-06 13:27:24 -07:00
parent c3b7c194ec
commit ece096d91e
5 changed files with 39 additions and 65 deletions

View File

@@ -518,11 +518,13 @@ void SILInlineCloner::fixUp(SILFunction *calleeFunction) {
assert(!Apply.getInstruction()->hasUsesOfAnyResult());
auto deleteCallback = [this](SILInstruction *deletedI) {
if (NextIter == deletedI->getIterator())
++NextIter;
if (DeletionCallback)
DeletionCallback(deletedI);
};
NextIter = recursivelyDeleteTriviallyDeadInstructions(Apply.getInstruction(),
true, deleteCallback);
recursivelyDeleteTriviallyDeadInstructions(Apply.getInstruction(), true,
deleteCallback);
}
SILValue SILInlineCloner::borrowFunctionArgument(SILValue callArg,