File tree Expand file tree Collapse file tree 4 files changed +26
-2
lines changed
SwiftCompilerSources/Sources/SIL Expand file tree Collapse file tree 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 {}
15321532
15331533final public class BeginApplyInst : MultipleValueInstruction , FullApplySite {
15341534 public var numArguments : Int { bridged. BeginApplyInst_numArguments ( ) }
1535+ public var isCalleeAllocated : Bool { bridged. BeginApplyInst_isCalleeAllocated ( ) }
15351536
15361537 public var singleDirectResult : Value ? { nil }
15371538 public var singleDirectErrorResult : Value ? { nil }
15381539
1539- public var token : Value { getResult ( index: resultCount - 1 ) }
1540+ public var token : Value { getResult ( index: resultCount - ( isCalleeAllocated ? 2 : 1 ) ) }
15401541
15411542 public var yieldedValues : Results {
1542- Results ( inst: self , numResults: resultCount - 1 )
1543+ Results ( inst: self , numResults: resultCount - ( isCalleeAllocated ? 2 : 1 ) )
15431544 }
15441545}
15451546
Original file line number Diff line number Diff line change @@ -779,6 +779,7 @@ struct BridgedInstruction {
779779 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSILTypeArray AllocRefInstBase_getTailAllocatedTypes () const ;
780780 BRIDGED_INLINE bool AllocRefDynamicInst_isDynamicTypeDeinitAndSizeKnownEquivalentToBaseType () const ;
781781 BRIDGED_INLINE SwiftInt BeginApplyInst_numArguments () const ;
782+ BRIDGED_INLINE bool BeginApplyInst_isCalleeAllocated () const ;
782783 BRIDGED_INLINE SwiftInt TryApplyInst_numArguments () const ;
783784 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedBasicBlock BranchInst_getTargetBlock () const ;
784785 BRIDGED_INLINE SwiftInt SwitchEnumInst_getNumCases () const ;
Original file line number Diff line number Diff line change @@ -1333,6 +1333,10 @@ SwiftInt BridgedInstruction::BeginApplyInst_numArguments() const {
13331333 return getAs<swift::BeginApplyInst>()->getNumArguments ();
13341334}
13351335
1336+ bool BridgedInstruction::BeginApplyInst_isCalleeAllocated () const {
1337+ return getAs<swift::BeginApplyInst>()->isCalleeAllocated ();
1338+ }
1339+
13361340SwiftInt BridgedInstruction::TryApplyInst_numArguments () const {
13371341 return getAs<swift::TryApplyInst>()->getNumArguments ();
13381342}
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ sil @use_inguaranteed : $@convention(thin) (@in_guaranteed Klass) -> ()
8787sil @guaranteed_fakeoptional_klass_user : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> ()
8888sil @guaranteed_fakeoptional_classlet_user : $@convention(thin) (@guaranteed FakeOptional<ClassLet>) -> ()
8989sil @closure : $@convention(thin) (@inout_aliasable Klass) -> ()
90+ sil @lendC : $@yield_once_2 @convention(thin) () -> @yields @guaranteed C
9091sil @useC : $@convention(thin) (@guaranteed C) -> () {
9192[global:]
9293}
@@ -2202,3 +2203,20 @@ bb3:
22022203 %r = tuple ()
22032204 return %r
22042205}
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