Skip to content

Commit 98b6e09

Browse files
committed
Add a transitive liveness test case
1 parent 9e0b615 commit 98b6e09

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/SILOptimizer/ossa_lifetime_analysis.sil

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ case some(T)
2020
}
2121

2222
class C {}
23+
class D {
24+
var object: C
25+
}
2326

2427
// CHECK-LABEL: @testSelfLoop
2528
// CHECK: SSA lifetime analysis: [[V:%.*]] = copy_value %0 : $C
@@ -109,3 +112,23 @@ bb4:
109112
%99 = tuple()
110113
return %99 : $()
111114
}
115+
116+
// CHECK-LABEL: @testGuaranteedForwarding
117+
// CHECK: SSA lifetime analysis: [[C:%.*]] = unchecked_ref_cast %{{.*}} : $D to $C
118+
// CHECK: bb0: LiveWithin
119+
// CHECK: regular user: %{{.*}} = load [copy]
120+
// CHECK: last user: %{{.*}} = load [copy]
121+
sil [ossa] @testGuaranteedForwarding : $@convention(thin) (@owned D) -> () {
122+
bb0(%0 : @owned $D):
123+
%borrow0 = begin_borrow %0 : $D
124+
%c = unchecked_ref_cast %borrow0 : $D to $C
125+
debug_value [trace] %c : $C
126+
%d = unchecked_ref_cast %c : $C to $D
127+
%f = ref_element_addr %d : $D, #D.object
128+
%o = load [copy] %f : $*C
129+
end_borrow %borrow0 : $D
130+
destroy_value %o : $C
131+
destroy_value %0 : $D
132+
%99 = tuple()
133+
return %99 : $()
134+
}

0 commit comments

Comments
 (0)