|
14 | 14 | #include "swift/Basic/BlotSetVector.h"
|
15 | 15 | #include "swift/Basic/STLExtras.h"
|
16 | 16 | #include "swift/SIL/BasicBlockUtils.h"
|
17 |
| -#include "swift/SIL/BranchPropagatedUser.h" |
18 | 17 | #include "swift/SIL/DebugUtils.h"
|
19 | 18 | #include "swift/SIL/MemAccessUtils.h"
|
20 | 19 | #include "swift/SIL/OwnershipUtils.h"
|
@@ -577,21 +576,19 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(CopyValueInst
|
577 | 576 | // need to insert an end_borrow since all of our borrow introducers are
|
578 | 577 | // non-local scopes.
|
579 | 578 | {
|
580 |
| - SmallVector<BranchPropagatedUser, 8> destroysForLinearLifetimeCheck; |
581 | 579 | bool foundNonDeadEnd = false;
|
582 | 580 | for (auto *dvi : destroys) {
|
583 | 581 | foundNonDeadEnd |= !getDeadEndBlocks().isDeadEnd(dvi->getParent());
|
584 |
| - destroysForLinearLifetimeCheck.push_back(&dvi->getAllOperands()[0]); |
585 | 582 | }
|
586 | 583 | if (!foundNonDeadEnd && haveAnyLocalScopes)
|
587 | 584 | return false;
|
588 |
| - SmallVector<BranchPropagatedUser, 8> scratchSpace; |
| 585 | + SmallVector<SILInstruction *, 8> scratchSpace; |
589 | 586 | SmallPtrSet<SILBasicBlock *, 4> visitedBlocks;
|
590 | 587 | if (llvm::any_of(borrowScopeIntroducers,
|
591 | 588 | [&](BorrowScopeIntroducingValue borrowScope) {
|
592 | 589 | return !borrowScope.areInstructionsWithinScope(
|
593 |
| - destroysForLinearLifetimeCheck, scratchSpace, |
594 |
| - visitedBlocks, getDeadEndBlocks()); |
| 590 | + destroys, scratchSpace, visitedBlocks, |
| 591 | + getDeadEndBlocks()); |
595 | 592 | })) {
|
596 | 593 | return false;
|
597 | 594 | }
|
@@ -786,22 +783,15 @@ class StorageGuaranteesLoadVisitor
|
786 | 783 |
|
787 | 784 | // Use the linear lifetime checker to check whether the copied
|
788 | 785 | // value is dominated by the lifetime of the borrow it's based on.
|
789 |
| - SmallVector<BranchPropagatedUser, 4> baseEndBorrows; |
790 |
| - for (auto *use : borrowInst->getUses()) { |
791 |
| - if (isa<EndBorrowInst>(use->getUser())) { |
792 |
| - baseEndBorrows.emplace_back(use); |
793 |
| - } |
794 |
| - } |
795 |
| - |
796 |
| - SmallVector<BranchPropagatedUser, 4> valueDestroys; |
797 |
| - for (auto *use : Load->getUses()) { |
798 |
| - if (isa<DestroyValueInst>(use->getUser())) { |
799 |
| - valueDestroys.emplace_back(use); |
800 |
| - } |
801 |
| - } |
802 |
| - |
803 |
| - SmallPtrSet<SILBasicBlock *, 4> visitedBlocks; |
| 786 | + SmallVector<SILInstruction *, 4> baseEndBorrows; |
| 787 | + llvm::copy(borrowInst->getUsersOfType<EndBorrowInst>(), |
| 788 | + std::back_inserter(baseEndBorrows)); |
804 | 789 |
|
| 790 | + SmallVector<SILInstruction *, 4> valueDestroys; |
| 791 | + llvm::copy(Load->getUsersOfType<DestroyValueInst>(), |
| 792 | + std::back_inserter(valueDestroys)); |
| 793 | + |
| 794 | + SmallPtrSet<SILBasicBlock *, 4> visitedBlocks; |
805 | 795 | LinearLifetimeChecker checker(visitedBlocks, ARCOpt.getDeadEndBlocks());
|
806 | 796 | // Returns true on success. So we invert.
|
807 | 797 | bool foundError =
|
|
0 commit comments