@@ -568,8 +568,10 @@ void CanonicalizeOSSALifetime::findOriginalBoundary(
568
568
// / with consumedAtExitBlocks, liveness should be extended to its original
569
569
// / extent.
570
570
// / [Extend liveness down to the boundary between green blocks and uncolored.]
571
- void CanonicalizeOSSALifetime::extendUnconsumedLiveness (
572
- PrunedLivenessBoundary const &boundary) {
571
+ void CanonicalizeOSSALifetime::visitExtendedUnconsumedBoundary (
572
+ ArrayRef<SILInstruction *> ends,
573
+ llvm::function_ref<void (SILInstruction *, PrunedLiveness::LifetimeEnding)>
574
+ visitor) {
573
575
auto currentDef = getCurrentDef ();
574
576
575
577
// First, collect the blocks that were _originally_ live. We can't use
@@ -617,7 +619,7 @@ void CanonicalizeOSSALifetime::extendUnconsumedLiveness(
617
619
// consumes. These are just the instructions on the boundary which aren't
618
620
// destroys.
619
621
BasicBlockWorklist worklist (currentDef->getFunction ());
620
- for (auto *instruction : boundary. lastUsers ) {
622
+ for (auto *instruction : ends ) {
621
623
if (destroys.contains (instruction))
622
624
continue ;
623
625
if (liveness->isInterestingUser (instruction)
@@ -646,7 +648,7 @@ void CanonicalizeOSSALifetime::extendUnconsumedLiveness(
646
648
// Add "the instruction(s) before the terminator" of the predecessor to
647
649
// liveness.
648
650
predecessor->getTerminator ()->visitPriorInstructions ([&](auto *inst) {
649
- liveness-> extendToNonUse (inst);
651
+ visitor (inst, PrunedLiveness::LifetimeEnding::NonUse () );
650
652
return true ;
651
653
});
652
654
}
@@ -660,10 +662,18 @@ void CanonicalizeOSSALifetime::extendUnconsumedLiveness(
660
662
// hoisting it would avoid a copy.
661
663
if (consumedAtExitBlocks.contains (block))
662
664
continue ;
663
- liveness-> updateForUse (destroy, /* lifetimeEnding */ true );
665
+ visitor (destroy, PrunedLiveness::LifetimeEnding::Ending () );
664
666
}
665
667
}
666
668
669
+ void CanonicalizeOSSALifetime::extendUnconsumedLiveness (
670
+ PrunedLivenessBoundary const &boundary) {
671
+ visitExtendedUnconsumedBoundary (
672
+ boundary.lastUsers , [&](auto *instruction, auto lifetimeEnding) {
673
+ liveness->updateForUse (instruction, lifetimeEnding);
674
+ });
675
+ }
676
+
667
677
// ===----------------------------------------------------------------------===//
668
678
// MARK: Step 4. Extend the "original" boundary from step 2 up to destroys that
669
679
// aren't separated from it by "interesting" instructions.
0 commit comments