@@ -339,7 +339,7 @@ static bool isStoreCopy(SILValue value) {
339339 return false ;
340340
341341 auto *user = value->getSingleUse ()->getUser ();
342- return isa<StoreInst>(user) || isa<AssignInst>(user) ;
342+ return isa<StoreInst>(user);
343343}
344344
345345void ValueStorageMap::insertValue (SILValue value, SILValue storageAddress) {
@@ -1784,14 +1784,12 @@ void CallArgRewriter::rewriteIndirectArgument(Operand *operand) {
17841784 });
17851785 } else {
17861786 auto borrow = argBuilder.emitBeginBorrowOperation (callLoc, argValue);
1787- auto *storeInst =
1788- argBuilder.emitStoreBorrowOperation (callLoc, borrow, allocInst);
1787+ argBuilder.emitStoreBorrowOperation (callLoc, borrow, allocInst);
17891788
17901789 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 );
17931792 }
1794- callBuilder.emitEndBorrowOperation (callLoc, borrow);
17951793 callBuilder.createDeallocStack (callLoc, allocInst);
17961794 });
17971795 }
@@ -2369,8 +2367,11 @@ class CheckedCastBrRewriter {
23692367 // / Return the storageAddress if \p value is opaque, otherwise create and
23702368 // / return a stack temporary.
23712369 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+ }
23742375
23752376 // Create a stack temporary for a loadable value
23762377 auto *addr = termBuilder.createAllocStack (castLoc, value->getType ());
@@ -2595,12 +2596,14 @@ class UseRewriter : SILInstructionVisitor<UseRewriter> {
25952596 }
25962597
25972598 void visitYieldInst (YieldInst *yield) {
2598- SILValue addr =
2599- pass.valueStorageMap .getStorage (yield->getOperand (0 )).storageAddress ;
2599+ SILValue addr = addrMat.materializeAddress (use->get ());
26002600 yield->setOperand (0 , addr);
26012601 }
26022602
2603- void visitAssignInst (AssignInst *assignInst);
2603+ void visitValueMetatypeInst (ValueMetatypeInst *vmi) {
2604+ SILValue opAddr = addrMat.materializeAddress (use->get ());
2605+ vmi->setOperand (opAddr);
2606+ }
26042607
26052608 void visitBeginBorrowInst (BeginBorrowInst *borrow);
26062609
@@ -2832,11 +2835,6 @@ void UseRewriter::visitStoreInst(StoreInst *storeInst) {
28322835 rewriteStore (storeInst->getSrc (), storeInst->getDest (), isInit);
28332836}
28342837
2835- void UseRewriter::visitAssignInst (AssignInst *assignInst) {
2836- rewriteStore (assignInst->getSrc (), assignInst->getDest (),
2837- IsNotInitialization);
2838- }
2839-
28402838// / Emit end_borrows for a an incomplete BorrowedValue with only nonlifetime
28412839// / ending uses. This function inserts end_borrows on the lifetime boundary.
28422840void UseRewriter::emitEndBorrows (SILValue value) {
0 commit comments