@@ -655,7 +655,7 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
655
655
Optional<StorageStateTracking<LiveValues>> runningVals;
656
656
// Keep track of the last StoreInst that we found and the BeginBorrowInst and
657
657
// CopyValueInst that we created in response if the alloc_stack was lexical.
658
- Optional<StorageStateTracking< SILInstruction *> > lastStoreInst;
658
+ Optional<SILInstruction *> lastStoreInst;
659
659
660
660
// For all instructions in the block.
661
661
for (auto bbi = blockPromotingWithin->begin (),
@@ -683,8 +683,6 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
683
683
}
684
684
if (runningVals)
685
685
runningVals->isStorageValid = false ;
686
- if (lastStoreInst)
687
- lastStoreInst->isStorageValid = false ;
688
686
}
689
687
690
688
if (runningVals) {
@@ -736,14 +734,14 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
736
734
737
735
// If we met a store before this one, delete it.
738
736
if (lastStoreInst) {
739
- assert (cast<StoreInst>(lastStoreInst-> value )->getOwnershipQualifier () !=
737
+ assert (cast<StoreInst>(* lastStoreInst)->getOwnershipQualifier () !=
740
738
StoreOwnershipQualifier::Assign &&
741
739
" store [assign] to the stack location should have been "
742
740
" transformed to a store [init]" );
743
- LLVM_DEBUG (llvm::dbgs () << " *** Removing redundant store: "
744
- << *lastStoreInst-> value );
741
+ LLVM_DEBUG (llvm::dbgs ()
742
+ << " *** Removing redundant store: " << *lastStoreInst);
745
743
++NumInstRemoved;
746
- prepareForDeletion (lastStoreInst-> value , instructionsToDelete);
744
+ prepareForDeletion (* lastStoreInst, instructionsToDelete);
747
745
}
748
746
749
747
auto oldRunningVals = runningVals;
@@ -752,7 +750,7 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
752
750
/* isStorageValid=*/ true };
753
751
// The current store is now the lastStoreInst (until we see
754
752
// another).
755
- lastStoreInst = { inst, /* isStorageValid= */ true } ;
753
+ lastStoreInst = inst;
756
754
if (shouldAddLexicalLifetime (asi)) {
757
755
if (oldRunningVals && oldRunningVals->isStorageValid &&
758
756
canEndLexicalLifetime (oldRunningVals->value )) {
@@ -770,17 +768,17 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
770
768
771
769
// If we met a store before this one, delete it.
772
770
if (lastStoreInst) {
773
- LLVM_DEBUG (llvm::dbgs () << " *** Removing redundant store: "
774
- << *lastStoreInst-> value );
771
+ LLVM_DEBUG (llvm::dbgs ()
772
+ << " *** Removing redundant store: " << *lastStoreInst);
775
773
++NumInstRemoved;
776
- prepareForDeletion (lastStoreInst-> value , instructionsToDelete);
774
+ prepareForDeletion (* lastStoreInst, instructionsToDelete);
777
775
}
778
776
779
777
// The stored value is the new running value.
780
778
runningVals = {LiveValues::toReplace (asi, sbi->getSrc ()),
781
779
/* isStorageValid=*/ true };
782
780
// The current store is now the lastStoreInst.
783
- lastStoreInst = { inst, /* isStorageValid= */ true } ;
781
+ lastStoreInst = inst;
784
782
if (shouldAddLexicalLifetime (asi)) {
785
783
runningVals = beginLexicalLifetimeAfterStore (asi, inst);
786
784
}
@@ -837,8 +835,6 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
837
835
runningVals->value );
838
836
}
839
837
runningVals->isStorageValid = false ;
840
- if (lastStoreInst)
841
- lastStoreInst->isStorageValid = false ;
842
838
} else {
843
839
assert (!deinitializationPoints[blockPromotingWithin]);
844
840
deinitializationPoints[blockPromotingWithin] = dai;
@@ -853,15 +849,15 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
853
849
}
854
850
}
855
851
856
- if (lastStoreInst && lastStoreInst ->isStorageValid ) {
857
- assert ((isa<StoreBorrowInst>(lastStoreInst-> value ) ||
858
- (cast<StoreInst>(lastStoreInst-> value )->getOwnershipQualifier () !=
852
+ if (lastStoreInst && runningVals ->isStorageValid ) {
853
+ assert ((isa<StoreBorrowInst>(* lastStoreInst) ||
854
+ (cast<StoreInst>(* lastStoreInst)->getOwnershipQualifier () !=
859
855
StoreOwnershipQualifier::Assign)) &&
860
856
" store [assign] to the stack location should have been "
861
857
" transformed to a store [init]" );
862
- LLVM_DEBUG (llvm::dbgs () << " *** Finished promotion. Last store: "
863
- << *lastStoreInst-> value );
864
- return lastStoreInst-> value ;
858
+ LLVM_DEBUG (llvm::dbgs ()
859
+ << " *** Finished promotion. Last store: " << *lastStoreInst);
860
+ return * lastStoreInst;
865
861
}
866
862
867
863
LLVM_DEBUG (llvm::dbgs () << " *** Finished promotion with no stores.\n " );
0 commit comments