@@ -70,4 +70,74 @@ bb0(%0 : @owned $String, %1 : $Int):
70
70
return %4 : $String
71
71
}
72
72
73
+ // CHECK-LABEL: sil [ossa] @forward_with_copy :
74
+ // CHECK: %2 = copy_value %0
75
+ // CHECK: %3 = struct $S (%0 : $String, %1 : $Int)
76
+ // CHECK: fix_lifetime %1
77
+ // CHECK: destroy_value %3
78
+ // CHECK: return %2
79
+ // CHECK: } // end sil function 'forward_with_copy'
80
+ sil [ossa] @forward_with_copy : $@convention(thin) (@owned String, Int) -> @owned String {
81
+ bb0(%0 : @owned $String, %1 : $Int):
82
+ %2 = struct $S (%0 : $String, %1 : $Int)
83
+ %3 = copy_value %2 : $S
84
+ (%4, %5) = destructure_struct %3 : $S
85
+ fix_lifetime %5 : $Int
86
+ destroy_value %2 : $S
87
+ return %4 : $String
88
+ }
89
+
90
+ // CHECK-LABEL: sil [ossa] @forward_with_two_copies :
91
+ // CHECK: %2 = copy_value %0
92
+ // CHECK: %3 = struct $S (%0 : $String, %1 : $Int)
93
+ // CHECK: %4 = copy_value %3
94
+ // CHECK: fix_lifetime %1
95
+ // CHECK: destroy_value %3
96
+ // CHECK: destroy_value %4
97
+ // CHECK: return %2
98
+ // CHECK: } // end sil function 'forward_with_two_copies'
99
+ sil [ossa] @forward_with_two_copies : $@convention(thin) (@owned String, Int) -> @owned String {
100
+ bb0(%0 : @owned $String, %1 : $Int):
101
+ %2 = struct $S (%0 : $String, %1 : $Int)
102
+ %3 = copy_value %2 : $S
103
+ %4 = copy_value %3 : $S
104
+ (%5, %6) = destructure_struct %4 : $S
105
+ fix_lifetime %6 : $Int
106
+ destroy_value %2 : $S
107
+ destroy_value %3 : $S
108
+ return %5 : $String
109
+ }
110
+
111
+ // CHECK-LABEL: sil [ossa] @copy_has_other_uses :
112
+ // CHECK: destructure_struct
113
+ // CHECK: } // end sil function 'copy_has_other_uses'
114
+ sil [ossa] @copy_has_other_uses : $@convention(thin) (@owned String, Int) -> @owned String {
115
+ bb0(%0 : @owned $String, %1 : $Int):
116
+ %2 = struct $S (%0 : $String, %1 : $Int)
117
+ %3 = copy_value %2 : $S
118
+ fix_lifetime %3 : $S
119
+ (%5, %6) = destructure_struct %3 : $S
120
+ fix_lifetime %6 : $Int
121
+ destroy_value %2 : $S
122
+ return %5 : $String
123
+ }
124
+
125
+ // CHECK-LABEL: sil [ossa] @different_basic_block :
126
+ // CHECK: bb2:
127
+ // CHECK: destructure_struct
128
+ // CHECK: } // end sil function 'different_basic_block'
129
+ sil [ossa] @different_basic_block : $@convention(thin) (@owned String, Int) -> @owned String {
130
+ bb0(%0 : @owned $String, %1 : $Int):
131
+ %2 = struct $S (%0 : $String, %1 : $Int)
132
+ %3 = copy_value %2 : $S
133
+ cond_br undef, bb1, bb2
134
+ bb1:
135
+ destroy_value %3 : $S
136
+ unreachable
137
+ bb2:
138
+ (%4, %5) = destructure_struct %3 : $S
139
+ fix_lifetime %5 : $Int
140
+ destroy_value %2 : $S
141
+ return %4 : $String
142
+ }
73
143
0 commit comments