mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Get rid of isStorageValid flag on lastStoreInst
This commit is contained in:
@@ -655,7 +655,7 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
|
||||
Optional<StorageStateTracking<LiveValues>> runningVals;
|
||||
// Keep track of the last StoreInst that we found and the BeginBorrowInst and
|
||||
// CopyValueInst that we created in response if the alloc_stack was lexical.
|
||||
Optional<StorageStateTracking<SILInstruction *>> lastStoreInst;
|
||||
Optional<SILInstruction *> lastStoreInst;
|
||||
|
||||
// For all instructions in the block.
|
||||
for (auto bbi = blockPromotingWithin->begin(),
|
||||
@@ -683,8 +683,6 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
|
||||
}
|
||||
if (runningVals)
|
||||
runningVals->isStorageValid = false;
|
||||
if (lastStoreInst)
|
||||
lastStoreInst->isStorageValid = false;
|
||||
}
|
||||
|
||||
if (runningVals) {
|
||||
@@ -736,14 +734,14 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
|
||||
|
||||
// If we met a store before this one, delete it.
|
||||
if (lastStoreInst) {
|
||||
assert(cast<StoreInst>(lastStoreInst->value)->getOwnershipQualifier() !=
|
||||
assert(cast<StoreInst>(*lastStoreInst)->getOwnershipQualifier() !=
|
||||
StoreOwnershipQualifier::Assign &&
|
||||
"store [assign] to the stack location should have been "
|
||||
"transformed to a store [init]");
|
||||
LLVM_DEBUG(llvm::dbgs() << "*** Removing redundant store: "
|
||||
<< *lastStoreInst->value);
|
||||
LLVM_DEBUG(llvm::dbgs()
|
||||
<< "*** Removing redundant store: " << *lastStoreInst);
|
||||
++NumInstRemoved;
|
||||
prepareForDeletion(lastStoreInst->value, instructionsToDelete);
|
||||
prepareForDeletion(*lastStoreInst, instructionsToDelete);
|
||||
}
|
||||
|
||||
auto oldRunningVals = runningVals;
|
||||
@@ -752,7 +750,7 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
|
||||
/*isStorageValid=*/true};
|
||||
// The current store is now the lastStoreInst (until we see
|
||||
// another).
|
||||
lastStoreInst = {inst, /*isStorageValid=*/true};
|
||||
lastStoreInst = inst;
|
||||
if (shouldAddLexicalLifetime(asi)) {
|
||||
if (oldRunningVals && oldRunningVals->isStorageValid &&
|
||||
canEndLexicalLifetime(oldRunningVals->value)) {
|
||||
@@ -770,17 +768,17 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
|
||||
|
||||
// If we met a store before this one, delete it.
|
||||
if (lastStoreInst) {
|
||||
LLVM_DEBUG(llvm::dbgs() << "*** Removing redundant store: "
|
||||
<< *lastStoreInst->value);
|
||||
LLVM_DEBUG(llvm::dbgs()
|
||||
<< "*** Removing redundant store: " << *lastStoreInst);
|
||||
++NumInstRemoved;
|
||||
prepareForDeletion(lastStoreInst->value, instructionsToDelete);
|
||||
prepareForDeletion(*lastStoreInst, instructionsToDelete);
|
||||
}
|
||||
|
||||
// The stored value is the new running value.
|
||||
runningVals = {LiveValues::toReplace(asi, sbi->getSrc()),
|
||||
/*isStorageValid=*/true};
|
||||
// The current store is now the lastStoreInst.
|
||||
lastStoreInst = {inst, /*isStorageValid=*/true};
|
||||
lastStoreInst = inst;
|
||||
if (shouldAddLexicalLifetime(asi)) {
|
||||
runningVals = beginLexicalLifetimeAfterStore(asi, inst);
|
||||
}
|
||||
@@ -837,8 +835,6 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
|
||||
runningVals->value);
|
||||
}
|
||||
runningVals->isStorageValid = false;
|
||||
if (lastStoreInst)
|
||||
lastStoreInst->isStorageValid = false;
|
||||
} else {
|
||||
assert(!deinitializationPoints[blockPromotingWithin]);
|
||||
deinitializationPoints[blockPromotingWithin] = dai;
|
||||
@@ -853,15 +849,15 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
|
||||
}
|
||||
}
|
||||
|
||||
if (lastStoreInst && lastStoreInst->isStorageValid) {
|
||||
assert((isa<StoreBorrowInst>(lastStoreInst->value) ||
|
||||
(cast<StoreInst>(lastStoreInst->value)->getOwnershipQualifier() !=
|
||||
if (lastStoreInst && runningVals->isStorageValid) {
|
||||
assert((isa<StoreBorrowInst>(*lastStoreInst) ||
|
||||
(cast<StoreInst>(*lastStoreInst)->getOwnershipQualifier() !=
|
||||
StoreOwnershipQualifier::Assign)) &&
|
||||
"store [assign] to the stack location should have been "
|
||||
"transformed to a store [init]");
|
||||
LLVM_DEBUG(llvm::dbgs() << "*** Finished promotion. Last store: "
|
||||
<< *lastStoreInst->value);
|
||||
return lastStoreInst->value;
|
||||
LLVM_DEBUG(llvm::dbgs()
|
||||
<< "*** Finished promotion. Last store: " << *lastStoreInst);
|
||||
return *lastStoreInst;
|
||||
}
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << "*** Finished promotion with no stores.\n");
|
||||
|
||||
Reference in New Issue
Block a user