File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -1904,6 +1904,22 @@ PartialApplyInst::visitOnStackLifetimeEnds(
1904
1904
return !noUsers;
1905
1905
}
1906
1906
1907
+ namespace swift ::test {
1908
+ FunctionTest PartialApplyPrintOnStackLifetimeEnds (
1909
+ " partial_apply_print_on_stack_lifetime_ends" ,
1910
+ [](auto &function, auto &arguments, auto &test) {
1911
+ auto *inst = arguments.takeInstruction ();
1912
+ auto *pai = cast<PartialApplyInst>(inst);
1913
+ function.print (llvm::outs ());
1914
+ auto result = pai->visitOnStackLifetimeEnds ([](auto *operand) {
1915
+ operand->print (llvm::outs ());
1916
+ return true ;
1917
+ });
1918
+ const char *resultString = result ? " true" : " false" ;
1919
+ llvm::outs () << " returned: " << resultString << " \n " ;
1920
+ });
1921
+ } // end namespace swift::test
1922
+
1907
1923
// FIXME: Rather than recursing through all results, this should only recurse
1908
1924
// through ForwardingInstruction and OwnershipTransitionInstruction and the
1909
1925
// client should prove that any other uses cannot be upstream from a consume of
Original file line number Diff line number Diff line change
1
+ // RUN: %target-sil-opt \
2
+ // RUN: -test-runner \
3
+ // RUN: %s \
4
+ // RUN: -o /dev/null \
5
+ // RUN: 2>&1 | %FileCheck %s
6
+
7
+ sil_stage canonical
8
+
9
+ class C {}
10
+
11
+ sil @borrowC : $@convention(thin) (@guaranteed C) -> ()
12
+
13
+ // CHECK-LABEL: begin running test {{.*}} on copied_partial_apply
14
+ // CHECK-LABEL: sil [ossa] @copied_partial_apply : {{.*}} {
15
+ // CHECK: bb0([[C:%[^,]+]] :
16
+ // CHECK: [[BORROW_C:%[^,]+]] = function_ref @borrowC
17
+ // CHECK: [[PA:%[^,]+]] = partial_apply [callee_guaranteed] [on_stack] [[BORROW_C]]([[C]])
18
+ // CHECK: [[PA2:%[^,]+]] = copy_value [[PA]]
19
+ // CHECK: destroy_value [[PA]]
20
+ // CHECK: destroy_value [[PA2]]
21
+ // CHECK: destroy_value [[C]]
22
+ // CHECK-LABEL: } // end sil function 'copied_partial_apply'
23
+ // CHECK: Operand.
24
+ // CHECK: Owner: destroy_value [[PA]]
25
+ // CHECK: returned: true
26
+ // CHECK-LABEL: end running test {{.*}} on copied_partial_apply
27
+ sil [ossa] @copied_partial_apply : $@convention(thin) (@owned C) -> () {
28
+ entry(%c: @owned $C):
29
+ specify_test "partial_apply_print_on_stack_lifetime_ends %pa"
30
+
31
+ %callee = function_ref @borrowC : $@convention(thin) (@guaranteed C) -> ()
32
+ %pa = partial_apply [callee_guaranteed] [on_stack] %callee(%c) : $@convention(thin) (@guaranteed C) -> ()
33
+ %pa2 = copy_value %pa
34
+ destroy_value %pa
35
+
36
+ destroy_value %pa2
37
+ destroy_value %c
38
+ %retval = tuple ()
39
+ return %retval
40
+ }
You can’t perform that action at this time.
0 commit comments