@@ -573,8 +573,10 @@ void CanonicalizeOSSALifetime::findOriginalBoundary(
573
573
// / with consumedAtExitBlocks, liveness should be extended to its original
574
574
// / extent.
575
575
// / [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) {
578
580
auto currentDef = getCurrentDef ();
579
581
580
582
// First, collect the blocks that were _originally_ live. We can't use
@@ -622,7 +624,7 @@ void CanonicalizeOSSALifetime::extendUnconsumedLiveness(
622
624
// consumes. These are just the instructions on the boundary which aren't
623
625
// destroys.
624
626
BasicBlockWorklist worklist (currentDef->getFunction ());
625
- for (auto *instruction : boundary. lastUsers ) {
627
+ for (auto *instruction : ends ) {
626
628
if (destroys.contains (instruction))
627
629
continue ;
628
630
if (liveness->isInterestingUser (instruction)
@@ -651,7 +653,7 @@ void CanonicalizeOSSALifetime::extendUnconsumedLiveness(
651
653
// Add "the instruction(s) before the terminator" of the predecessor to
652
654
// liveness.
653
655
predecessor->getTerminator ()->visitPriorInstructions ([&](auto *inst) {
654
- liveness-> extendToNonUse (inst);
656
+ visitor (inst, PrunedLiveness::LifetimeEnding::NonUse () );
655
657
return true ;
656
658
});
657
659
}
@@ -665,10 +667,18 @@ void CanonicalizeOSSALifetime::extendUnconsumedLiveness(
665
667
// hoisting it would avoid a copy.
666
668
if (consumedAtExitBlocks.contains (block))
667
669
continue ;
668
- liveness-> updateForUse (destroy, /* lifetimeEnding */ true );
670
+ visitor (destroy, PrunedLiveness::LifetimeEnding::Ending () );
669
671
}
670
672
}
671
673
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
+
672
682
// ===----------------------------------------------------------------------===//
673
683
// MARK: Step 4. Extend the "original" boundary from step 2 up to destroys that
674
684
// aren't separated from it by "interesting" instructions.
0 commit comments