@@ -85,8 +85,10 @@ class InstModCallbacks {
8585 // / immediately remove all references to the instruction, including the parent
8686 // / block list.
8787 // /
88- // / TODO: When zombie instructions are implemented at the module level, we
89- // / should move the eraseFromParent() functionality out of the callback.
88+ // / TODO: Now that instructions deletion can be delayed via
89+ // / SILModule::scheduleForDeletion(); there's no longer a good use case for
90+ // / calling eraseFromParent() within this callback. Rewrite all clients
91+ // / without doing the instruction deletion within the callback.
9092 std::function<void (SILInstruction *instToDelete)> deleteInstFunc;
9193
9294 // / If non-null, called before a salient instruction is deleted or has its
@@ -385,8 +387,13 @@ bool tryCheckedCastBrJumpThreading(
385387
386388// / A utility for deleting one or more instructions belonging to a function, and
387389// / cleaning up any dead code resulting from deleting those instructions. Use
388- // / this utility instead of
389- // / \c recursivelyDeleteTriviallyDeadInstruction.
390+ // / this utility instead of \p recursivelyDeleteTriviallyDeadInstruction
391+ // / as follows:
392+ // / InstructionDeleter deleter;
393+ // / deleter.deleteIfDead(instruction);
394+ // / deleter.cleanupDeadInstructions();
395+ // /
396+ // /
390397// /
391398// / This is designed to be used with a single 'onDelete' callback, which is
392399// / invoked consistently just before deleting each instruction. It's usually
@@ -446,28 +453,27 @@ class InstructionDeleter {
446453 // / Calls callbacks.notifyWillBeDeleted().
447454 bool trackIfDead (SILInstruction *inst);
448455
449- // / Force track this instruction as dead. Used to enable the deletion of a
450- // / bunch of instructions at the same time.
456+ // / Track this instruction as dead even if it has side effects. Used to enable
457+ // / the deletion of a bunch of instructions at the same time.
451458 // /
452459 // / Calls callbacks.notifyWillBeDeleted().
453460 void forceTrackAsDead (SILInstruction *inst);
454461
455462 // / If the instruction \p inst is dead, delete it immediately along with its
456- // / destroys and scope-ending uses, and record its operands so that they can
457- // / be cleaned up later.
463+ // / destroys and scope-ending uses. If any operand definitions will become
464+ // / dead after deleting this instruction, track them so they can be deleted
465+ // / later during cleanUpDeadInstructions().
458466 // /
459467 // / Calls callbacks.notifyWillBeDeleted().
460468 bool deleteIfDead (SILInstruction *inst);
461469
462- // / Delete the instruction \p inst and record instructions that may become
463- // / dead because of the removal of \c inst. This function will add necessary
464- // / ownership instructions to fix the lifetimes of the operands of \c inst to
465- // / compensate for its deletion. This function will not clean up dead code
466- // / resulting from the instruction's removal. To do so, invoke the method \c
467- // / cleanupDeadCode of this instance, once the SIL of the contaning function
468- // / is made consistent.
470+ // / Delete the instruction \p inst, ignoring its side effects. If any operand
471+ // / definitions will become dead after deleting this instruction, track them
472+ // / so they can be deleted later during cleanUpDeadInstructions(). This
473+ // / function will add necessary ownership instructions to fix the lifetimes of
474+ // / the operands of \p inst to compensate for its deletion.
469475 // /
470- // / \pre the function containing \c inst must be using ownership SIL.
476+ // / \pre the function containing \p inst must be using ownership SIL.
471477 // / \pre the instruction to be deleted must not have any use other than
472478 // / incidental uses.
473479 // /
0 commit comments