Skip to content

Commit 0018a0a

Browse files
committed
Unit test for OSSALifetimeCompletion
1 parent b0affc4 commit 0018a0a

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// RUN: %target-sil-opt -enable-ossa-complete-lifetimes -unit-test-runner %s -o /dev/null 2>&1 | %FileCheck %s
2+
3+
sil_stage raw
4+
5+
import Builtin
6+
7+
class C {}
8+
9+
// CHECK-LABEL: begin running test 1 of 1 on eagerConsumneOwnedArg: ossa-lifetime-completion with: @argument
10+
// CHECK-LABEL: OSSA lifetime completion: %0 = argument of bb0 : $C
11+
// CHECK: sil [ossa] @eagerConsumneOwnedArg : $@convention(thin) (@owned C) -> () {
12+
// CHECK: bb0(%0 : @_eagerMove @owned $C):
13+
// CHECK-NEXT: destroy_value %0 : $C
14+
// CHECK-LABEL: end running test 1 of 1 on eagerConsumneOwnedArg: ossa-lifetime-completion with: @argument
15+
sil [ossa] @eagerConsumneOwnedArg : $@convention(thin) (@owned C) -> () {
16+
entry(%0 : @_eagerMove @owned $C):
17+
test_specification "ossa-lifetime-completion @argument"
18+
br exit
19+
20+
exit:
21+
%retval = tuple ()
22+
return %retval : $()
23+
}
24+
25+
// CHECK-LABEL: begin running test 1 of 1 on lexicalOwnedArg: ossa-lifetime-completion with: @argument
26+
// CHECK: OSSA lifetime completion: %0 = argument of bb0 : $C // user: %4
27+
// CHECK: sil [ossa] @lexicalOwnedArg : $@convention(thin) (@owned C) -> () {
28+
// CHECK: bb0(%0 : @owned $C):
29+
// CHECK: cond_br undef, bb1, bb2
30+
// CHECK: bb2:
31+
// CHECK-NEXT: destroy_value %0 : $C
32+
// CHECK-NEXT: unreachable
33+
// CHECK: } // end sil function 'lexicalOwnedArg'
34+
// CHECK-LABEL: end running test 1 of 1 on lexicalOwnedArg: ossa-lifetime-completion with: @argument
35+
sil [ossa] @lexicalOwnedArg : $@convention(thin) (@owned C) -> () {
36+
bb0(%0 : @owned $C):
37+
test_specification "ossa-lifetime-completion @argument"
38+
cond_br undef, bb1, bb2
39+
bb1:
40+
br bb3
41+
bb2:
42+
unreachable
43+
bb3:
44+
destroy_value %0 : $C
45+
%r = tuple ()
46+
return %r : $()
47+
}

0 commit comments

Comments
 (0)