@@ -501,7 +501,7 @@ static FunctionTest SSAUseLivenessTest("ssa_use_liveness", [](auto &function,
501501} // end namespace swift::test
502502
503503template <typename LivenessWithDefs>
504- bool PrunedLiveRange<LivenessWithDefs>::isWithinBoundary (
504+ bool PrunedLiveRange<LivenessWithDefs>::isWithinLivenessBoundary (
505505 SILInstruction *inst) const {
506506 assert (asImpl ().isInitialized ());
507507
@@ -574,8 +574,18 @@ bool PrunedLiveRange<LivenessWithDefs>::isInstructionAvailable(
574574}
575575
576576template <typename LivenessWithDefs>
577- bool PrunedLiveRange<LivenessWithDefs>::isWithinExtendedBoundary (
577+ bool PrunedLiveRange<LivenessWithDefs>::isWithinBoundary (
578578 SILInstruction *inst, DeadEndBlocks *deadEndBlocks) const {
579+ if (deadEndBlocks) {
580+ return asImpl ().isWithinExtendedBoundary (inst, *deadEndBlocks);
581+ } else {
582+ return asImpl ().isWithinLivenessBoundary (inst);
583+ }
584+ }
585+
586+ template <typename LivenessWithDefs>
587+ bool PrunedLiveRange<LivenessWithDefs>::isWithinExtendedBoundary(
588+ SILInstruction *inst, DeadEndBlocks &deadEndBlocks) const {
579589 // A value has a pruned live region, a live region and an available region.
580590 // (Note: PrunedLiveness does not distinguish between the pruned live region
581591 // and the live region; the pruned live region coincides with the live region
@@ -628,21 +638,13 @@ bool PrunedLiveRange<LivenessWithDefs>::isWithinExtendedBoundary(
628638 // That this region is of interest is another result of lacking complete
629639 // OSSA lifetimes.
630640
631- if (asImpl ().isWithinBoundary (inst)) {
641+ if (asImpl ().isWithinLivenessBoundary (inst)) {
632642 // The extended region is a superset of the pruned live region.
633643 return true ;
634644 }
635645
636- if (!deadEndBlocks) {
637- // Without knowledge of the dead-end region, the extended region can't be
638- // determined. It could, of course, be rediscovered here, but that would
639- // be silly; instead, allowing a nullable pointer provides a mechanism for
640- // the client to indicate what invariants hold. Specifically, omitting
641- // dead-end blocks is equivalent to asserting that lifetimes are complete.
642- return false ;
643- }
644646 SILBasicBlock *parent = inst->getParent ();
645- if (!deadEndBlocks-> isDeadEnd (parent)) {
647+ if (!deadEndBlocks. isDeadEnd (parent)) {
646648 // The extended region intersected with the non-dead-end region is equal to
647649 // the pruned live region.
648650 return false ;
@@ -652,7 +654,7 @@ bool PrunedLiveRange<LivenessWithDefs>::isWithinExtendedBoundary(
652654 break ;
653655 case PrunedLiveBlocks::LiveWithin:
654656 // Dead defs may result in LiveWithin but AvailableOut blocks.
655- return isInstructionAvailable (inst, * deadEndBlocks);
657+ return isInstructionAvailable (inst, deadEndBlocks);
656658 case PrunedLiveBlocks::LiveOut:
657659 // The instruction is not within the boundary, but its parent is LiveOut;
658660 // therefore it must be a def block.
@@ -687,7 +689,7 @@ bool PrunedLiveRange<LivenessWithDefs>::isWithinExtendedBoundary(
687689 worklist.push (parent);
688690 while (auto *block = worklist.pop ()) {
689691 auto isLive = liveBlocks.getBlockLiveness (block);
690- if (!deadEndBlocks-> isDeadEnd (block)) {
692+ if (!deadEndBlocks. isDeadEnd (block)) {
691693 // The first block beyond the dead-end region has been reached.
692694 if (isLive != PrunedLiveBlocks::LiveOut) {
693695 // Cases (2) above.
@@ -706,7 +708,7 @@ bool PrunedLiveRange<LivenessWithDefs>::isWithinExtendedBoundary(
706708 case PrunedLiveBlocks::LiveWithin:
707709 // Availability may have ended in this block. Check whether the block is
708710 // "AvailableOut".
709- if (!isAvailableOut (block, * deadEndBlocks)) {
711+ if (!isAvailableOut (block, deadEndBlocks)) {
710712 // Case (1) above.
711713 return false ;
712714 }
@@ -799,7 +801,7 @@ bool PrunedLiveRange<LivenessWithDefs>::areUsesWithinBoundary(
799801
800802 for (auto *use : uses) {
801803 auto *user = use->getUser ();
802- if (!isWithinExtendedBoundary (user, deadEndBlocks))
804+ if (!isWithinBoundary (user, deadEndBlocks))
803805 return false ;
804806 }
805807 return true ;
@@ -812,7 +814,7 @@ bool PrunedLiveRange<LivenessWithDefs>::areUsesOutsideBoundary(
812814
813815 for (auto *use : uses) {
814816 auto *user = use->getUser ();
815- if (isWithinExtendedBoundary (user, deadEndBlocks))
817+ if (isWithinBoundary (user, deadEndBlocks))
816818 return false ;
817819 }
818820 return true ;
0 commit comments