@@ -85,8 +85,10 @@ class InstModCallbacks {
85
85
// / immediately remove all references to the instruction, including the parent
86
86
// / block list.
87
87
// /
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.
90
92
std::function<void (SILInstruction *instToDelete)> deleteInstFunc;
91
93
92
94
// / If non-null, called before a salient instruction is deleted or has its
@@ -385,8 +387,13 @@ bool tryCheckedCastBrJumpThreading(
385
387
386
388
// / A utility for deleting one or more instructions belonging to a function, and
387
389
// / 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
+ // /
390
397
// /
391
398
// / This is designed to be used with a single 'onDelete' callback, which is
392
399
// / invoked consistently just before deleting each instruction. It's usually
@@ -446,28 +453,27 @@ class InstructionDeleter {
446
453
// / Calls callbacks.notifyWillBeDeleted().
447
454
bool trackIfDead (SILInstruction *inst);
448
455
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.
451
458
// /
452
459
// / Calls callbacks.notifyWillBeDeleted().
453
460
void forceTrackAsDead (SILInstruction *inst);
454
461
455
462
// / 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().
458
466
// /
459
467
// / Calls callbacks.notifyWillBeDeleted().
460
468
bool deleteIfDead (SILInstruction *inst);
461
469
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.
469
475
// /
470
- // / \pre the function containing \c inst must be using ownership SIL.
476
+ // / \pre the function containing \p inst must be using ownership SIL.
471
477
// / \pre the instruction to be deleted must not have any use other than
472
478
// / incidental uses.
473
479
// /
0 commit comments