@@ -573,8 +573,10 @@ void CanonicalizeOSSALifetime::findOriginalBoundary(
573573// / with consumedAtExitBlocks, liveness should be extended to its original
574574// / extent.
575575// / [Extend liveness down to the boundary between green blocks and uncolored.]
576- void CanonicalizeOSSALifetime::extendUnconsumedLiveness (
577- PrunedLivenessBoundary const &boundary) {
576+ void CanonicalizeOSSALifetime::visitExtendedUnconsumedBoundary (
577+ ArrayRef<SILInstruction *> ends,
578+ llvm::function_ref<void (SILInstruction *, PrunedLiveness::LifetimeEnding)>
579+ visitor) {
578580 auto currentDef = getCurrentDef ();
579581
580582 // First, collect the blocks that were _originally_ live. We can't use
@@ -622,7 +624,7 @@ void CanonicalizeOSSALifetime::extendUnconsumedLiveness(
622624 // consumes. These are just the instructions on the boundary which aren't
623625 // destroys.
624626 BasicBlockWorklist worklist (currentDef->getFunction ());
625- for (auto *instruction : boundary. lastUsers ) {
627+ for (auto *instruction : ends ) {
626628 if (destroys.contains (instruction))
627629 continue ;
628630 if (liveness->isInterestingUser (instruction)
@@ -651,7 +653,7 @@ void CanonicalizeOSSALifetime::extendUnconsumedLiveness(
651653 // Add "the instruction(s) before the terminator" of the predecessor to
652654 // liveness.
653655 predecessor->getTerminator ()->visitPriorInstructions ([&](auto *inst) {
654- liveness-> extendToNonUse (inst);
656+ visitor (inst, PrunedLiveness::LifetimeEnding::NonUse () );
655657 return true ;
656658 });
657659 }
@@ -665,10 +667,18 @@ void CanonicalizeOSSALifetime::extendUnconsumedLiveness(
665667 // hoisting it would avoid a copy.
666668 if (consumedAtExitBlocks.contains (block))
667669 continue ;
668- liveness-> updateForUse (destroy, /* lifetimeEnding */ true );
670+ visitor (destroy, PrunedLiveness::LifetimeEnding::Ending () );
669671 }
670672}
671673
674+ void CanonicalizeOSSALifetime::extendUnconsumedLiveness (
675+ PrunedLivenessBoundary const &boundary) {
676+ visitExtendedUnconsumedBoundary (
677+ boundary.lastUsers , [&](auto *instruction, auto lifetimeEnding) {
678+ liveness->updateForUse (instruction, lifetimeEnding);
679+ });
680+ }
681+
672682// ===----------------------------------------------------------------------===//
673683// MARK: Step 4. Extend the "original" boundary from step 2 up to destroys that
674684// aren't separated from it by "interesting" instructions.
0 commit comments