1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435
|
// RUN: %target-sil-opt -enable-sil-verify-all -sil-epilogue-retain-release-dumper %s | %FileCheck %s
import Builtin
import Swift
/////////////////////
// Data Structures //
/////////////////////
class foo {
var a: Int
deinit
init()
}
class bar {
var start: foo
var end: foo
deinit
init()
}
struct baz {
var start: foo
var end: foo
init()
}
struct boo {
var tbaz = baz()
var a = 0
init()
}
// CHECK-LABEL: START: sil @single_release_foo
// CHECK: [[IN1:%.*]] = argument of bb0 : $foo
// CHECK: strong_release [[IN1]] : $foo
// CHECK: END: sil @single_release_foo
sil @single_release_foo : $@convention(thin) (@owned foo) -> () {
bb0(%0 : $foo):
strong_release %0 : $foo
%3 = tuple ()
return %3 : $()
}
// CHECK-LABEL: START: sil @single_release_foo_with_epilogue_retain
// CHECK: [[IN1:%.*]] = argument of bb0 : $foo
// CHECK: strong_release [[IN1]] : $foo
// CHECK: END: sil @single_release_foo_with_epilogue_retain
sil @single_release_foo_with_epilogue_retain : $@convention(thin) (@owned foo) -> () {
bb0(%0 : $foo):
strong_release %0 : $foo
strong_retain %0 : $foo
%3 = tuple ()
return %3 : $()
}
// CHECK-LABEL: START: sil @single_release_foo_with_unknown_release
// CHECK: [[IN1:%.*]] = argument of bb0 : $foo
// CHECK-NOT: strong_release [[IN1]] : $foo
// CHECK: END: sil @single_release_foo_with_unknown_release
sil @single_release_foo_with_unknown_release : $@convention(thin) (@owned foo, @inout foo) -> () {
bb0(%0 : $foo, %1 : $*foo):
strong_release %0 : $foo
%5 = load %1 : $*foo
strong_release %5 : $foo
%3 = tuple ()
return %3 : $()
}
// CHECK-LABEL: START: sil @single_release_foo_with_unknown_retain
// CHECK: [[IN1:%.*]] = argument of bb0 : $foo
// CHECK: strong_release [[IN1]] : $foo
// CHECK: END: sil @single_release_foo_with_unknown_retain
sil @single_release_foo_with_unknown_retain : $@convention(thin) (@owned foo, @inout foo) -> () {
bb0(%0 : $foo, %1 : $*foo):
strong_release %0 : $foo
%5 = load %1 : $*foo
strong_retain %5 : $foo
%3 = tuple ()
return %3 : $()
}
// CHECK-LABEL: START: sil @single_release_foo_with_destroy_addr
// CHECK: [[IN1:%.*]] = argument of bb0 : $foo
// CHECK-NOT: strong_release [[IN1]] : $foo
// CHECK: END: sil @single_release_foo_with_destroy_addr
sil @single_release_foo_with_destroy_addr : $@convention(thin) (@owned foo, @inout foo) -> () {
bb0(%0 : $foo, %1 : $*foo):
strong_release %0 : $foo
destroy_addr %1 : $*foo
%3 = tuple ()
return %3 : $()
}
// CHECK-LABEL: START: sil @dealloc_ref_after_last_release
// CHECK: [[IN1:%.*]] = argument of bb0 : $foo
// CHECK-NOT: strong_release [[IN1]] : $foo
// CHECK: END: sil @dealloc_ref_after_last_release
sil @dealloc_ref_after_last_release : $@convention(thin) (@owned foo) -> () {
bb0(%0 : $foo):
strong_retain %0 : $foo
strong_release %0 : $foo
dealloc_ref %0 : $foo
%3 = tuple ()
return %3 : $()
}
// CHECK-LABEL: START: sil @single_release_bar
// CHECK: [[IN1:%.*]] = argument of bb0 : $bar
// CHECK: strong_release [[IN1]] : $bar
// CHECK: END: sil @single_release_bar
sil @single_release_bar : $@convention(thin) (@owned bar) -> () {
bb0(%0 : $bar):
strong_release %0 : $bar
%3 = tuple ()
return %3 : $()
}
// CHECK-LABEL: START: sil @multiple_release_bar
// CHECK: [[IN1:%.*]] = argument of bb0 : $bar
// CHECK: release_value [[IN1]] : $bar
// CHECK: END: sil @multiple_release_bar
sil @multiple_release_bar : $@convention(thin) (@owned bar) -> () {
bb0(%0 : $bar):
strong_release %0 : $bar
release_value %0 : $bar
%3 = tuple ()
return %3 : $()
}
// CHECK-LABEL: START: sil @exploded_release_baz
// CHECK: [[IN1:%.*]] = argument of bb0 : $baz
// CHECK: strong_release
// CHECK: strong_release
// CHECK: END: sil @exploded_release_baz
sil @exploded_release_baz : $@convention(thin) (@owned baz) -> () {
bb0(%0 : $baz):
%1 = struct_extract %0 : $baz, #baz.start
%2 = struct_extract %0 : $baz, #baz.end
strong_release %1 : $foo
strong_release %2 : $foo
%5 = tuple ()
return %5 : $()
}
// Make sure we stop at retain_value %0.
//
// CHECK-LABEL: START: sil @exploded_release_with_interfering_uses
// CHECK: [[IN1:%.*]] = argument of bb0 : $baz
// CHECK: strong_release
// CHECK: strong_release
// CHECK: END: sil @exploded_release_with_interfering_uses
sil @exploded_release_with_interfering_uses : $@convention(thin) (@owned baz) -> () {
bb0(%0 : $baz):
%1 = struct_extract %0 : $baz, #baz.start
%2 = struct_extract %0 : $baz, #baz.end
strong_release %1 : $foo
retain_value %0 : $baz
strong_release %2 : $foo
%3 = tuple ()
return %3 : $()
}
// Make sure we stop at an overlapping release.
//
// CHECK-LABEL: START: sil @exploded_release_with_overlapping_releases
// CHECK: [[IN1:%.*]] = argument of bb0 : $baz
// CHECK-NOT: strong_release
// CHECK: END: sil @exploded_release_with_overlapping_releases
sil @exploded_release_with_overlapping_releases : $@convention(thin) (@owned baz) -> () {
bb0(%0 : $baz):
%1 = struct_extract %0 : $baz, #baz.start
%2 = struct_extract %0 : $baz, #baz.end
strong_release %1 : $foo
release_value %0 : $baz
strong_release %2 : $foo
%5 = tuple ()
return %5 : $()
}
// CHECK-LABEL: START: sil @single_release_on_multiple_args
// CHECK: [[IN1:%.*]] = argument of bb0 : $foo
// CHECK: strong_release [[IN1]] : $foo
// CHECK: [[IN2:%.*]] = argument of bb0 : $bar
// CHECK: strong_release [[IN2]] : $bar
// CHECK: END: sil @single_release_on_multiple_args
sil @single_release_on_multiple_args : $@convention(thin) (@owned foo, @owned bar) -> () {
bb0(%0 : $foo, %1 : $bar):
strong_release %0 : $foo
strong_release %1 : $bar
%3 = tuple ()
return %3 : $()
}
// CHECK-LABEL: START: sil @single_release_on_multiple_args_with_interfering_uses
// CHECK: [[IN1:%.*]] = argument of bb0 : $foo
// CHECK: strong_release [[IN1]] : $foo
// CHECK: [[IN2:%.*]] = argument of bb0 : $bar
// CHECK: strong_release [[IN2]] : $bar
// CHECK: END: sil @single_release_on_multiple_args_with_interfering_uses
sil @single_release_on_multiple_args_with_interfering_uses : $@convention(thin) (@owned foo, @owned bar) -> () {
bb0(%0 : $foo, %1 : $bar):
strong_release %0 : $foo
strong_retain %1 : $bar
strong_release %1 : $bar
%3 = tuple ()
return %3 : $()
}
// Make sure we stop at the redundant release.
//
// CHECK-LABEL: START: sil @exploded_release_with_redundant_releases
// CHECK: [[IN1:%.*]] = argument of bb0 : $baz
// CHECK: release_value [[IN1]]
// CHECK: END: sil @exploded_release_with_redundant_releases
sil @exploded_release_with_redundant_releases : $@convention(thin) (@owned baz) -> () {
bb0(%0 : $baz):
%1 = struct_extract %0 : $baz, #baz.start
%2 = struct_extract %0 : $baz, #baz.end
strong_release %1 : $foo
strong_release %2 : $foo
release_value %0 : $baz
%5 = tuple ()
return %5 : $()
}
// Make sure we have an uncovered value type.
//
// CHECK-LABEL: START: sil @exploded_release_with_uncovered_value_semantics
// CHECK: [[IN0:%.*]] = argument of bb0 : $boo
// CHECK: release_value
// CHECK: release_value
// CHECK: END: sil @exploded_release_with_uncovered_value_semantics
sil @exploded_release_with_uncovered_value_semantics : $@convention(thin) (@owned boo) -> () {
bb0(%0 : $boo):
%1 = struct_extract %0 : $boo, #boo.tbaz
%2 = struct_extract %0 : $boo, #boo.a
%3 = struct_extract %1 : $baz, #baz.start
%4 = struct_extract %1 : $baz, #baz.end
release_value %3 : $foo
release_value %4 : $foo
%5 = tuple ()
return %5 : $()
}
// Make sure we have an uncovered reference type.
//
// CHECK-LABEL: START: sil @exploded_release_with_uncovered_reference_semantics
// CHECK: [[IN1:%.*]] = argument of bb0 : $boo
// CHECK-NOT: release_value
// CHECK: END: sil @exploded_release_with_uncovered_reference_semantics
sil @exploded_release_with_uncovered_reference_semantics : $@convention(thin) (@owned boo) -> () {
bb0(%0 : $boo):
%1 = struct_extract %0 : $boo, #boo.tbaz
%2 = struct_extract %0 : $boo, #boo.a
%3 = struct_extract %1 : $baz, #baz.start
%4 = struct_extract %1 : $baz, #baz.end
release_value %3 : $foo
%5 = tuple ()
return %5 : $()
}
// Make sure we have an uncovered reference type due to overlapping release.
//
// CHECK-LABEL: START: sil @exploded_release_with_uncovered_reference_semantics_overlapping_release
// CHECK: [[IN1:%.*]] = argument of bb0 : $boo
// CHECK-NOT: release_value
// CHECK: END: sil @exploded_release_with_uncovered_reference_semantics_overlapping_release
sil @exploded_release_with_uncovered_reference_semantics_overlapping_release : $@convention(thin) (@owned boo) -> () {
bb0(%0 : $boo):
%1 = struct_extract %0 : $boo, #boo.tbaz
%2 = struct_extract %0 : $boo, #boo.a
%3 = struct_extract %1 : $baz, #baz.start
%4 = struct_extract %1 : $baz, #baz.end
release_value %4 : $foo
release_value %3 : $foo
release_value %3 : $foo
%5 = tuple ()
return %5 : $()
}
// Make sure we can match release with argument when the released value is a silargument
// and rc-identical to the argument.
//
// CHECK-LABEL: START: sil @single_release_foo_with_silargument_one_incoming_value
// CHECK: [[IN1:%.*]] = argument of bb0 : $foo
// CHECK: strong_release [[IN2:%.*]] : $foo
// CHECK: END: sil @single_release_foo_with_silargument_one_incoming_value
sil @single_release_foo_with_silargument_one_incoming_value : $@convention(thin) (@owned foo) -> () {
bb0(%0 : $foo):
br bb1(%0: $foo)
bb1(%1 : $foo):
strong_release %1 : $foo
%3 = tuple ()
return %3 : $()
}
// CHECK-LABEL: START: sil @single_release_foo_with_silargument_multiple_incoming_values
// CHECK: [[IN1:%.*]] = argument of bb0 : $foo
// CHECK: [[IN2:%.*]] = argument of bb0 : $foo
// CHECK-NOT: strong_release [[IN1]] : $foo
// CHECK-NOT: strong_release [[IN2]] : $foo
// CHECK: END: sil @single_release_foo_with_silargument_multiple_incoming_values
sil @single_release_foo_with_silargument_multiple_incoming_values : $@convention(thin) (@owned foo, @owned foo) -> () {
bb0(%0 : $foo, %8 : $foo):
cond_br undef, bb1(%0: $foo), bb2(%8 : $foo)
bb1(%1 : $foo):
br bb3(%1 : $foo)
bb2(%2 : $foo):
br bb3( %2 : $foo)
bb3(%3 : $foo):
strong_release %3 : $foo
%4 = tuple ()
return %4 : $()
}
// CHECK-LABEL: START: sil @single_retain_foo
// CHECK: strong_retain [[IN1:%.*]] : $foo
// CHECK: END: sil @single_retain_foo
sil @single_retain_foo : $@convention(thin) (@owned foo) -> @owned foo {
bb0(%0 : $foo):
strong_retain %0 : $foo
return %0 : $foo
}
// CHECK-LABEL: START: sil @multiple_retain_foo
// CHECK: retain_value [[IN1:%.*]] : $foo
// CHECK: END: sil @multiple_retain_foo
sil @multiple_retain_foo : $@convention(thin) (@owned foo) -> @owned foo {
bb0(%0 : $foo):
strong_retain %0 : $foo
retain_value %0 : $foo
return %0 : $foo
}
// CHECK-LABEL: START: sil @retain_with_interfering_uses
// CHECK-NOT: retain_value
// CHECK: END: sil @retain_with_interfering_uses
sil @retain_with_interfering_uses : $@convention(thin) (@owned baz) -> @owned baz {
bb0(%0 : $baz):
%2 = struct_extract %0 : $baz, #baz.end
retain_value %0 : $baz
strong_release %2 : $foo
return %0 : $baz
}
// CHECK-LABEL: START: sil @single_retain_foo_with_silargument_one_incoming_value
// CHECK: strong_retain [[IN2:%.*]] : $foo
// CHECK: END: sil @single_retain_foo_with_silargument_one_incoming_value
sil @single_retain_foo_with_silargument_one_incoming_value : $@convention(thin) (@owned foo) -> @owned foo {
bb0(%0 : $foo):
br bb1(%0: $foo)
bb1(%1 : $foo):
strong_retain %1 : $foo
return %0 : $foo
}
// CHECK-LABEL: START: sil @single_retain_foo_with_silargument_multiple_incoming_values
// CHECK-NOT: strong_retain [[IN1:%.*]] : $foo
// CHECK: END: sil @single_retain_foo_with_silargument_multiple_incoming_values
sil @single_retain_foo_with_silargument_multiple_incoming_values : $@convention(thin) (@owned foo, @owned foo) -> @owned foo {
bb0(%0 : $foo, %8 : $foo):
cond_br undef, bb1(%0: $foo), bb2(%8 : $foo)
bb1(%1 : $foo):
br bb3(%1 : $foo)
bb2(%2 : $foo):
br bb3( %2 : $foo)
bb3(%3 : $foo):
strong_retain %3 : $foo
return %0 : $foo
}
// CHECK-LABEL: START: sil @exploded_retain
// CHECK-NOT: strong_retain
// CHECK: END: sil @exploded_retain
sil @exploded_retain : $@convention(thin) (@owned boo) -> @owned boo {
bb0(%0 : $boo):
%1 = struct_extract %0 : $boo, #boo.tbaz
%2 = struct_extract %0 : $boo, #boo.a
%3 = struct_extract %1 : $baz, #baz.start
%4 = struct_extract %1 : $baz, #baz.end
strong_retain %4 : $foo
strong_retain %3 : $foo
return %0 : $boo
}
// CHECK-LABEL: START: sil @epilogue_retains_in_split_block
// CHECK: strong_retain [[IN1:%.*]] : $foo
// CHECK: strong_retain [[IN2:%.*]] : $foo
// CHECK: END: sil @epilogue_retains_in_split_block
sil @epilogue_retains_in_split_block : $@convention(thin) (@owned foo) -> @owned foo {
bb0(%0 : $foo):
cond_br undef, bb1(%0: $foo), bb2(%0 : $foo)
bb1(%1 : $foo):
strong_retain %1 : $foo
br bb3(%1 : $foo)
bb2(%2 : $foo):
strong_retain %2 : $foo
br bb3( %2 : $foo)
bb3(%3 : $foo):
return %0 : $foo
}
// CHECK-LABEL: START: sil @epilogue_retains_in_diamond_top_block
// CHECK: strong_retain [[IN1:%.*]] : $foo
// CHECK: END: sil @epilogue_retains_in_diamond_top_block
sil @epilogue_retains_in_diamond_top_block : $@convention(thin) (@owned foo) -> @owned foo {
bb0(%0 : $foo):
strong_retain %0 : $foo
cond_br undef, bb1(%0: $foo), bb2(%0 : $foo)
bb1(%1 : $foo):
br bb3(%1 : $foo)
bb2(%2 : $foo):
br bb3( %2 : $foo)
bb3(%3 : $foo):
return %0 : $foo
}
// CHECK-LABEL: START: sil @epilogue_retains_in_diamond_top_and_left_split_block
// CHECK-NOT: strong_retain [[IN1:%.*]] : $foo
// CHECK: END: sil @epilogue_retains_in_diamond_top_and_left_split_block
sil @epilogue_retains_in_diamond_top_and_left_split_block : $@convention(thin) (@owned foo) -> @owned foo {
bb0(%0 : $foo):
strong_retain %0 : $foo
cond_br undef, bb1(%0: $foo), bb2(%0 : $foo)
bb1(%1 : $foo):
strong_retain %1 : $foo
br bb3(%1 : $foo)
bb2(%2 : $foo):
br bb3( %2 : $foo)
bb3(%3 : $foo):
return %0 : $foo
}
|