File tree 4 files changed +26
-2
lines changed
SwiftCompilerSources/Sources/SIL
4 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -1532,14 +1532,15 @@ final public class EndUnpairedAccessInst : Instruction {}
1532
1532
1533
1533
final public class BeginApplyInst : MultipleValueInstruction , FullApplySite {
1534
1534
public var numArguments : Int { bridged. BeginApplyInst_numArguments ( ) }
1535
+ public var isCalleeAllocated : Bool { bridged. BeginApplyInst_isCalleeAllocated ( ) }
1535
1536
1536
1537
public var singleDirectResult : Value ? { nil }
1537
1538
public var singleDirectErrorResult : Value ? { nil }
1538
1539
1539
- public var token : Value { getResult ( index: resultCount - 1 ) }
1540
+ public var token : Value { getResult ( index: resultCount - ( isCalleeAllocated ? 2 : 1 ) ) }
1540
1541
1541
1542
public var yieldedValues : Results {
1542
- Results ( inst: self , numResults: resultCount - 1 )
1543
+ Results ( inst: self , numResults: resultCount - ( isCalleeAllocated ? 2 : 1 ) )
1543
1544
}
1544
1545
}
1545
1546
Original file line number Diff line number Diff line change @@ -780,6 +780,7 @@ struct BridgedInstruction {
780
780
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSILTypeArray AllocRefInstBase_getTailAllocatedTypes () const ;
781
781
BRIDGED_INLINE bool AllocRefDynamicInst_isDynamicTypeDeinitAndSizeKnownEquivalentToBaseType () const ;
782
782
BRIDGED_INLINE SwiftInt BeginApplyInst_numArguments () const ;
783
+ BRIDGED_INLINE bool BeginApplyInst_isCalleeAllocated () const ;
783
784
BRIDGED_INLINE SwiftInt TryApplyInst_numArguments () const ;
784
785
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedBasicBlock BranchInst_getTargetBlock () const ;
785
786
BRIDGED_INLINE SwiftInt SwitchEnumInst_getNumCases () const ;
Original file line number Diff line number Diff line change @@ -1338,6 +1338,10 @@ SwiftInt BridgedInstruction::BeginApplyInst_numArguments() const {
1338
1338
return getAs<swift::BeginApplyInst>()->getNumArguments ();
1339
1339
}
1340
1340
1341
+ bool BridgedInstruction::BeginApplyInst_isCalleeAllocated () const {
1342
+ return getAs<swift::BeginApplyInst>()->isCalleeAllocated ();
1343
+ }
1344
+
1341
1345
SwiftInt BridgedInstruction::TryApplyInst_numArguments () const {
1342
1346
return getAs<swift::TryApplyInst>()->getNumArguments ();
1343
1347
}
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ sil @use_inguaranteed : $@convention(thin) (@in_guaranteed Klass) -> ()
87
87
sil @guaranteed_fakeoptional_klass_user : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> ()
88
88
sil @guaranteed_fakeoptional_classlet_user : $@convention(thin) (@guaranteed FakeOptional<ClassLet>) -> ()
89
89
sil @closure : $@convention(thin) (@inout_aliasable Klass) -> ()
90
+ sil @lendC : $@yield_once_2 @convention(thin) () -> @yields @guaranteed C
90
91
sil @useC : $@convention(thin) (@guaranteed C) -> () {
91
92
[global:]
92
93
}
@@ -2202,3 +2203,20 @@ bb3:
2202
2203
%r = tuple ()
2203
2204
return %r
2204
2205
}
2206
+
2207
+
2208
+ // CHECK-LABEL: sil [ossa] @keep_yield2ed_copy : {{.*}} {
2209
+ // CHECK: copy_value
2210
+ // CHECK: } // end sil function 'keep_yield2ed_copy'
2211
+ sil [ossa] @keep_yield2ed_copy : $@convention(thin) () -> () {
2212
+ %lendC = function_ref @lendC : $@yield_once_2 @convention(thin) () -> @yields @guaranteed C
2213
+ (%c, %token, %alloc) = begin_apply %lendC() : $@yield_once_2 @convention(thin) () -> @yields @guaranteed C
2214
+ %copy = copy_value %c : $C
2215
+ end_apply %token as $()
2216
+ dealloc_stack %alloc : $*Builtin.SILToken
2217
+ %useC = function_ref @useC : $@convention(thin) (@guaranteed C) -> ()
2218
+ apply %useC(%copy) : $@convention(thin) (@guaranteed C) -> ()
2219
+ destroy_value %copy : $C
2220
+ %retval = tuple ()
2221
+ return %retval : $()
2222
+ }
You can’t perform that action at this time.
0 commit comments