Skip to content

Commit f6cae0c

Browse files
committed
Add liveness test cases
for scoped addresses and coroutines
1 parent 6af0b6d commit f6cae0c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/SILOptimizer/ossa_lifetime_analysis.sil

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ case some(T)
2222
class C {}
2323
class D {
2424
var object: C
25+
@_borrowed @_hasStorage var borrowed: C { get set }
2526
}
2627

2728
// CHECK-LABEL: @testSelfLoop
@@ -132,3 +133,45 @@ bb0(%0 : @owned $D):
132133
%99 = tuple()
133134
return %99 : $()
134135
}
136+
137+
// CHECK-LABEL: @testGuaranteedResult
138+
// CHECK: SSA lifetime analysis: %0 = argument of bb0 : $D
139+
// CHECK: bb0: LiveWithin
140+
// CHECK: last user: end_apply
141+
sil [ossa] @testGuaranteedResult : $@convention(thin) (@guaranteed D) -> () {
142+
bb0(%0 : @guaranteed $D):
143+
debug_value [trace] %0 : $D
144+
%2 = class_method %0 : $D, #D.borrowed!read : (D) -> () -> (), $@yield_once @convention(method) (@guaranteed D) -> @yields @guaranteed C
145+
(%3, %4) = begin_apply %2(%0) : $@yield_once @convention(method) (@guaranteed D) -> @yields @guaranteed C
146+
end_apply %4
147+
%99 = tuple()
148+
return %99 : $()
149+
}
150+
151+
// CHECK-LABEL: @testScopedAddress
152+
// CHECK: SSA lifetime analysis: %{{.*}} = ref_element_addr %0
153+
// CHECK: bb0: LiveWithin
154+
// CHECK: last user: end_access
155+
sil [ossa] @testScopedAddress : $@convention(thin) (@guaranteed D) -> () {
156+
bb0(%0 : @guaranteed $D):
157+
%f = ref_element_addr %0 : $D, #D.object
158+
debug_value [trace] %f : $*C
159+
%access = begin_access [read] [static] %f : $*C
160+
%o = load [copy] %access : $*C
161+
end_access %access : $*C
162+
destroy_value %o : $C
163+
%99 = tuple()
164+
return %99 : $()
165+
}
166+
167+
// CHECK-LABEL: @testDeadAddress
168+
// CHECK: SSA lifetime analysis: %0 = argument of bb0 : $D
169+
// CHECK: bb0: LiveWithin
170+
// CHECK: last user: %{{.*}} = ref_element_addr
171+
sil [ossa] @testDeadAddress : $@convention(thin) (@guaranteed D) -> () {
172+
bb0(%0 : @guaranteed $D):
173+
debug_value [trace] %0 : $D
174+
%f = ref_element_addr %0 : $D, #D.object
175+
%99 = tuple()
176+
return %99 : $()
177+
}

0 commit comments

Comments
 (0)