@@ -339,7 +339,7 @@ static bool isStoreCopy(SILValue value) {
339
339
return false ;
340
340
341
341
auto *user = value->getSingleUse ()->getUser ();
342
- return isa<StoreInst>(user) || isa<AssignInst>(user) ;
342
+ return isa<StoreInst>(user);
343
343
}
344
344
345
345
void ValueStorageMap::insertValue (SILValue value, SILValue storageAddress) {
@@ -1784,14 +1784,12 @@ void CallArgRewriter::rewriteIndirectArgument(Operand *operand) {
1784
1784
});
1785
1785
} else {
1786
1786
auto borrow = argBuilder.emitBeginBorrowOperation (callLoc, argValue);
1787
- auto *storeInst =
1788
- argBuilder.emitStoreBorrowOperation (callLoc, borrow, allocInst);
1787
+ argBuilder.emitStoreBorrowOperation (callLoc, borrow, allocInst);
1789
1788
1790
1789
apply.insertAfterFullEvaluation ([&](SILBuilder &callBuilder) {
1791
- if (auto *storeBorrow = dyn_cast<StoreBorrowInst>(storeInst) ) {
1792
- callBuilder.emitEndBorrowOperation (callLoc, storeBorrow );
1790
+ if (borrow != argValue ) {
1791
+ callBuilder.emitEndBorrowOperation (callLoc, borrow );
1793
1792
}
1794
- callBuilder.emitEndBorrowOperation (callLoc, borrow);
1795
1793
callBuilder.createDeallocStack (callLoc, allocInst);
1796
1794
});
1797
1795
}
@@ -2369,8 +2367,11 @@ class CheckedCastBrRewriter {
2369
2367
// / Return the storageAddress if \p value is opaque, otherwise create and
2370
2368
// / return a stack temporary.
2371
2369
SILValue getAddressForCastEntity (SILValue value, bool needsInit) {
2372
- if (value->getType ().isAddressOnly (*func))
2373
- return pass.valueStorageMap .getStorage (value).storageAddress ;
2370
+ if (value->getType ().isAddressOnly (*func)) {
2371
+ auto builder = pass.getBuilder (ccb->getIterator ());
2372
+ AddressMaterialization addrMat (pass, builder);
2373
+ return addrMat.materializeAddress (value);
2374
+ }
2374
2375
2375
2376
// Create a stack temporary for a loadable value
2376
2377
auto *addr = termBuilder.createAllocStack (castLoc, value->getType ());
@@ -2595,12 +2596,14 @@ class UseRewriter : SILInstructionVisitor<UseRewriter> {
2595
2596
}
2596
2597
2597
2598
void visitYieldInst (YieldInst *yield) {
2598
- SILValue addr =
2599
- pass.valueStorageMap .getStorage (yield->getOperand (0 )).storageAddress ;
2599
+ SILValue addr = addrMat.materializeAddress (use->get ());
2600
2600
yield->setOperand (0 , addr);
2601
2601
}
2602
2602
2603
- void visitAssignInst (AssignInst *assignInst);
2603
+ void visitValueMetatypeInst (ValueMetatypeInst *vmi) {
2604
+ SILValue opAddr = addrMat.materializeAddress (use->get ());
2605
+ vmi->setOperand (opAddr);
2606
+ }
2604
2607
2605
2608
void visitBeginBorrowInst (BeginBorrowInst *borrow);
2606
2609
@@ -2832,11 +2835,6 @@ void UseRewriter::visitStoreInst(StoreInst *storeInst) {
2832
2835
rewriteStore (storeInst->getSrc (), storeInst->getDest (), isInit);
2833
2836
}
2834
2837
2835
- void UseRewriter::visitAssignInst (AssignInst *assignInst) {
2836
- rewriteStore (assignInst->getSrc (), assignInst->getDest (),
2837
- IsNotInitialization);
2838
- }
2839
-
2840
2838
// / Emit end_borrows for a an incomplete BorrowedValue with only nonlifetime
2841
2839
// / ending uses. This function inserts end_borrows on the lifetime boundary.
2842
2840
void UseRewriter::emitEndBorrows (SILValue value) {
0 commit comments