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 @@ -1903,6 +1903,22 @@ PartialApplyInst::visitOnStackLifetimeEnds(
1903
1903
return !noUsers;
1904
1904
}
1905
1905
1906
+ namespace swift ::test {
1907
+ FunctionTest PartialApplyPrintOnStackLifetimeEnds (
1908
+ " partial_apply_print_on_stack_lifetime_ends" ,
1909
+ [](auto &function, auto &arguments, auto &test) {
1910
+ auto *inst = arguments.takeInstruction ();
1911
+ auto *pai = cast<PartialApplyInst>(inst);
1912
+ function.print (llvm::outs ());
1913
+ auto result = pai->visitOnStackLifetimeEnds ([](auto *operand) {
1914
+ operand->print (llvm::outs ());
1915
+ return true ;
1916
+ });
1917
+ const char *resultString = result ? " true" : " false" ;
1918
+ llvm::outs () << " returned: " << resultString << " \n " ;
1919
+ });
1920
+ } // end namespace swift::test
1921
+
1906
1922
// FIXME: Rather than recursing through all results, this should only recurse
1907
1923
// through ForwardingInstruction and OwnershipTransitionInstruction and the
1908
1924
// 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