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 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798
|
// RUN: %target-sil-opt %s -dump-addr-escape-info -o /dev/null | %FileCheck %s
// REQUIRES: swift_in_compiler
sil_stage canonical
import Builtin
import Swift
import SwiftShims
struct Str {
@_hasStorage var a: Int
@_hasStorage var b: Int
}
class X {
@_hasStorage var s: Str
}
class D: X {}
struct Container {
@_hasStorage var x: X
}
struct XandInt {
@_hasStorage var x: X
@_hasStorage var i: Int
}
class XandIntClass {
@_hasStorage var x: X
@_hasStorage var i: Int
}
protocol P {}
extension Int : P {}
sil @no_arguments : $@convention(thin) () -> ()
sil @indirect_argument : $@convention(thin) (@in Int) -> ()
sil @indirect_struct_argument : $@convention(thin) (@in Str) -> ()
sil @direct_argument : $@convention(thin) (Int) -> ()
sil @class_argument : $@convention(thin) (@guaranteed X) -> ()
sil @non_escaping_class_argument : $@convention(thin) (@guaranteed X) -> () {
[%0: noescape]
}
sil @inout_class_argument : $@convention(thin) (@inout X) -> () {
[%0: noescape **]
}
sil @container_argument : $@convention(thin) (@guaranteed Container) -> ()
sil @take_closure_as_addr : $@convention(thin) (@in @callee_guaranteed () -> ()) -> ()
sil @take_closure_as_addr_noescape : $@convention(thin) (@in @callee_guaranteed () -> ()) -> () {
[%0: noescape **]
}
sil @closure_with_inout : $@convention(thin) (@inout Str) -> () {
[%0: noescape **]
}
sil @initX : $@convention(method) (@owned X) -> @owned X {
[%0: escape => %r, escape c*.v** => %r.c*.v**]
}
sil @modifyStr : $@convention(method) (@inout Str) -> ()
sil @guaranteed_yield_coroutine : $@yield_once @convention(thin) (@inout X) -> @yields @inout X
sil @in_ptr : $@convention(thin) (@in Builtin.RawPointer) -> ()
// CHECK-LABEL: Address escape information for test_simple:
// CHECK: value: %1 = struct_element_addr %0 : $*Str, #Str.a
// CHECK-NEXT: ==> %7 = apply %6(%5) : $@convention(thin) (@in Int) -> ()
// CHECK-NEXT: - %10 = apply %8(%9) : $@convention(thin) (Int) -> ()
// CHECK: value: %3 = struct_element_addr %0 : $*Str, #Str.b
// CHECK-NEXT: - %7 = apply %6(%5) : $@convention(thin) (@in Int) -> ()
// CHECK-NEXT: - %10 = apply %8(%9) : $@convention(thin) (Int) -> ()
// CHECK: pair 0 - 1
// CHECK-NEXT: %1 = struct_element_addr %0 : $*Str, #Str.a
// CHECK-NEXT: %3 = struct_element_addr %0 : $*Str, #Str.b
// CHECK-NEXT: no alias
// CHECK: End function test_simple
sil @test_simple : $@convention(thin) () -> () {
bb0:
%0 = alloc_stack $Str
%1 = struct_element_addr %0 : $*Str, #Str.a
fix_lifetime %1 : $*Int
%3 = struct_element_addr %0 : $*Str, #Str.b
fix_lifetime %3 : $*Int
%5 = struct_element_addr %0 : $*Str, #Str.a
%6 = function_ref @indirect_argument : $@convention(thin) (@in Int) -> ()
%7 = apply %6(%5) : $@convention(thin) (@in Int) -> ()
%8 = function_ref @direct_argument : $@convention(thin) (Int) -> ()
%9 = load %3 : $*Int
%10 = apply %8(%9) : $@convention(thin) (Int) -> ()
dealloc_stack %0 : $*Str
%12 = tuple ()
return %12 : $()
}
// CHECK-LABEL: Address escape information for test_class:
// CHECK: value: %0 = alloc_ref $X
// CHECK-NEXT: ==> %11 = apply %10(%0) : $@convention(thin) (@guaranteed X) -> ()
// CHECK: value: %2 = struct_element_addr %1 : $*Str, #Str.a
// CHECK-NEXT: ==> %11 = apply %10(%0) : $@convention(thin) (@guaranteed X) -> ()
// CHECK: value: %5 = alloc_ref $X
// CHECK-NEXT: - %11 = apply %10(%0) : $@convention(thin) (@guaranteed X) -> ()
// CHECK: value: %7 = struct_element_addr %6 : $*Str, #Str.a
// CHECK-NEXT: - %11 = apply %10(%0) : $@convention(thin) (@guaranteed X) -> ()
// CHECK: pair 0 - 1
// CHECK-NEXT: %0 = alloc_ref $X
// CHECK-NEXT: %2 = struct_element_addr %1 : $*Str, #Str.a
// CHECK-NEXT: may alias
// CHECK: pair 0 - 2
// CHECK-NEXT: %0 = alloc_ref $X
// CHECK-NEXT: %5 = alloc_ref $X
// CHECK-NEXT: no alias
// CHECK: pair 0 - 3
// CHECK-NEXT: %0 = alloc_ref $X
// CHECK-NEXT: %7 = struct_element_addr %6 : $*Str, #Str.a
// CHECK-NEXT: no alias
// CHECK: pair 1 - 2
// CHECK-NEXT: %2 = struct_element_addr %1 : $*Str, #Str.a
// CHECK-NEXT: %5 = alloc_ref $X
// CHECK-NEXT: no alias
// CHECK: pair 1 - 3
// CHECK-NEXT: %2 = struct_element_addr %1 : $*Str, #Str.a
// CHECK-NEXT: %7 = struct_element_addr %6 : $*Str, #Str.a
// CHECK-NEXT: no alias
// CHECK: pair 2 - 3
// CHECK-NEXT: %5 = alloc_ref $X
// CHECK-NEXT: %7 = struct_element_addr %6 : $*Str, #Str.a
// CHECK-NEXT: may alias
// CHECK: End function test_class
sil @test_class : $@convention(thin) () -> X {
bb0:
%0 = alloc_ref $X
%1 = ref_element_addr %0 : $X, #X.s
%2 = struct_element_addr %1 : $*Str, #Str.a
fix_lifetime %0 : $X
fix_lifetime %2 : $*Int
%5 = alloc_ref $X
%6 = ref_element_addr %5 : $X, #X.s
%7 = struct_element_addr %6 : $*Str, #Str.a
fix_lifetime %5 : $X
fix_lifetime %7 : $*Int
%10 = function_ref @class_argument : $@convention(thin) (@guaranteed X) -> ()
%11 = apply %10(%0) : $@convention(thin) (@guaranteed X) -> ()
return %5 : $X
}
sil @return_x : $@convention(thin) (@guaranteed X) -> @owned X
// CHECK-LABEL: Address escape information for test_class_argument:
// CHECK: pair 0 - 1
// CHECK-NEXT: %0 = alloc_ref $X
// CHECK-NEXT: %3 = ref_element_addr %2 : $X, #X.s
// CHECK-NEXT: may alias
// CHECK: End function test_class_argument
sil @test_class_argument : $@convention(thin) () -> () {
bb0:
%0 = alloc_ref $X
%1 = function_ref @return_x : $@convention(thin) (@guaranteed X) -> @owned X
%2 = apply %1(%0) : $@convention(thin) (@guaranteed X) -> @owned X
%3 = ref_element_addr %2 : $X, #X.s
fix_lifetime %0 : $X
fix_lifetime %3 : $*Str
%12 = tuple ()
return %12 : $()
}
// CHECK-LABEL: Address escape information for test_reachable_no_alias:
// CHECK: pair 0 - 1
// CHECK-NEXT: %3 = ref_element_addr %2 : $X, #X.s
// CHECK-NEXT: %0 = alloc_ref $XandIntClass
// CHECK-NEXT: address reachable but no alias
// CHECK: End function test_reachable_no_alias
sil @test_reachable_no_alias : $@convention(thin) () -> () {
bb0:
%0 = alloc_ref $XandIntClass
%1 = ref_element_addr %0 : $XandIntClass, #XandIntClass.x
%2 = load %1 : $*X
%3 = ref_element_addr %2 : $X, #X.s
fix_lifetime %3 : $*Str
fix_lifetime %0 : $XandIntClass
%12 = tuple ()
return %12 : $()
}
// CHECK-LABEL: Address escape information for test_struct_with_class:
// CHECK: value: %1 = struct $Container (%0 : $X)
// CHECK-NEXT: ==> %7 = apply %6(%1) : $@convention(thin) (@guaranteed Container) -> ()
// CHECK: value: %4 = struct $Container (%3 : $X)
// CHECK-NEXT: - %7 = apply %6(%1) : $@convention(thin) (@guaranteed Container) -> ()
// CHECK: End function test_struct_with_class
sil @test_struct_with_class : $@convention(thin) () -> Container {
bb0:
%0 = alloc_ref $X
%1 = struct $Container (%0 : $X)
fix_lifetime %1 : $Container
%3 = alloc_ref $X
%4 = struct $Container (%3 : $X)
fix_lifetime %4 : $Container
%6 = function_ref @container_argument : $@convention(thin) (@guaranteed Container) -> ()
%10 = apply %6(%1) : $@convention(thin) (@guaranteed Container) -> ()
return %4 : $Container
}
// CHECK-LABEL: Address escape information for ignore_indirect_arg_of_other_call:
// CHECK: value: %1 = ref_element_addr %0 : $X, #X.s
// CHECK-NEXT: ==> %5 = apply %4(%3) : $@convention(thin) (@in Int) -> ()
// CHECK-NEXT: - %7 = apply %6() : $@convention(thin) () -> ()
// CHECK: End function ignore_indirect_arg_of_other_call
sil @ignore_indirect_arg_of_other_call : $@convention(thin) () -> () {
bb0:
%0 = alloc_ref $X
%1 = ref_element_addr %0 : $X, #X.s
fix_lifetime %1 : $*Str
%3 = struct_element_addr %1 : $*Str, #Str.a
%4 = function_ref @indirect_argument : $@convention(thin) (@in Int) -> ()
%5 = apply %4(%3) : $@convention(thin) (@in Int) -> ()
%6 = function_ref @no_arguments : $@convention(thin) () -> ()
%7 = apply %6() : $@convention(thin) () -> ()
%8 = tuple ()
return %8 : $()
}
// CHECK-LABEL: Address escape information for dont_ignore_direct_arg_of_other_call:
// CHECK: value: %1 = ref_element_addr %0 : $X, #X.s
// CHECK-NEXT: ==> %4 = apply %3(%0) : $@convention(thin) (@guaranteed X) -> ()
// CHECK-NEXT: ==> %6 = apply %5() : $@convention(thin) () -> ()
// CHECK: End function dont_ignore_direct_arg_of_other_call
sil @dont_ignore_direct_arg_of_other_call : $@convention(thin) () -> () {
bb0:
%0 = alloc_ref $X
%1 = ref_element_addr %0 : $X, #X.s
fix_lifetime %1 : $*Str
%3 = function_ref @class_argument : $@convention(thin) (@guaranteed X) -> ()
%4 = apply %3(%0) : $@convention(thin) (@guaranteed X) -> ()
%5 = function_ref @no_arguments : $@convention(thin) () -> ()
%6 = apply %5() : $@convention(thin) () -> ()
%7 = tuple ()
return %7 : $()
}
// CHECK-LABEL: Address escape information for ignore_non_escaping_arg_of_other_call:
// CHECK: value: %1 = ref_element_addr %0 : $X, #X.s
// CHECK-NEXT: ==> %4 = apply %3(%0) : $@convention(thin) (@guaranteed X) -> ()
// CHECK-NEXT: - %6 = apply %5() : $@convention(thin) () -> ()
// CHECK: End function ignore_non_escaping_arg_of_other_call
sil @ignore_non_escaping_arg_of_other_call : $@convention(thin) () -> () {
bb0:
%0 = alloc_ref $X
%1 = ref_element_addr %0 : $X, #X.s
fix_lifetime %1 : $*Str
%3 = function_ref @non_escaping_class_argument : $@convention(thin) (@guaranteed X) -> ()
%4 = apply %3(%0) : $@convention(thin) (@guaranteed X) -> ()
%5 = function_ref @no_arguments : $@convention(thin) () -> ()
%6 = apply %5() : $@convention(thin) () -> ()
%7 = tuple ()
return %7 : $()
}
// CHECK-LABEL: Address escape information for dont_ignore_non_escaping_arg_of_other_call_if_followstores:
// CHECK: value: %7 = ref_element_addr %6 : $X, #X.s
// CHECK-NEXT: ==> %5 = apply %4(%1) : $@convention(thin) (@inout X) -> ()
// CHECK-NEXT: ==> %10 = apply %9() : $@convention(thin) () -> ()
// CHECK: End function dont_ignore_non_escaping_arg_of_other_call_if_followstores
sil @dont_ignore_non_escaping_arg_of_other_call_if_followstores : $@convention(thin) () -> () {
bb0:
%0 = alloc_ref $X
%1 = alloc_stack $X
store %0 to %1 : $*X
%3 = alloc_ref $X
%4 = function_ref @inout_class_argument : $@convention(thin) (@inout X) -> ()
%5 = apply %4(%1) : $@convention(thin) (@inout X) -> ()
%6 = load %1 : $*X
%7 = ref_element_addr %6 : $X, #X.s
fix_lifetime %7 : $*Str
%9 = function_ref @no_arguments : $@convention(thin) () -> ()
%10 = apply %9() : $@convention(thin) () -> ()
dealloc_stack %1 : $*X
%12 = tuple ()
return %12 : $()
}
// CHECK-LABEL: Address escape information for indirect_argument_escape_to_yield:
// CHECK: value: %1 = alloc_stack $X
// CHECK-NEXT: ==> (%5, %6) = begin_apply %4(%1) : $@yield_once @convention(thin) (@inout X) -> @yields @inout X
// CHECK-NEXT: ==> %8 = apply %7(%5) : $@convention(thin) (@inout X) -> ()
// CHECK: End function indirect_argument_escape_to_yield
sil @indirect_argument_escape_to_yield : $@convention(thin) (@guaranteed X) -> () {
bb0(%0 : $X):
%1 = alloc_stack $X
store %0 to %1 : $*X
fix_lifetime %1 : $*X
%3 = function_ref @guaranteed_yield_coroutine : $@yield_once @convention(thin) (@inout X) -> @yields @inout X
(%4, %5) = begin_apply %3(%1) : $@yield_once @convention(thin) (@inout X) -> @yields @inout X
%6 = function_ref @inout_class_argument : $@convention(thin) (@inout X) -> ()
%7 = apply %6(%4) : $@convention(thin) (@inout X) -> ()
end_apply %5
dealloc_stack %1 : $*X
%r = tuple ()
return %r : $()
}
// CHECK-LABEL: Address escape information for ignore_copy_addr_and_release:
// CHECK: value: %1 = ref_element_addr %0 : $X, #X.s
// CHECK-NEXT: - %6 = apply %5(%3) : $@convention(thin) (@in Str) -> ()
// CHECK: End function ignore_copy_addr_and_release
sil @ignore_copy_addr_and_release : $@convention(thin) () -> () {
bb0:
%0 = alloc_ref $X
%1 = ref_element_addr %0 : $X, #X.s
fix_lifetime %1 : $*Str
%3 = alloc_stack $Str
copy_addr %1 to [init] %3 : $*Str
%5 = function_ref @indirect_struct_argument : $@convention(thin) (@in Str) -> ()
%6 = apply %5(%3) : $@convention(thin) (@in Str) -> ()
strong_release %0 : $X
dealloc_stack %3 : $*Str
%9 = tuple ()
return %9 : $()
}
// CHECK-LABEL: Address escape information for non_aliased_addr_arg:
// CHECK: value:%0 = argument of bb0 : $*Int
// CHECK-NEXT: - %3 = apply %2() : $@convention(thin) () -> ()
// CHECK: End function non_aliased_addr_arg
sil @non_aliased_addr_arg : $@convention(thin) (@inout Int) -> () {
bb0(%0 : $*Int):
fix_lifetime %0 : $*Int
%2 = function_ref @no_arguments : $@convention(thin) () -> ()
%3 = apply %2() : $@convention(thin) () -> ()
%4 = tuple ()
return %4 : $()
}
// CHECK-LABEL: Address escape information for aliased_addr_arg:
// CHECK: value:%0 = argument of bb0 : $*Int
// CHECK-NEXT: ==> %3 = apply %2() : $@convention(thin) () -> ()
// CHECK: End function aliased_addr_arg
sil @aliased_addr_arg : $@convention(thin) (@inout_aliasable Int) -> () {
bb0(%0 : $*Int):
fix_lifetime %0 : $*Int
%2 = function_ref @no_arguments : $@convention(thin) () -> ()
%3 = apply %2() : $@convention(thin) () -> ()
%4 = tuple ()
return %4 : $()
}
// CHECK-LABEL: Address escape information for adddr_arg_with_aliased_content:
// CHECK: value: %2 = ref_element_addr %1 : $X, #X.s
// CHECK-NEXT: ==> %5 = apply %4() : $@convention(thin) () -> ()
// CHECK: End function adddr_arg_with_aliased_content
sil @adddr_arg_with_aliased_content : $@convention(thin) (@inout X) -> () {
bb0(%0 : $*X):
%1 = load %0 : $*X
%2 = ref_element_addr %1 : $X, #X.s
fix_lifetime %2 : $*Str
%4 = function_ref @no_arguments : $@convention(thin) () -> ()
%5 = apply %4() : $@convention(thin) () -> ()
%6 = tuple ()
return %6 : $()
}
// CHECK-LABEL: Address escape information for pointer_arg:
// CHECK: value: %1 = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*Str
// CHECK-NEXT: ==> %4 = apply %3() : $@convention(thin) () -> ()
// CHECK: End function pointer_arg
sil @pointer_arg : $@convention(thin) (Builtin.RawPointer) -> () {
bb0(%0 : $Builtin.RawPointer):
%1 = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*Str
fix_lifetime %1 : $*Str
%3 = function_ref @no_arguments : $@convention(thin) () -> ()
%4 = apply %3() : $@convention(thin) () -> ()
%5 = tuple ()
return %5 : $()
}
// CHECK-LABEL: Address escape information for follow_stores_to_arg:
// CHECK: value: %2 = pointer_to_address %1 : $Builtin.RawPointer to [strict] $*Str
// CHECK-NEXT: ==> %5 = apply %4() : $@convention(thin) () -> ()
// CHECK: End function follow_stores_to_arg
sil @follow_stores_to_arg : $@convention(thin) (@inout Builtin.RawPointer) -> () {
bb0(%0 : $*Builtin.RawPointer):
%1 = load %0 : $*Builtin.RawPointer
%2 = pointer_to_address %1 : $Builtin.RawPointer to [strict] $*Str
fix_lifetime %2 : $*Str
%4 = function_ref @no_arguments : $@convention(thin) () -> ()
%5 = apply %4() : $@convention(thin) () -> ()
%6 = tuple ()
return %6 : $()
}
// CHECK-LABEL: Address escape information for partial_apply:
// CHECK: value: %0 = alloc_stack $Str
// CHECK-NEXT: - %5 = apply %4() : $@convention(thin) () -> ()
// CHECK: End function partial_apply
sil @partial_apply : $@convention(thin) () -> () {
bb0:
%0 = alloc_stack $Str
fix_lifetime %0 : $*Str
%2 = function_ref @closure_with_inout : $@convention(thin) (@inout Str) -> ()
%3 = partial_apply [callee_guaranteed] [on_stack] %2(%0) : $@convention(thin) (@inout Str) -> ()
%8 = function_ref @no_arguments : $@convention(thin) () -> ()
%9 = apply %8() : $@convention(thin) () -> ()
dealloc_stack %3 : $@callee_guaranteed @noescape () -> ()
dealloc_stack %0 : $*Str
%12 = tuple ()
return %12 : $()
}
// CHECK-LABEL: Address escape information for partial_apply_with_inout:
// CHECK: value: %0 = alloc_stack $Str
// CHECK-NEXT: ==> %7 = apply %6(%4) : $@convention(thin) (@in @callee_guaranteed () -> ()) -> ()
// CHECK-NEXT: ==> %9 = apply %8() : $@convention(thin) () -> ()
// CHECK: End function partial_apply_with_inout
sil @partial_apply_with_inout : $@convention(thin) () -> () {
bb0:
%0 = alloc_stack $Str
fix_lifetime %0 : $*Str
%2 = function_ref @closure_with_inout : $@convention(thin) (@inout Str) -> ()
%3 = partial_apply [callee_guaranteed] %2(%0) : $@convention(thin) (@inout Str) -> ()
%4 = alloc_stack $@callee_guaranteed () -> ()
store %3 to %4 : $*@callee_guaranteed () -> ()
%6 = function_ref @take_closure_as_addr : $@convention(thin) (@in @callee_guaranteed () -> ()) -> ()
%7 = apply %6(%4) : $@convention(thin) (@in @callee_guaranteed () -> ()) -> ()
%8 = function_ref @no_arguments : $@convention(thin) () -> ()
%9 = apply %8() : $@convention(thin) () -> ()
dealloc_stack %4 : $*@callee_guaranteed () -> ()
dealloc_stack %0 : $*Str
%12 = tuple ()
return %12 : $()
}
// CHECK-LABEL: Address escape information for partial_apply_with_inout_noescape:
// CHECK: value: %0 = alloc_stack $Str
// CHECK-NEXT: ==> %7 = apply %6(%4) : $@convention(thin) (@in @callee_guaranteed () -> ()) -> ()
// CHECK-NEXT: - %9 = apply %8() : $@convention(thin) () -> ()
// CHECK: End function partial_apply_with_inout_noescape
sil @partial_apply_with_inout_noescape : $@convention(thin) () -> () {
bb0:
%0 = alloc_stack $Str
fix_lifetime %0 : $*Str
%2 = function_ref @closure_with_inout : $@convention(thin) (@inout Str) -> ()
%3 = partial_apply [callee_guaranteed] %2(%0) : $@convention(thin) (@inout Str) -> ()
%4 = alloc_stack $@callee_guaranteed () -> ()
store %3 to %4 : $*@callee_guaranteed () -> ()
%6 = function_ref @take_closure_as_addr_noescape : $@convention(thin) (@in @callee_guaranteed () -> ()) -> ()
%7 = apply %6(%4) : $@convention(thin) (@in @callee_guaranteed () -> ()) -> ()
%8 = function_ref @no_arguments : $@convention(thin) () -> ()
%9 = apply %8() : $@convention(thin) () -> ()
dealloc_stack %4 : $*@callee_guaranteed () -> ()
dealloc_stack %0 : $*Str
%12 = tuple ()
return %12 : $()
}
// CHECK-LABEL: Address escape information for non_escaping_trivial_member:
// CHECK: value: %2 = struct $XandInt (%1 : $X, %0 : $Int)
// CHECK-NEXT: - %8 = apply %7(%6) : $@convention(thin) (@in Int) -> ()
// CHECK: End function non_escaping_trivial_member
sil @non_escaping_trivial_member : $@convention(thin) (Int) -> () {
bb0(%0 : $Int):
%1 = alloc_ref $X
%2 = struct $XandInt(%1 : $X, %0 : $Int)
%3 = alloc_stack $XandInt
store %2 to %3 : $*XandInt
fix_lifetime %2 : $XandInt
%6 = struct_element_addr %3 : $*XandInt, #XandInt.i
%7 = function_ref @indirect_argument : $@convention(thin) (@in Int) -> ()
%8 = apply %7(%6) : $@convention(thin) (@in Int) -> ()
dealloc_stack %3 : $*XandInt
%12 = tuple ()
return %12 : $()
}
// CHECK-LABEL: Address escape information for escaping_nontrivial_member:
// CHECK: value: %2 = struct $XandInt (%1 : $X, %0 : $Int)
// CHECK-NEXT: ==> %8 = apply %7(%6) : $@convention(thin) (@inout X) -> ()
// CHECK: End function escaping_nontrivial_member
sil @escaping_nontrivial_member : $@convention(thin) (Int) -> () {
bb0(%0 : $Int):
%1 = alloc_ref $X
%2 = struct $XandInt(%1 : $X, %0 : $Int)
%3 = alloc_stack $XandInt
store %2 to %3 : $*XandInt
fix_lifetime %2 : $XandInt
%6 = struct_element_addr %3 : $*XandInt, #XandInt.x
%7 = function_ref @inout_class_argument : $@convention(thin) (@inout X) -> ()
%8 = apply %7(%6) : $@convention(thin) (@inout X) -> ()
dealloc_stack %3 : $*XandInt
%10 = tuple ()
return %10 : $()
}
// CHECK-LABEL: Address escape information for escaping_address_in_nontrivial_member:
// CHECK: value: %2 = struct $XandInt (%1 : $X, %0 : $Int)
// CHECK-NEXT: ==> %11 = apply %10(%9) : $@convention(thin) (@in Int) -> ()
// CHECK: End function escaping_address_in_nontrivial_member
sil @escaping_address_in_nontrivial_member : $@convention(thin) (Int) -> () {
bb0(%0 : $Int):
%1 = alloc_ref $X
%2 = struct $XandInt(%1 : $X, %0 : $Int)
%3 = alloc_stack $XandInt
store %2 to %3 : $*XandInt
fix_lifetime %2 : $XandInt
%6 = struct_element_addr %3 : $*XandInt, #XandInt.x
%7 = load %6 : $*X
%8 = ref_element_addr %7 : $X, #X.s
%9 = struct_element_addr %8 : $*Str, #Str.a
%10 = function_ref @indirect_argument : $@convention(thin) (@in Int) -> ()
%11 = apply %10(%9) : $@convention(thin) (@in Int) -> ()
dealloc_stack %3 : $*XandInt
%13 = tuple ()
return %13 : $()
}
// CHECK-LABEL: Address escape information for bidirectly_forward_property_addr:
// CHECK: value: %3 = ref_element_addr %2 : $X, #X.s
// CHECK-NEXT: ==> %2 = apply %1(%0) : $@convention(method) (@owned X) -> @owned X
// CHECK-NEXT: ==> %6 = apply %5(%3) : $@convention(method) (@inout Str) -> ()
// CHECK: End function bidirectly_forward_property_addr
sil @bidirectly_forward_property_addr : $@convention(thin) () -> () {
bb0:
%0 = alloc_ref $X
%1 = function_ref @initX : $@convention(method) (@owned X) -> @owned X
%2 = apply %1(%0) : $@convention(method) (@owned X) -> @owned X
%3 = ref_element_addr %2 : $X, #X.s
fix_lifetime %3 : $*Str
%5 = function_ref @modifyStr : $@convention(method) (@inout Str) -> ()
%6 = apply %5(%3) : $@convention(method) (@inout Str) -> ()
%7 = tuple ()
return %7 : $()
}
// CHECK-LABEL: Address escape information for load_rawpointer:
// CHECK: value: %5 = pointer_to_address %4 : $Builtin.RawPointer to [strict] $*Int
// CHECK-NEXT: ==> %8 = apply %7(%5) : $@convention(thin) (@in Int) -> ()
// CHECK: End function load_rawpointer
sil @load_rawpointer : $@convention(thin) () -> () {
bb0:
%0 = alloc_stack $Int
%1 = address_to_pointer %0 : $*Int to $Builtin.RawPointer
%2 = alloc_stack $Builtin.RawPointer
store %1 to %2 : $*Builtin.RawPointer
%4 = load %2 : $*Builtin.RawPointer
%5 = pointer_to_address %4 : $Builtin.RawPointer to [strict] $*Int
fix_lifetime %5 : $*Int
%7 = function_ref @indirect_argument : $@convention(thin) (@in Int) -> ()
%8 = apply %7(%5) : $@convention(thin) (@in Int) -> ()
dealloc_stack %2 : $*Builtin.RawPointer
dealloc_stack %0 : $*Int
%r = tuple ()
return %r : $()
}
// CHECK-LABEL: Address escape information for test_addr_alias1:
// CHECK: pair 0 - 1
// CHECK-NEXT: %2 = ref_element_addr %0 : $XandIntClass, #XandIntClass.x
// CHECK-NEXT: %4 = ref_element_addr %0 : $XandIntClass, #XandIntClass.i
// CHECK-NEXT: no alias
// CHECK: pair 0 - 2
// CHECK-NEXT: %2 = ref_element_addr %0 : $XandIntClass, #XandIntClass.x
// CHECK-NEXT: %5 = ref_element_addr %1 : $X, #X.s
// CHECK-NEXT: no alias
// CHECK: pair 0 - 3
// CHECK-NEXT: %2 = ref_element_addr %0 : $XandIntClass, #XandIntClass.x
// CHECK-NEXT: %6 = struct_element_addr %5 : $*Str, #Str.a
// CHECK-NEXT: no alias
// CHECK: pair 1 - 2
// CHECK-NEXT: %4 = ref_element_addr %0 : $XandIntClass, #XandIntClass.i
// CHECK-NEXT: %5 = ref_element_addr %1 : $X, #X.s
// CHECK-NEXT: no alias
// CHECK: pair 1 - 3
// CHECK-NEXT: %4 = ref_element_addr %0 : $XandIntClass, #XandIntClass.i
// CHECK-NEXT: %6 = struct_element_addr %5 : $*Str, #Str.a
// CHECK-NEXT: no alias
// CHECK: pair 2 - 3
// CHECK-NEXT: %5 = ref_element_addr %1 : $X, #X.s
// CHECK-NEXT: %6 = struct_element_addr %5 : $*Str, #Str.a
// CHECK-NEXT: may alias
// CHECK: End function test_addr_alias1
sil @test_addr_alias1 : $@convention(thin) () -> () {
bb0:
%0 = alloc_ref $XandIntClass
%1 = alloc_ref $X
%2 = ref_element_addr %0 : $XandIntClass, #XandIntClass.x
store %1 to %2 : $*X
%4 = ref_element_addr %0 : $XandIntClass, #XandIntClass.i
%5 = ref_element_addr %1 : $X, #X.s
%6 = struct_element_addr %5 : $*Str, #Str.a
fix_lifetime %2 : $*X
fix_lifetime %4 : $*Int
fix_lifetime %5 : $*Str
fix_lifetime %6 : $*Int
%11 = tuple ()
return %11 : $()
}
// CHECK-LABEL: Address escape information for test_addr_alias2:
// CHECK: pair 0 - 1
// CHECK-NEXT: %1 = ref_element_addr %0 : $X, #X.s
// CHECK-NEXT: %2 = struct_element_addr %1 : $*Str, #Str.a
// CHECK-NEXT: may alias
// CHECK: pair 0 - 2
// CHECK-NEXT: %1 = ref_element_addr %0 : $X, #X.s
// CHECK-NEXT: %3 = struct_element_addr %1 : $*Str, #Str.b
// CHECK-NEXT: may alias
// CHECK: pair 0 - 3
// CHECK-NEXT: %1 = ref_element_addr %0 : $X, #X.s
// CHECK-NEXT: %5 = struct_element_addr %4 : $*Str, #Str.a
// CHECK-NEXT: may alias
// CHECK: pair 1 - 2
// CHECK-NEXT: %2 = struct_element_addr %1 : $*Str, #Str.a
// CHECK-NEXT: %3 = struct_element_addr %1 : $*Str, #Str.b
// CHECK-NEXT: no alias
// CHECK: pair 1 - 3
// CHECK-NEXT: %2 = struct_element_addr %1 : $*Str, #Str.a
// CHECK-NEXT: %5 = struct_element_addr %4 : $*Str, #Str.a
// CHECK-NEXT: may alias
// CHECK: pair 2 - 3
// CHECK-NEXT: %3 = struct_element_addr %1 : $*Str, #Str.b
// CHECK-NEXT: %5 = struct_element_addr %4 : $*Str, #Str.a
// CHECK-NEXT: no alias
// CHECK: End function test_addr_alias2
sil @test_addr_alias2 : $@convention(thin) () -> () {
bb0:
%0 = alloc_ref $X
%1 = ref_element_addr %0 : $X, #X.s
%2 = struct_element_addr %1 : $*Str, #Str.a
%3 = struct_element_addr %1 : $*Str, #Str.b
%4 = ref_element_addr %0 : $X, #X.s
%5 = struct_element_addr %4 : $*Str, #Str.a
fix_lifetime %1 : $*Str
fix_lifetime %2 : $*Int
fix_lifetime %3 : $*Int
fix_lifetime %5 : $*Int
%11 = tuple ()
return %11 : $()
}
sil @call_closure : $@convention(method) (@noescape @callee_guaranteed () -> ()) -> ()
sil @closure : $@convention(thin) (@inout_aliasable Int64) -> ()
// CHECK-LABEL: Address escape information for test_closure_capturing_address:
// CHECK: value: %0 = alloc_stack $Int64
// CHECK-NEXT: ==> %7 = apply %6(%4) : $@convention(method) (@noescape @callee_guaranteed () -> ()) -> ()
// CHECK: End function test_closure_capturing_address
sil @test_closure_capturing_address : $@convention(thin) () -> Int64 {
bb0:
%0 = alloc_stack $Int64
%1 = integer_literal $Builtin.Int64, 0
%2 = struct $Int64 (%1 : $Builtin.Int64)
%3 = function_ref @closure : $@convention(thin) (@inout_aliasable Int64) -> ()
%4 = partial_apply [callee_guaranteed] [on_stack] %3(%0) : $@convention(thin) (@inout_aliasable Int64) -> ()
store %2 to %0 : $*Int64
%6 = function_ref @call_closure : $@convention(method) (@noescape @callee_guaranteed () -> ()) -> ()
%7 = apply %6(%4) : $@convention(method) (@noescape @callee_guaranteed () -> ()) -> ()
dealloc_stack %4 : $@noescape @callee_guaranteed () -> ()
fix_lifetime %0 : $*Int64
%9 = load %0 : $*Int64
dealloc_stack %0 : $*Int64
return %9 : $Int64
}
// CHECK-LABEL: Address escape information for test_index_addr:
// CHECK: pair 0 - 1
// CHECK-NEXT: %2 = ref_tail_addr %1 : $X, $Int
// CHECK-NEXT: %5 = index_addr %2 : $*Int, %0 : $Builtin.Word
// CHECK-NEXT: may alias
// CHECK: pair 0 - 2
// CHECK-NEXT: %2 = ref_tail_addr %1 : $X, $Int
// CHECK-NEXT: %6 = index_addr %2 : $*Int, %3 : $Builtin.Word
// CHECK-NEXT: may alias
// CHECK: pair 0 - 3
// CHECK-NEXT: %2 = ref_tail_addr %1 : $X, $Int
// CHECK-NEXT: %7 = index_addr %2 : $*Int, %4 : $Builtin.Word
// CHECK-NEXT: may alias
// CHECK: pair 0 - 4
// CHECK-NEXT: %2 = ref_tail_addr %1 : $X, $Int
// CHECK-NEXT: %8 = index_addr %7 : $*Int, %4 : $Builtin.Word
// CHECK-NEXT: may alias
// CHECK: pair 1 - 2
// CHECK-NEXT: %5 = index_addr %2 : $*Int, %0 : $Builtin.Word
// CHECK-NEXT: %6 = index_addr %2 : $*Int, %3 : $Builtin.Word
// CHECK-NEXT: may alias
// CHECK: pair 1 - 3
// CHECK-NEXT: %5 = index_addr %2 : $*Int, %0 : $Builtin.Word
// CHECK-NEXT: %7 = index_addr %2 : $*Int, %4 : $Builtin.Word
// CHECK-NEXT: may alias
// CHECK: pair 1 - 4
// CHECK-NEXT: %5 = index_addr %2 : $*Int, %0 : $Builtin.Word
// CHECK-NEXT: %8 = index_addr %7 : $*Int, %4 : $Builtin.Word
// CHECK-NEXT: may alias
// CHECK: pair 2 - 4
// CHECK-NEXT: %6 = index_addr %2 : $*Int, %3 : $Builtin.Word
// CHECK-NEXT: %8 = index_addr %7 : $*Int, %4 : $Builtin.Word
// CHECK-NEXT: may alias
// CHECK: End function test_index_addr
sil @test_index_addr : $@convention(thin) (Builtin.Word) -> () {
bb0(%0 : $Builtin.Word):
%1 = alloc_ref $X
%2 = ref_tail_addr %1 : $X, $Int
%3 = integer_literal $Builtin.Word, 2
%4 = integer_literal $Builtin.Word, 1
%5 = index_addr %2 : $*Int, %0 : $Builtin.Word
%6 = index_addr %2 : $*Int, %3 : $Builtin.Word
%7 = index_addr %2 : $*Int, %4 : $Builtin.Word
%8 = index_addr %7 : $*Int, %4 : $Builtin.Word
fix_lifetime %2 : $*Int
fix_lifetime %5 : $*Int
fix_lifetime %6 : $*Int
fix_lifetime %7 : $*Int
fix_lifetime %8 : $*Int
%r = tuple ()
return %r : $()
}
// CHECK-LABEL: Address escape information for test_existentials:
// CHECK: pair 0 - 1
// CHECK-NEXT: %2 = init_existential_addr %1 : $*any P, $Int
// CHECK-NEXT: %4 = open_existential_addr immutable_access %1 : $*any P to $*@opened("D2149896-0C4D-11EE-92B7-0EA13E3AABB3", any P) Self
// CHECK-NEXT: may alias
// CHECK: End function test_existentials
sil @test_existentials : $@convention(thin) (Int) -> () {
bb0(%0 : $Int):
%1 = alloc_stack $P
%2 = init_existential_addr %1 : $*P, $Int
store %0 to %2 : $*Int
%4 = open_existential_addr immutable_access %1 : $*any P to $*@opened("D2149896-0C4D-11EE-92B7-0EA13E3AABB3", any P) Self
fix_lifetime %2 : $*Int
fix_lifetime %4 : $*@opened("D2149896-0C4D-11EE-92B7-0EA13E3AABB3", any P) Self
dealloc_stack %1 : $*P
%r = tuple ()
return %r : $()
}
// CHECK-LABEL: Address escape information for test_stored_pointer:
// CHECK: value: %0 = alloc_stack $Int
// CHECK-NEXT: ==> %5 = apply %4(%2) : $@convention(thin) (@in Builtin.RawPointer) -> ()
// CHECK: End function test_stored_pointer
sil @test_stored_pointer : $@convention(thin) () -> () {
bb0:
%0 = alloc_stack $Int
%1 = address_to_pointer %0 : $*Int to $Builtin.RawPointer
%2 = alloc_stack $Builtin.RawPointer
store %1 to %2 : $*Builtin.RawPointer
%4 = function_ref @in_ptr : $@convention(thin) (@in Builtin.RawPointer) -> ()
%5 = apply %4(%2) : $@convention(thin) (@in Builtin.RawPointer) -> ()
dealloc_stack %2 : $*Builtin.RawPointer
fix_lifetime %0 : $*Int
dealloc_stack %0 : $*Int
%8 = tuple ()
return %8 : $()
}
// CHECK-LABEL: Address escape information for test_unchecked_ref_cast:
// CHECK: pair 0 - 1
// CHECK-NEXT: %4 = ref_element_addr %2 : $X, #X.s
// CHECK-NEXT: %6 = ref_element_addr %3 : $X, #X.s
// CHECK-NEXT: no alias
// CHECK: End function test_unchecked_ref_cast
sil @test_unchecked_ref_cast : $@convention(thin) () -> () {
bb0:
%0 = alloc_ref $D
%1 = alloc_ref $D
%2 = unchecked_ref_cast %0 : $D to $X
%3 = unchecked_ref_cast %1 : $D to $X
%4 = ref_element_addr %2 : $X, #X.s
fix_lifetime %4 : $*Str
%6 = ref_element_addr %3 : $X, #X.s
fix_lifetime %6 : $*Str
%r = tuple ()
return %r : $()
}
// CHECK-LABEL: Address escape information for test_anyobject_cast:
// CHECK: pair 0 - 1
// CHECK-NEXT: %3 = ref_element_addr %2 : $X, #X.s
// CHECK-NEXT: %5 = ref_element_addr %2 : $X, #X.s
// CHECK-NEXT: may alias
// CHECK: End function test_anyobject_cast
sil @test_anyobject_cast : $@convention(thin) () -> () {
bb0:
%0 = alloc_ref $X
%1 = init_existential_ref %0 : $X : $X, $AnyObject
%2 = unchecked_ref_cast %1 : $AnyObject to $X
%3 = ref_element_addr %2 : $X, #X.s
fix_lifetime %3 : $*Str
%5 = ref_element_addr %2 : $X, #X.s
fix_lifetime %5 : $*Str
%r = tuple ()
return %r : $()
}
|