@@ -872,6 +872,9 @@ static Operand *getProjectedDefOperand(SILValue value) {
872
872
873
873
return nullptr ;
874
874
875
+ case ValueKind::MoveValueInst:
876
+ return &cast<MoveValueInst>(value)->getOperandRef ();
877
+
875
878
case ValueKind::MultipleValueInstructionResult: {
876
879
SILInstruction *destructure =
877
880
cast<MultipleValueInstructionResult>(value)->getParent ();
@@ -3050,6 +3053,9 @@ class UseRewriter : SILInstructionVisitor<UseRewriter> {
3050
3053
}
3051
3054
}
3052
3055
3056
+ template <typename Introducer>
3057
+ void visitLifetimeIntroducer (Introducer *introducer);
3058
+
3053
3059
void visitBeginBorrowInst (BeginBorrowInst *borrow);
3054
3060
3055
3061
void visitEndBorrowInst (EndBorrowInst *end) {}
@@ -3125,6 +3131,8 @@ class UseRewriter : SILInstructionVisitor<UseRewriter> {
3125
3131
// types.
3126
3132
void visitOpenExistentialValueInst (OpenExistentialValueInst *openExistential);
3127
3133
3134
+ void visitMoveValueInst (MoveValueInst *mvi);
3135
+
3128
3136
void visitReturnInst (ReturnInst *returnInst) {
3129
3137
// Returns are rewritten for any function with indirect results after
3130
3138
// opaque value rewriting.
@@ -3263,15 +3271,16 @@ void UseRewriter::rewriteDestructure(SILInstruction *destructure) {
3263
3271
}
3264
3272
}
3265
3273
3266
- void UseRewriter::visitBeginBorrowInst (BeginBorrowInst *borrow) {
3267
- assert (use == getProjectedDefOperand (borrow));
3274
+ template <typename Introducer>
3275
+ void UseRewriter::visitLifetimeIntroducer (Introducer *introducer) {
3276
+ assert (use == getProjectedDefOperand (introducer));
3268
3277
3269
3278
// Mark the value as rewritten and use the operand's storage.
3270
3279
auto address = pass.valueStorageMap .getStorage (use->get ()).storageAddress ;
3271
- markRewritten (borrow , address);
3280
+ markRewritten (introducer , address);
3272
3281
3273
- // Borrows are irrelevant unless they are marked lexical.
3274
- if (borrow ->isLexical ()) {
3282
+ // Lifetime introducers are irrelevant unless they are marked lexical.
3283
+ if (introducer ->isLexical ()) {
3275
3284
if (auto base = getAccessBase (address)) {
3276
3285
if (auto *allocStack = dyn_cast<AllocStackInst>(base)) {
3277
3286
allocStack->setIsLexical ();
@@ -3287,6 +3296,14 @@ void UseRewriter::visitBeginBorrowInst(BeginBorrowInst *borrow) {
3287
3296
}
3288
3297
}
3289
3298
3299
+ void UseRewriter::visitBeginBorrowInst (BeginBorrowInst *borrow) {
3300
+ visitLifetimeIntroducer (borrow);
3301
+ }
3302
+
3303
+ void UseRewriter::visitMoveValueInst (MoveValueInst *mvi) {
3304
+ visitLifetimeIntroducer (mvi);
3305
+ }
3306
+
3290
3307
// Opening an opaque existential. Rewrite the opened existentials here on
3291
3308
// the use-side because it may produce either loadable or address-only
3292
3309
// types.
0 commit comments