File: mandatory_combiner.sil

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (929 lines) | stat: -rw-r--r-- 48,220 bytes parent folder | download
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
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
// RUN: %target-sil-opt -onone-simplification %s | %FileCheck %s

// REQUIRES: swift_in_compiler

sil_stage canonical

import Builtin

// Trivial declarations

struct MyInt {
  var value: Builtin.Int64
}

// Generic declarations

protocol Addable {
  static var an: Self { get }
}

// Class declarations

class Klass {
  init()
  deinit
}

// Existential declarations

protocol Proto {
  static var an: Proto { get }
}

// Trivial support

sil @first_of_three_ints : $@convention(thin) (MyInt, MyInt, MyInt) -> MyInt

sil @constant_zero : $@convention(thin) () -> MyInt 

sil @identity_int : $@convention(thin) (MyInt) -> MyInt 

// Generic support

sil @first_of_three_addables : $@convention(thin) <A where A : Addable> (@in_guaranteed A, @guaranteed <τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <A>, @guaranteed <τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <A>) -> @
out A

// Class support

sil [exact_self_class] @klass_alloc_init : $@convention(method) (@thick Klass.Type) -> @owned Klass

// Klass.init()
sil @klass_init : $@convention(method) (@owned Klass) -> @owned Klass
// Klass.deinit
sil @klass_deinit : $@convention(method) (@guaranteed Klass) -> @owned Builtin.NativeObject

// Klass.__deallocating_deinit
sil @klass_dealloc_deinit : $@convention(method) (@owned Klass) -> ()

sil_vtable Klass {
  #Klass.init!allocator: (Klass.Type) -> () -> Klass : @klass_alloc_init
  #Klass.deinit!deallocator: @klass_dealloc_deinit
}

sil @first_of_three_klasses : $@convention(thin) (@guaranteed Klass, @guaranteed Klass, @guaranteed Klass) -> @owned Klass

// Existential support

sil @first_of_three_protos : $@convention(thin) (@in_guaranteed Proto, @guaranteed { var Proto }, @guaranteed { var Proto }) -> @out Proto

sil @get_proto : $@convention(thin) () -> @out Proto

// Mixed support

sil @proto_from_proto_and_myint : $@convention(thin) (@in_guaranteed Proto, MyInt) -> @out Proto

sil @myint_from_myint_and_proto : $@convention(thin) (MyInt, @guaranteed { var Proto }) -> MyInt

sil @myint_from_proto_and_myint : $@convention(thin) (@guaranteed { var Proto }, MyInt) -> MyInt

// Optional support
enum FakeOptional<T> {
case none
case some(T)
}

///////////
// Tests //
///////////

////////////////////////
// Trivial, No Return //
////////////////////////

// All trivial arguments.  No partial apply arguments.  No apply arguments.
// CHECK-LABEL: sil hidden @trivial_nocapture_noargs : $@convention(thin) () -> MyInt {
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply {{%.*}}()
// CHECK: return [[RESULT]]
// CHECK: } // end sil function 'trivial_nocapture_noargs'
sil hidden @trivial_nocapture_noargs : $@convention(thin) () -> MyInt {
bb0:
  %0 = function_ref @constant_zero : $@convention(thin) () -> MyInt
  %1 = partial_apply [callee_guaranteed] %0() : $@convention(thin) () -> MyInt
  strong_retain %1 : $@callee_guaranteed () -> MyInt
  %2 = apply %1() : $@callee_guaranteed () -> MyInt
  strong_release %1 : $@callee_guaranteed () -> MyInt
  strong_release %1 : $@callee_guaranteed () -> MyInt
  return %2 : $MyInt
} // end sil function 'trivial_nocapture_noargs'

// All trivial arguments.  Partial apply arguments.  No apply arguments.
// CHECK-LABEL: sil hidden @trivial_capture_noargs : $@convention(thin) () -> MyInt {
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply {{%.*}}({{%.*}})
// CHECK: return [[RESULT]]
// CHECK: } // end sil function 'trivial_capture_noargs'
sil hidden @trivial_capture_noargs : $@convention(thin) () -> MyInt {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %2 = function_ref @identity_int : $@convention(thin) (MyInt) -> MyInt
  %3 = partial_apply [callee_guaranteed] %2(%1) : $@convention(thin) (MyInt) -> MyInt
  strong_retain %3 : $@callee_guaranteed () -> MyInt
  %4 = apply %3() : $@callee_guaranteed () -> MyInt
  strong_release %3 : $@callee_guaranteed () -> MyInt
  strong_release %3 : $@callee_guaranteed () -> MyInt
  return %4 : $MyInt
} // end sil function 'trivial_capture_noargs'

// All trivial arguments.  No partial apply arguments.  Apply arguments.
// CHECK-LABEL: sil hidden @trivial_nocapture_args : $@convention(thin) () -> MyInt {
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply {{%.*}}({{%.*}})
// CHECK: return [[RESULT]]
// CHECK: } // end sil function 'trivial_nocapture_args'
sil hidden @trivial_nocapture_args : $@convention(thin) () -> MyInt {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %2 = function_ref @identity_int : $@convention(thin) (MyInt) -> MyInt
  %3 = partial_apply [callee_guaranteed] %2() : $@convention(thin) (MyInt) -> MyInt
  strong_retain %3 : $@callee_guaranteed (MyInt) -> MyInt
  %4 = apply %3(%1) : $@callee_guaranteed (MyInt) -> MyInt
  strong_release %3 : $@callee_guaranteed (MyInt) -> MyInt
  strong_release %3 : $@callee_guaranteed (MyInt) -> MyInt
  return %4 : $MyInt
} // end sil function 'trivial_nocapture_args'

// All trivial arguments.  Partial apply arguments.  Apply arguments.
// CHECK-LABEL: sil hidden @trivial_capture_args : $@convention(thin) () -> MyInt {
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply {{%.*}}({{%.*}}, {{%.*}}, {{%.*}})
// CHECK: return  [[RESULT]]
// CHECK: } // end sil function 'trivial_capture_args'
sil hidden @trivial_capture_args : $@convention(thin) () -> MyInt {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %3 = integer_literal $Builtin.Int64, 10
  %4 = struct $MyInt (%3 : $Builtin.Int64)
  %6 = function_ref @first_of_three_ints : $@convention(thin) (MyInt, MyInt, MyInt) -> MyInt
  %7 = partial_apply [callee_guaranteed] %6(%1, %4) : $@convention(thin) (MyInt, MyInt, MyInt) -> MyInt
  strong_retain %7 : $@callee_guaranteed (MyInt) -> MyInt
  %10 = integer_literal $Builtin.Int64, 15
  %11 = struct $MyInt (%10 : $Builtin.Int64)
  %12 = apply %7(%11) : $@callee_guaranteed (MyInt) -> MyInt
  strong_release %7 : $@callee_guaranteed (MyInt) -> MyInt
  strong_release %7 : $@callee_guaranteed (MyInt) -> MyInt
  return %12 : $MyInt
} // end sil function 'trivial_capture_args'

/////////////////////
// Trivial, Return //
/////////////////////

// All trivial arguments.  No partial apply arguments.  No apply arguments.  Return partial apply.
// CHECK-LABEL: sil hidden @trivial_nocapture_noargs_ret : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed () -> MyInt) {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @constant_zero
// CHECK: [[PARTIAL_APPLY_RESULT:%.*]] = partial_apply [callee_guaranteed] [[FUNCTION_REF]]() :
// CHECK: [[APPLY_RESULT:%.]] = apply [[FUNCTION_REF]]()
// CHECK: [[TUPLE_RESULT:%.*]] = tuple ([[APPLY_RESULT]] : $MyInt, [[PARTIAL_APPLY_RESULT]] : $@callee_guaranteed () -> MyInt)
// CHECK: return [[TUPLE_RESULT]]
// CHECK: } // end sil function 'trivial_nocapture_noargs_ret'
sil hidden @trivial_nocapture_noargs_ret : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed () -> MyInt) {
bb0:
  %0 = function_ref @constant_zero : $@convention(thin) () -> MyInt
  %1 = partial_apply [callee_guaranteed] %0() : $@convention(thin) () -> MyInt
  strong_retain %1 : $@callee_guaranteed () -> MyInt
  %2 = apply %1() : $@callee_guaranteed () -> MyInt
  strong_release %1 : $@callee_guaranteed () -> MyInt
  strong_release %1 : $@callee_guaranteed () -> MyInt
  %3 = tuple (%2 : $MyInt, %1 : $@callee_guaranteed () -> MyInt)
  return %3 : $(MyInt, @callee_guaranteed () -> MyInt)
} // end sil function 'trivial_nocapture_noargs_ret'

// All trivial arguments.  Partial apply arguments.  No apply arguments.  Return partial apply.
// CHECK-LABEL: sil hidden @trivial_capture_noargs_ret : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed () -> MyInt) {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @identity_int
// CHECK: [[PARTIAL_APPLY_RESULT:%.*]] = partial_apply [callee_guaranteed] [[FUNCTION_REF]]([[FIRST_ARGUMENT:%.*]]) :
// CHECK: [[APPLY_RESULT:%.]] = apply [[FUNCTION_REF]]([[FIRST_ARGUMENT]])
// CHECK: [[TUPLE_RESULT:%.*]] = tuple ([[APPLY_RESULT]] : $MyInt, [[PARTIAL_APPLY_RESULT]] : $@callee_guaranteed () -> MyInt)
// CHECK: return [[TUPLE_RESULT]]
// CHECK: } // end sil function 'trivial_capture_noargs_ret'
sil hidden @trivial_capture_noargs_ret : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed () -> MyInt) {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %2 = function_ref @identity_int : $@convention(thin) (MyInt) -> MyInt
  %3 = partial_apply [callee_guaranteed] %2(%1) : $@convention(thin) (MyInt) -> MyInt
  strong_retain %3 : $@callee_guaranteed () -> MyInt
  %4 = apply %3() : $@callee_guaranteed () -> MyInt
  strong_release %3 : $@callee_guaranteed () -> MyInt
  strong_release %3 : $@callee_guaranteed () -> MyInt
  %5 = tuple (%4 : $MyInt, %3 : $@callee_guaranteed () -> MyInt)
  return %5 : $(MyInt, @callee_guaranteed () -> MyInt)
} // end sil function 'trivial_capture_noargs_ret'

// All trivial arguments.  No partial apply arguments.  Apply arguments.  Return partial apply.
// CHECK-LABEL: sil hidden @trivial_nocapture_args_ret : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed (MyInt) -> MyInt) {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @identity_int
// CHECK: [[PARTIAL_APPLY_RESULT:%.*]] = partial_apply [callee_guaranteed] [[FUNCTION_REF]]() :
// CHECK: [[APPLY_RESULT:%.]] = apply [[FUNCTION_REF]]({{%.*}})
// CHECK: [[TUPLE_RESULT:%.*]] = tuple ([[APPLY_RESULT]] : $MyInt, [[PARTIAL_APPLY_RESULT]] : $@callee_guaranteed (MyInt) -> MyInt)
// CHECK: return [[TUPLE_RESULT]]
// CHECK: } // end sil function 'trivial_nocapture_args_ret'
sil hidden @trivial_nocapture_args_ret : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed (MyInt) -> MyInt) {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %2 = function_ref @identity_int : $@convention(thin) (MyInt) -> MyInt
  %3 = partial_apply [callee_guaranteed] %2() : $@convention(thin) (MyInt) -> MyInt
  strong_retain %3 : $@callee_guaranteed (MyInt) -> MyInt
  %4 = apply %3(%1) : $@callee_guaranteed (MyInt) -> MyInt
  strong_release %3 : $@callee_guaranteed (MyInt) -> MyInt
  strong_release %3 : $@callee_guaranteed (MyInt) -> MyInt
  %5 = tuple (%4 : $MyInt, %3 : $@callee_guaranteed (MyInt) -> MyInt)
  return %5 : $(MyInt, @callee_guaranteed (MyInt) -> MyInt)
} // end sil function 'trivial_nocapture_args_ret'

// All trivial arguments.  Partial apply arguments.  Apply arguments.  Return partial apply.
// CHECK-LABEL: sil hidden @trivial_capture_args_ret : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed (MyInt) -> MyInt) {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @first_of_three_ints
// CHECK: [[PARTIAL_APPLY_RESULT:%.*]] = partial_apply [callee_guaranteed] [[FUNCTION_REF]]([[FIRST_ARGUMENT:%.*]], [[SECOND_ARGUMENT:%.*]]) :
// CHECK: [[APPLY_RESULT:%.]] = apply [[FUNCTION_REF]]({{%.*}}, [[FIRST_ARGUMENT]], [[SECOND_ARGUMENT]])
// CHECK: [[TUPLE_RESULT:%.*]] = tuple ([[APPLY_RESULT]] : $MyInt, [[PARTIAL_APPLY_RESULT]] : $@callee_guaranteed (MyInt) -> MyInt)
// CHECK: return [[TUPLE_RESULT]]
// CHECK: } // end sil function 'trivial_capture_args_ret'
sil hidden @trivial_capture_args_ret : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed (MyInt) -> MyInt) {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %3 = integer_literal $Builtin.Int64, 10
  %4 = struct $MyInt (%3 : $Builtin.Int64)
  %6 = function_ref @first_of_three_ints : $@convention(thin) (MyInt, MyInt, MyInt) -> MyInt
  %7 = partial_apply [callee_guaranteed] %6(%1, %4) : $@convention(thin) (MyInt, MyInt, MyInt) -> MyInt
  strong_retain %7 : $@callee_guaranteed (MyInt) -> MyInt
  %10 = integer_literal $Builtin.Int64, 15
  %11 = struct $MyInt (%10 : $Builtin.Int64)
  %12 = apply %7(%11) : $@callee_guaranteed (MyInt) -> MyInt
  strong_release %7 : $@callee_guaranteed (MyInt) -> MyInt
  %14 = tuple (%12 : $MyInt, %7 : $@callee_guaranteed (MyInt) -> MyInt)
  return %14 : $(MyInt, @callee_guaranteed (MyInt) -> MyInt)
} // end sil function 'trivial_capture_args_ret'

/////////////
// Generic //
/////////////

// All generic arguments.  Partial apply arguments.  Apply arguments.
// CHECK-LABEL: sil hidden @generic_capture_args : $@convention(thin) <A where A : Addable> () -> @out A {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @first_of_three_addables
// CHECK:  = partial_apply [callee_guaranteed] [[FUNCTION_REF]]<A>
// Use %0 explicitly because that is the out parameter.
// CHECK: apply [[FUNCTION_REF]]<A>(%0, {{%.*}})
// CHECK: [[RESULT:%.*]] = tuple ()
// CHECK: return [[RESULT]] : $()
// CHECK: } // end sil function 'generic_capture_args'
sil hidden @generic_capture_args : $@convention(thin) <A where A : Addable> () -> @out A {
bb0(%0 : $*A):
  %1 = alloc_stack $A, let, name "x"
  %2 = metatype $@thick A.Type
  %3 = witness_method $A, #Addable.an!getter : <Self where Self : Addable> (Self.Type) -> () -> Self : $@convention(witness_method: Addable) <τ_0_0 where τ_0_0 : Addable> (@thick τ_0_0.Type) -> @out τ_0_0
  %4 = apply %3<A>(%1, %2) : $@convention(witness_method: Addable) <τ_0_0 where τ_0_0 : Addable> (@thick τ_0_0.Type) -> @out τ_0_0
  %5 = alloc_stack $A, let, name "y"
  %6 = metatype $@thick A.Type
  %7 = witness_method $A, #Addable.an!getter : <Self where Self : Addable> (Self.Type) -> () -> Self : $@convention(witness_method: Addable) <τ_0_0 where τ_0_0 : Addable> (@thick τ_0_0.Type) -> @out τ_0_0
  %8 = apply %7<A>(%5, %6) : $@convention(witness_method: Addable) <τ_0_0 where τ_0_0 : Addable> (@thick τ_0_0.Type) -> @out τ_0_0
  %9 = function_ref @first_of_three_addables : $@convention(thin) <τ_0_0 where τ_0_0 : Addable> (@in_guaranteed τ_0_0, @guaranteed <τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <τ_0_0>, @guaranteed <τ_0_0 where τ_0_0 : Addable>
 { var τ_0_0 } <τ_0_0>) -> @out τ_0_0
  %10 = alloc_box $<τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <A>
  %11 = project_box %10 : $<τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <A>, 0
  copy_addr %5 to [init] %11 : $*A
  %13 = alloc_box $<τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <A>
  %14 = project_box %13 : $<τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <A>, 0
  copy_addr %1 to [init] %14 : $*A
  %16 = partial_apply [callee_guaranteed] %9<A>(%10, %13) : $@convention(thin) <τ_0_0 where τ_0_0 : Addable> (@in_guaranteed τ_0_0, @guaranteed <τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <τ_0_0>, @guaranteed <τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <τ_0_0>) -> @out τ_0_0
  strong_retain %16 : $@callee_guaranteed (@in_guaranteed A) -> @out A
  %19 = metatype $@thick A.Type
  %20 = alloc_stack $A
  %21 = witness_method $A, #Addable.an!getter : <Self where Self : Addable> (Self.Type) -> () -> Self : $@convention(witness_method: Addable) <τ_0_0 where τ_0_0 : Addable> (@thick τ_0_0.Type) -> @out τ_0_0
  %22 = apply %21<A>(%20, %19) : $@convention(witness_method: Addable) <τ_0_0 where τ_0_0 : Addable> (@thick τ_0_0.Type) -> @out τ_0_0
  %23 = apply %16(%0, %20) : $@callee_guaranteed (@in_guaranteed A) -> @out A
  destroy_addr %20 : $*A
  dealloc_stack %20 : $*A
  debug_value %16 : $@callee_guaranteed (@in_guaranteed A) -> @out A, let, name "x"
  strong_release %16 : $@callee_guaranteed (@in_guaranteed A) -> @out A
  strong_release %16 : $@callee_guaranteed (@in_guaranteed A) -> @out A
  destroy_addr %5 : $*A
  dealloc_stack %5 : $*A
  destroy_addr %1 : $*A
  dealloc_stack %1 : $*A
  %32 = tuple ()
  return %32 : $()
} // end sil function 'generic_capture_args'


///////////
// Class //
///////////

// All class arguments.  Partial apply arguments.  Apply arguments.
// CHECK-LABEL: sil hidden @class_capture_args : $@convention(thin) () -> @owned Klass {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @first_of_three_klasses
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply [[FUNCTION_REF]]({{%.*}})
// CHECK: return [[RESULT]]
// CHECK: } // end sil function 'class_capture_args'
sil hidden @class_capture_args : $@convention(thin) () -> @owned Klass {
bb0:
  %0 = metatype $@thick Klass.Type
  %1 = function_ref @klass_alloc_init : $@convention(method) (@thick Klass.Type) -> @owned Klass
  %2 = apply %1(%0) : $@convention(method) (@thick Klass.Type) -> @owned Klass
  %6 = apply %1(%0) : $@convention(method) (@thick Klass.Type) -> @owned Klass
  %8 = function_ref @first_of_three_klasses : $@convention(thin) (@guaranteed Klass, @guaranteed Klass, @guaranteed Klass) -> @owned Klass
  strong_retain %2 : $Klass
  strong_retain %6 : $Klass
  %11 = partial_apply [callee_guaranteed] %8(%2, %6) : $@convention(thin) (@guaranteed Klass, @guaranteed Klass, @guaranteed Klass) -> @owned Klass
  strong_retain %11 : $@callee_guaranteed (@guaranteed Klass) -> @owned Klass
  %16 = apply %1(%0) : $@convention(method) (@thick Klass.Type) -> @owned Klass
  %17 = apply %11(%16) : $@callee_guaranteed (@guaranteed Klass) -> @owned Klass
  strong_release %16 : $Klass
  strong_release %11 : $@callee_guaranteed (@guaranteed Klass) -> @owned Klass
  strong_release %11 : $@callee_guaranteed (@guaranteed Klass) -> @owned Klass
  strong_release %6 : $Klass
  strong_release %2 : $Klass
  return %17 : $Klass
} // end sil function 'class_capture_args'

/////////////////
// Existential //
/////////////////

// All existential arguments.  Partial apply arguments.  Apply arguments.
// CHECK-LABEL: sil hidden @existential_capture_args : $@convention(thin) () -> @out any Proto {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @first_of_three_protos
// CHECK-NOT:  partial_apply
// Use %0 explicitly because that is the out parameter.
// CHECK: apply [[FUNCTION_REF]](%0, {{%.*}})
// CHECK: [[RESULT:%.*]] = tuple ()
// CHECK: return [[RESULT]] : $()
// CHECK: } // end sil function 'existential_capture_args'
sil hidden @existential_capture_args : $@convention(thin) () -> @out Proto {
bb0(%0 : $*Proto):
  %1 = alloc_stack $Proto, let, name "x"
  %2 = function_ref @get_proto : $@convention(thin) () -> @out Proto
  %3 = apply %2(%1) : $@convention(thin) () -> @out Proto
  %4 = alloc_stack $Proto, let, name "y"
  %6 = apply %2(%4) : $@convention(thin) () -> @out Proto
  %7 = function_ref @first_of_three_protos : $@convention(thin) (@in_guaranteed Proto, @guaranteed { var Proto }, @guaranteed { var Proto }) -> @out Proto
  %8 = alloc_box ${ var Proto }
  %9 = project_box %8 : ${ var Proto }, 0
  copy_addr %1 to [init] %9 : $*Proto
  %11 = alloc_box ${ var Proto }
  %12 = project_box %11 : ${ var Proto }, 0
  copy_addr %4 to [init] %12 : $*Proto
  %14 = partial_apply [callee_guaranteed] %7(%8, %11) : $@convention(thin) (@in_guaranteed Proto, @guaranteed { var Proto }, @guaranteed { var Proto }) -> @out Proto
  strong_retain %14 : $@callee_guaranteed (@in_guaranteed Proto) -> @out Proto
  %17 = alloc_stack $Proto
  %19 = apply %2(%17) : $@convention(thin) () -> @out Proto
  %20 = apply %14(%0, %17) : $@callee_guaranteed (@in_guaranteed Proto) -> @out Proto
  destroy_addr %17 : $*Proto
  dealloc_stack %17 : $*Proto
  strong_release %14 : $@callee_guaranteed (@in_guaranteed Proto) -> @out Proto
  strong_release %14 : $@callee_guaranteed (@in_guaranteed Proto) -> @out Proto
  destroy_addr %4 : $*Proto
  dealloc_stack %4 : $*Proto
  destroy_addr %1 : $*Proto
  dealloc_stack %1 : $*Proto
  %29 = tuple ()
  return %29 : $()
} // end sil function 'existential_capture_args'

///////////
// Mixed //
///////////

// Mixed arguments.  Trivial partial apply argument.  Existential argument.
// CHECK-LABEL: sil hidden @mixed_trivialcapture_existentialarg : $@convention(thin) () -> @out any Proto {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @proto_from_proto_and_myint
// CHECK-NOT: partial_apply
// Use %0 explicitly because that is the out parameter.
// CHECK: apply [[FUNCTION_REF]](%0, {{%.*}})
// CHECK: [[RESULT:%.*]] = tuple ()
// CHECK: return [[RESULT]] : $()
// CHECK: } // end sil function 'mixed_trivialcapture_existentialarg'
sil hidden @mixed_trivialcapture_existentialarg : $@convention(thin) () -> @out Proto {
bb0(%0 : $*Proto):
  %1 = integer_literal $Builtin.Int64, 5
  %2 = struct $MyInt (%1 : $Builtin.Int64)
  %4 = function_ref @proto_from_proto_and_myint : $@convention(thin) (@in_guaranteed Proto, MyInt) -> @out Proto
  %5 = partial_apply [callee_guaranteed] %4(%2) : $@convention(thin) (@in_guaranteed Proto, MyInt) -> @out Proto
  strong_retain %5 : $@callee_guaranteed (@in_guaranteed Proto) -> @out Proto
  %8 = alloc_stack $Proto
  %9 = function_ref @get_proto : $@convention(thin) () -> @out Proto
  %10 = apply %9(%8) : $@convention(thin) () -> @out Proto
  %11 = apply %5(%0, %8) : $@callee_guaranteed (@in_guaranteed Proto) -> @out Proto
  destroy_addr %8 : $*Proto
  dealloc_stack %8 : $*Proto
  strong_release %5 : $@callee_guaranteed (@in_guaranteed Proto) -> @out Proto
  strong_release %5 : $@callee_guaranteed (@in_guaranteed Proto) -> @out Proto
  %16 = tuple ()
  return %16 : $()
} // end sil function 'mixed_trivialcapture_existentialarg'

// Mixed arguments.  Existential partial apply argument.  Trivial argument.
// CHECK-LABEL: sil hidden @mixed_existentialcapture_trivialarg : $@convention(thin) () -> MyInt {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @myint_from_myint_and_proto
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply [[FUNCTION_REF]]({{%.*}})
// CHECK: return [[RESULT]]
// CHECK: } // end sil function 'mixed_existentialcapture_trivialarg'
sil hidden @mixed_existentialcapture_trivialarg : $@convention(thin) () -> MyInt {
bb0:
  %0 = alloc_stack $Proto, let, name "x"
  %1 = function_ref @get_proto : $@convention(thin) () -> @out Proto
  %2 = apply %1(%0) : $@convention(thin) () -> @out Proto
  %3 = function_ref @myint_from_myint_and_proto : $@convention(thin) (MyInt, @guaranteed { var Proto }) -> MyInt
  %4 = alloc_box ${ var Proto }
  %5 = project_box %4 : ${ var Proto }, 0
  copy_addr %0 to [init] %5 : $*Proto
  %7 = partial_apply [callee_guaranteed] %3(%4) : $@convention(thin) (MyInt, @guaranteed { var Proto }) -> MyInt
  strong_retain %7 : $@callee_guaranteed (MyInt) -> MyInt
  %10 = integer_literal $Builtin.Int64, 5
  %11 = struct $MyInt (%10 : $Builtin.Int64)
  %12 = apply %7(%11) : $@callee_guaranteed (MyInt) -> MyInt
  strong_release %7 : $@callee_guaranteed (MyInt) -> MyInt
  strong_release %7 : $@callee_guaranteed (MyInt) -> MyInt
  destroy_addr %0 : $*Proto
  dealloc_stack %0 : $*Proto
  return %12 : $MyInt
} // end sil function 'mixed_existentialcapture_trivialarg'

// Mixed arguments.  Mixed partial apply arguments.  No arguments.
// CHECK-LABEL: sil hidden @mixed_mixedcapture_noargs : $@convention(thin) () -> MyInt {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @myint_from_proto_and_myint
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply [[FUNCTION_REF]]({{.*}})
// CHECK: return [[RESULT]]
// CHECK: } // end sil function 'mixed_mixedcapture_noargs'
sil hidden @mixed_mixedcapture_noargs : $@convention(thin) () -> MyInt {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %3 = alloc_stack $Proto, let, name "y"
  %4 = function_ref @get_proto : $@convention(thin) () -> @out Proto
  %5 = apply %4(%3) : $@convention(thin) () -> @out Proto
  %6 = function_ref @myint_from_proto_and_myint : $@convention(thin) (@guaranteed { var Proto }, MyInt) -> MyInt
  %7 = alloc_box ${ var Proto }
  %8 = project_box %7 : ${ var Proto }, 0
  copy_addr %3 to [init] %8 : $*Proto
  %10 = partial_apply [callee_guaranteed] %6(%7, %1) : $@convention(thin) (@guaranteed { var Proto }, MyInt) -> MyInt
  strong_retain %10 : $@callee_guaranteed () -> MyInt
  %13 = apply %10() : $@callee_guaranteed () -> MyInt
  strong_release %10 : $@callee_guaranteed () -> MyInt
  strong_release %10 : $@callee_guaranteed () -> MyInt
  destroy_addr %3 : $*Proto
  dealloc_stack %3 : $*Proto
  return %13 : $MyInt
} // end sil function 'mixed_mixedcapture_noargs'

// Mixed arguments.  No partial apply arguments.  Mixed arguments.
// CHECK-LABEL: sil hidden @mixed_nocapture_mixedargs : $@convention(thin) () -> MyInt {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @myint_from_proto_and_myint
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply [[FUNCTION_REF]]({{%.*}}, {{%.*}})
// CHECK: return [[RESULT]]
// CHECK: } // end sil function 'mixed_nocapture_mixedargs'
sil hidden @mixed_nocapture_mixedargs : $@convention(thin) () -> MyInt {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %3 = alloc_stack $Proto, let, name "y"
  %4 = function_ref @get_proto : $@convention(thin) () -> @out Proto
  %5 = apply %4(%3) : $@convention(thin) () -> @out Proto
  %6 = function_ref @myint_from_proto_and_myint : $@convention(thin) (@guaranteed { var Proto }, MyInt) -> MyInt
  %7 = alloc_box ${ var Proto }
  %8 = project_box %7 : ${ var Proto }, 0
  copy_addr %3 to [init] %8 : $*Proto
  %10 = partial_apply [callee_guaranteed] %6() : $@convention(thin) (@guaranteed { var Proto }, MyInt) -> MyInt
  strong_retain %10 : $@callee_guaranteed (@guaranteed { var Proto }, MyInt) -> MyInt
  %13 = apply %10(%7, %1) : $@callee_guaranteed (@guaranteed { var Proto }, MyInt) -> MyInt
  strong_release %10 : $@callee_guaranteed (@guaranteed { var Proto }, MyInt) -> MyInt
  strong_release %10 : $@callee_guaranteed (@guaranteed { var Proto }, MyInt) -> MyInt
  destroy_addr %3 : $*Proto
  dealloc_stack %3 : $*Proto
  return %13 : $MyInt
} // end sil function 'mixed_nocapture_mixedargs'

//////////////
//////////////
//// OSSA ////
//////////////
//////////////

////////////////////////
// Trivial, No Return //
////////////////////////

// All trivial arguments.  No partial apply arguments.  No apply arguments.  OSSA.
// CHECK-LABEL: sil [ossa] @trivial_nocapture_noargs_ossa : $@convention(thin) () -> MyInt {
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply {{%.*}}()
// CHECK: return [[RESULT]]
// CHECK: } // end sil function 'trivial_nocapture_noargs_ossa'
sil [ossa] @trivial_nocapture_noargs_ossa : $@convention(thin) () -> MyInt {
bb0:
  %0 = function_ref @constant_zero : $@convention(thin) () -> MyInt
  %1 = partial_apply [callee_guaranteed] %0() : $@convention(thin) () -> MyInt
  %2 = apply %1() : $@callee_guaranteed () -> MyInt
  destroy_value %1 : $@callee_guaranteed () -> MyInt
  return %2 : $MyInt
} // end sil function 'trivial_nocapture_noargs_ossa'

// All trivial arguments.  Partial apply arguments.  No apply arguments.  OSSA.
// CHECK-LABEL: sil [ossa] @trivial_capture_noargs_ossa : $@convention(thin) () -> MyInt {
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply {{%.*}}({{%.*}})
// CHECK: return [[RESULT]]
// CHECK: } // end sil function 'trivial_capture_noargs_ossa'
sil [ossa] @trivial_capture_noargs_ossa : $@convention(thin) () -> MyInt {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %2 = function_ref @identity_int : $@convention(thin) (MyInt) -> MyInt
  %3 = partial_apply [callee_guaranteed] %2(%1) : $@convention(thin) (MyInt) -> MyInt
  %4 = apply %3() : $@callee_guaranteed () -> MyInt
  destroy_value %3 : $@callee_guaranteed () -> MyInt
  return %4 : $MyInt
} // end sil function 'trivial_capture_noargs_ossa'

// All trivial arguments.  No partial apply arguments.  Apply arguments.  OSSA.
// CHECK-LABEL: sil [ossa] @trivial_nocapture_args_ossa : $@convention(thin) () -> MyInt {
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply {{%.*}}({{%.*}})
// CHECK: return [[RESULT]]
// CHECK: } // end sil function 'trivial_nocapture_args_ossa'
sil [ossa] @trivial_nocapture_args_ossa : $@convention(thin) () -> MyInt {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %2 = function_ref @identity_int : $@convention(thin) (MyInt) -> MyInt
  %3 = partial_apply [callee_guaranteed] %2() : $@convention(thin) (MyInt) -> MyInt
  %4 = apply %3(%1) : $@callee_guaranteed (MyInt) -> MyInt
  destroy_value %3 : $@callee_guaranteed (MyInt) -> MyInt
  return %4 : $MyInt
} // end sil function 'trivial_nocapture_args_ossa'

// All trivial arguments.  Partial apply arguments.  Apply arguments.  OSSA.
// CHECK-LABEL: sil [ossa] @trivial_capture_args_ossa : $@convention(thin) () -> MyInt {
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply {{%.*}}({{%.*}}, {{%.*}}, {{%.*}})
// CHECK: return  [[RESULT]]
// CHECK: } // end sil function 'trivial_capture_args_ossa'
sil [ossa] @trivial_capture_args_ossa : $@convention(thin) () -> MyInt {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %3 = integer_literal $Builtin.Int64, 10
  %4 = struct $MyInt (%3 : $Builtin.Int64)
  %6 = function_ref @first_of_three_ints : $@convention(thin) (MyInt, MyInt, MyInt) -> MyInt
  %7 = partial_apply [callee_guaranteed] %6(%1, %4) : $@convention(thin) (MyInt, MyInt, MyInt) -> MyInt
  %10 = integer_literal $Builtin.Int64, 15
  %11 = struct $MyInt (%10 : $Builtin.Int64)
  %12 = apply %7(%11) : $@callee_guaranteed (MyInt) -> MyInt
  destroy_value %7 : $@callee_guaranteed (MyInt) -> MyInt
  return %12 : $MyInt
} // end sil function 'trivial_capture_args_ossa'

/////////////////////
// Trivial, Return //
/////////////////////

// All trivial arguments.  No partial apply arguments.  No apply arguments.  Return partial apply.  OSSA.
// CHECK-LABEL: sil [ossa] @trivial_nocapture_noargs_ret_ossa : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed () -> MyInt) {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @constant_zero
// CHECK: [[PARTIAL_APPLY_RESULT:%.*]] = partial_apply [callee_guaranteed] [[FUNCTION_REF]]() :
// CHECK: [[APPLY_RESULT:%.]] = apply [[FUNCTION_REF]]()
// CHECK: [[TUPLE_RESULT:%.*]] = tuple ([[APPLY_RESULT]] : $MyInt, [[PARTIAL_APPLY_RESULT]] : $@callee_guaranteed () -> MyInt)
// CHECK: return [[TUPLE_RESULT]]
// CHECK: } // end sil function 'trivial_nocapture_noargs_ret_ossa'
sil [ossa] @trivial_nocapture_noargs_ret_ossa : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed () -> MyInt) {
bb0:
  %0 = function_ref @constant_zero : $@convention(thin) () -> MyInt
  %1 = partial_apply [callee_guaranteed] %0() : $@convention(thin) () -> MyInt
  %2 = apply %1() : $@callee_guaranteed () -> MyInt
  %3 = tuple (%2 : $MyInt, %1 : $@callee_guaranteed () -> MyInt)
  return %3 : $(MyInt, @callee_guaranteed () -> MyInt)
} // end sil function 'trivial_nocapture_noargs_ret_ossa'

// All trivial arguments.  Partial apply arguments.  No apply arguments.  Return partial apply.  OSSA.
// CHECK-LABEL: sil [ossa] @trivial_capture_noargs_ret_ossa : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed () -> MyInt) {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @identity_int
// CHECK: [[PARTIAL_APPLY_RESULT:%.*]] = partial_apply [callee_guaranteed] [[FUNCTION_REF]]([[FIRST_ARGUMENT:%.*]]) :
// CHECK: [[APPLY_RESULT:%.]] = apply [[FUNCTION_REF]]([[FIRST_ARGUMENT]])
// CHECK: [[TUPLE_RESULT:%.*]] = tuple ([[APPLY_RESULT]] : $MyInt, [[PARTIAL_APPLY_RESULT]] : $@callee_guaranteed () -> MyInt)
// CHECK: return [[TUPLE_RESULT]]
// CHECK: } // end sil function 'trivial_capture_noargs_ret_ossa'
sil [ossa] @trivial_capture_noargs_ret_ossa : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed () -> MyInt) {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %2 = function_ref @identity_int : $@convention(thin) (MyInt) -> MyInt
  %3 = partial_apply [callee_guaranteed] %2(%1) : $@convention(thin) (MyInt) -> MyInt
  %4 = apply %3() : $@callee_guaranteed () -> MyInt
  %5 = tuple (%4 : $MyInt, %3 : $@callee_guaranteed () -> MyInt)
  return %5 : $(MyInt, @callee_guaranteed () -> MyInt)
} // end sil function 'trivial_capture_noargs_ret_ossa'

// All trivial arguments.  No partial apply arguments.  Apply arguments.  Return partial apply.  OSSA.
// CHECK-LABEL: sil [ossa] @trivial_nocapture_args_ret_ossa : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed (MyInt) -> MyInt) {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @identity_int
// CHECK: [[PARTIAL_APPLY_RESULT:%.*]] = partial_apply [callee_guaranteed] [[FUNCTION_REF]]() :
// CHECK: [[APPLY_RESULT:%.]] = apply [[FUNCTION_REF]]({{%.*}})
// CHECK: [[TUPLE_RESULT:%.*]] = tuple ([[APPLY_RESULT]] : $MyInt, [[PARTIAL_APPLY_RESULT]] : $@callee_guaranteed (MyInt) -> MyInt)
// CHECK: return [[TUPLE_RESULT]]
// CHECK: } // end sil function 'trivial_nocapture_args_ret_ossa'
sil [ossa] @trivial_nocapture_args_ret_ossa : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed (MyInt) -> MyInt) {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %2 = function_ref @identity_int : $@convention(thin) (MyInt) -> MyInt
  %3 = partial_apply [callee_guaranteed] %2() : $@convention(thin) (MyInt) -> MyInt
  %4 = apply %3(%1) : $@callee_guaranteed (MyInt) -> MyInt
  %5 = tuple (%4 : $MyInt, %3 : $@callee_guaranteed (MyInt) -> MyInt)
  return %5 : $(MyInt, @callee_guaranteed (MyInt) -> MyInt)
} // end sil function 'trivial_nocapture_args_ret_ossa'

// All trivial arguments.  Partial apply arguments.  Apply arguments.  Return partial apply.  OSSA.
// CHECK-LABEL: sil [ossa] @trivial_capture_args_ret_ossa : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed (MyInt) -> MyInt) {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @first_of_three_ints
// CHECK: [[PARTIAL_APPLY_RESULT:%.*]] = partial_apply [callee_guaranteed] [[FUNCTION_REF]]([[FIRST_ARGUMENT:%.*]], [[SECOND_ARGUMENT:%.*]]) :
// CHECK: [[APPLY_RESULT:%.]] = apply [[FUNCTION_REF]]({{%.*}}, [[FIRST_ARGUMENT]], [[SECOND_ARGUMENT]])
// CHECK: [[TUPLE_RESULT:%.*]] = tuple ([[APPLY_RESULT]] : $MyInt, [[PARTIAL_APPLY_RESULT]] : $@callee_guaranteed (MyInt) -> MyInt)
// CHECK: return [[TUPLE_RESULT]]
// CHECK: } // end sil function 'trivial_capture_args_ret_ossa'
sil [ossa] @trivial_capture_args_ret_ossa : $@convention(thin) () -> (MyInt, @owned @callee_guaranteed (MyInt) -> MyInt) {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %3 = integer_literal $Builtin.Int64, 10
  %4 = struct $MyInt (%3 : $Builtin.Int64)
  %6 = function_ref @first_of_three_ints : $@convention(thin) (MyInt, MyInt, MyInt) -> MyInt
  %7 = partial_apply [callee_guaranteed] %6(%1, %4) : $@convention(thin) (MyInt, MyInt, MyInt) -> MyInt
  %10 = integer_literal $Builtin.Int64, 15
  %11 = struct $MyInt (%10 : $Builtin.Int64)
  %12 = apply %7(%11) : $@callee_guaranteed (MyInt) -> MyInt
  %14 = tuple (%12 : $MyInt, %7 : $@callee_guaranteed (MyInt) -> MyInt)
  return %14 : $(MyInt, @callee_guaranteed (MyInt) -> MyInt)
} // end sil function 'trivial_capture_args_ret_ossa'

/////////////
// Generic //
/////////////

// All generic arguments.  Partial apply arguments.  Apply arguments.  OSSA.
// CHECK-LABEL: sil [ossa] @generic_capture_args_ossa : $@convention(thin) <A where A : Addable> () -> @out A {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @first_of_three_addables
// CHECK-NOT: partial_apply
// Use %0 explicitly because that is the out parameter.
// CHECK: apply [[FUNCTION_REF]]<A>(%0, {{%.*}})
// CHECK: [[RESULT:%.*]] = tuple ()
// CHECK: return [[RESULT]] : $()
// CHECK: } // end sil function 'generic_capture_args_ossa'
sil [ossa] @generic_capture_args_ossa : $@convention(thin) <A where A : Addable> () -> @out A {
bb0(%0 : $*A):
  %1 = alloc_stack $A, let, name "x"
  %2 = metatype $@thick A.Type
  %3 = witness_method $A, #Addable.an!getter : <Self where Self : Addable> (Self.Type) -> () -> Self : $@convention(witness_method: Addable) <τ_0_0 where τ_0_0 : Addable> (@thick τ_0_0.Type) -> @out τ_0_0
  %4 = apply %3<A>(%1, %2) : $@convention(witness_method: Addable) <τ_0_0 where τ_0_0 : Addable> (@thick τ_0_0.Type) -> @out τ_0_0
  %5 = alloc_stack $A, let, name "y"
  %6 = metatype $@thick A.Type
  %7 = witness_method $A, #Addable.an!getter : <Self where Self : Addable> (Self.Type) -> () -> Self : $@convention(witness_method: Addable) <τ_0_0 where τ_0_0 : Addable> (@thick τ_0_0.Type) -> @out τ_0_0
  %8 = apply %7<A>(%5, %6) : $@convention(witness_method: Addable) <τ_0_0 where τ_0_0 : Addable> (@thick τ_0_0.Type) -> @out τ_0_0
  %9 = function_ref @first_of_three_addables : $@convention(thin) <τ_0_0 where τ_0_0 : Addable> (@in_guaranteed τ_0_0, @guaranteed <τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <τ_0_0>, @guaranteed <τ_0_0 where τ_0_0 : Addable>
 { var τ_0_0 } <τ_0_0>) -> @out τ_0_0
  %10 = alloc_box $<τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <A>
  %11 = project_box %10 : $<τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <A>, 0
  copy_addr %5 to [init] %11 : $*A
  %13 = alloc_box $<τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <A>
  %14 = project_box %13 : $<τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <A>, 0
  copy_addr %1 to [init] %14 : $*A
  %16 = partial_apply [callee_guaranteed] %9<A>(%10, %13) : $@convention(thin) <τ_0_0 where τ_0_0 : Addable> (@in_guaranteed τ_0_0, @guaranteed <τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <τ_0_0>, @guaranteed <τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <τ_0_0>) -> @out τ_0_0
  %19 = metatype $@thick A.Type
  %20 = alloc_stack $A
  %21 = witness_method $A, #Addable.an!getter : <Self where Self : Addable> (Self.Type) -> () -> Self : $@convention(witness_method: Addable) <τ_0_0 where τ_0_0 : Addable> (@thick τ_0_0.Type) -> @out τ_0_0
  %22 = apply %21<A>(%20, %19) : $@convention(witness_method: Addable) <τ_0_0 where τ_0_0 : Addable> (@thick τ_0_0.Type) -> @out τ_0_0
  %23 = apply %16(%0, %20) : $@callee_guaranteed (@in_guaranteed A) -> @out A
  destroy_addr %20 : $*A
  dealloc_stack %20 : $*A
  destroy_value %16 : $@callee_guaranteed (@in_guaranteed A) -> @out A
  destroy_addr %5 : $*A
  dealloc_stack %5 : $*A
  destroy_addr %1 : $*A
  dealloc_stack %1 : $*A
  %32 = tuple ()
  return %32 : $()
} // end sil function 'generic_capture_args_ossa'

///////////
// Class //
///////////

// All class arguments.  Partial apply arguments.  Apply arguments.  OSSA.
// CHECK-LABEL: sil [ossa] @class_capture_args_ossa : $@convention(thin) () -> @owned Klass {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @first_of_three_klasses
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply [[FUNCTION_REF]]({{%.*}})
// CHECK: return [[RESULT]]
// CHECK: } // end sil function 'class_capture_args_ossa'
sil [ossa] @class_capture_args_ossa : $@convention(thin) () -> @owned Klass {
bb0:
  %0 = metatype $@thick Klass.Type
  %1 = function_ref @klass_alloc_init : $@convention(method) (@thick Klass.Type) -> @owned Klass
  %2 = apply %1(%0) : $@convention(method) (@thick Klass.Type) -> @owned Klass
  %6 = apply %1(%0) : $@convention(method) (@thick Klass.Type) -> @owned Klass
  %8 = function_ref @first_of_three_klasses : $@convention(thin) (@guaranteed Klass, @guaranteed Klass, @guaranteed Klass) -> @owned Klass
  %2a = copy_value %2 : $Klass
  %6a = copy_value %6 : $Klass
  %11 = partial_apply [callee_guaranteed] %8(%2a, %6a) : $@convention(thin) (@guaranteed Klass, @guaranteed Klass, @guaranteed Klass) -> @owned Klass
  %16 = apply %1(%0) : $@convention(method) (@thick Klass.Type) -> @owned Klass
  %17 = apply %11(%16) : $@callee_guaranteed (@guaranteed Klass) -> @owned Klass
  destroy_value %16 : $Klass
  destroy_value %11 : $@callee_guaranteed (@guaranteed Klass) -> @owned Klass
  destroy_value %6 : $Klass
  destroy_value %2 : $Klass
  return %17 : $Klass
} // end sil function 'class_capture_args_ossa'

/////////////////
// Existential //
/////////////////

// All existential arguments.  Partial apply arguments.  Apply arguments.  OSSA.
// CHECK-LABEL: sil [ossa] @existential_capture_args_ossa : $@convention(thin) () -> @out any Proto {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @first_of_three_protos
// CHECK-NOT: partial_apply
// Use %0 explicitly because that is the out parameter.
// CHECK: apply [[FUNCTION_REF]](%0, {{%.*}})
// CHECK: [[RESULT:%.*]] = tuple ()
// CHECK: return [[RESULT]] : $()
// CHECK: } // end sil function 'existential_capture_args_ossa'
sil [ossa] @existential_capture_args_ossa : $@convention(thin) () -> @out Proto {
bb0(%0 : $*Proto):
  %1 = alloc_stack $Proto, let, name "x"
  %2 = function_ref @get_proto : $@convention(thin) () -> @out Proto
  %3 = apply %2(%1) : $@convention(thin) () -> @out Proto
  %4 = alloc_stack $Proto, let, name "y"
  %6 = apply %2(%4) : $@convention(thin) () -> @out Proto
  %7 = function_ref @first_of_three_protos : $@convention(thin) (@in_guaranteed Proto, @guaranteed { var Proto }, @guaranteed { var Proto }) -> @out Proto
  %8 = alloc_box ${ var Proto }
  %9 = project_box %8 : ${ var Proto }, 0
  copy_addr %1 to [init] %9 : $*Proto
  %11 = alloc_box ${ var Proto }
  %12 = project_box %11 : ${ var Proto }, 0
  copy_addr %4 to [init] %12 : $*Proto
  %14 = partial_apply [callee_guaranteed] %7(%8, %11) : $@convention(thin) (@in_guaranteed Proto, @guaranteed { var Proto }, @guaranteed { var Proto }) -> @out Proto
  %17 = alloc_stack $Proto
  %19 = apply %2(%17) : $@convention(thin) () -> @out Proto
  %20 = apply %14(%0, %17) : $@callee_guaranteed (@in_guaranteed Proto) -> @out Proto
  destroy_addr %17 : $*Proto
  dealloc_stack %17 : $*Proto
  destroy_value %14 : $@callee_guaranteed (@in_guaranteed Proto) -> @out Proto
  destroy_addr %4 : $*Proto
  dealloc_stack %4 : $*Proto
  destroy_addr %1 : $*Proto
  dealloc_stack %1 : $*Proto
  %29 = tuple ()
  return %29 : $()
} // end sil function 'existential_capture_args_ossa'

///////////
// Mixed //
///////////

// Mixed arguments.  Trivial partial apply argument.  Existential argument.  OSSA.
// CHECK-LABEL: sil [ossa] @mixed_trivialcapture_existentialarg_ossa : $@convention(thin) () -> @out any Proto {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @proto_from_proto_and_myint
// CHECK-NOT: partial_apply
// Use %0 explicitly because that is the out parameter.
// CHECK: apply [[FUNCTION_REF]](%0, {{%.*}})
// CHECK: [[RESULT:%.*]] = tuple ()
// CHECK: return [[RESULT]] : $()
// CHECK: } // end sil function 'mixed_trivialcapture_existentialarg_ossa'
sil [ossa] @mixed_trivialcapture_existentialarg_ossa : $@convention(thin) () -> @out Proto {
bb0(%0 : $*Proto):
  %1 = integer_literal $Builtin.Int64, 5
  %2 = struct $MyInt (%1 : $Builtin.Int64)
  %4 = function_ref @proto_from_proto_and_myint : $@convention(thin) (@in_guaranteed Proto, MyInt) -> @out Proto
  %5 = partial_apply [callee_guaranteed] %4(%2) : $@convention(thin) (@in_guaranteed Proto, MyInt) -> @out Proto
  %8 = alloc_stack $Proto
  %9 = function_ref @get_proto : $@convention(thin) () -> @out Proto
  %10 = apply %9(%8) : $@convention(thin) () -> @out Proto
  %11 = apply %5(%0, %8) : $@callee_guaranteed (@in_guaranteed Proto) -> @out Proto
  destroy_addr %8 : $*Proto
  dealloc_stack %8 : $*Proto
  destroy_value %5 : $@callee_guaranteed (@in_guaranteed Proto) -> @out Proto
  %16 = tuple ()
  return %16 : $()
} // end sil function 'mixed_trivialcapture_existentialarg_ossa'

// Mixed arguments.  Existential partial apply argument.  Trivial argument.  OSSA.
// CHECK-LABEL: sil [ossa] @mixed_existentialcapture_trivialarg_ossa : $@convention(thin) () -> MyInt {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @myint_from_myint_and_proto
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply [[FUNCTION_REF]]({{%.*}})
// CHECK: return [[RESULT]]
// CHECK: } // end sil function 'mixed_existentialcapture_trivialarg_ossa'
sil [ossa] @mixed_existentialcapture_trivialarg_ossa : $@convention(thin) () -> MyInt {
bb0:
  %0 = alloc_stack $Proto, let, name "x"
  %1 = function_ref @get_proto : $@convention(thin) () -> @out Proto
  %2 = apply %1(%0) : $@convention(thin) () -> @out Proto
  %3 = function_ref @myint_from_myint_and_proto : $@convention(thin) (MyInt, @guaranteed { var Proto }) -> MyInt
  %4 = alloc_box ${ var Proto }
  %5 = project_box %4 : ${ var Proto }, 0
  copy_addr %0 to [init] %5 : $*Proto
  %7 = partial_apply [callee_guaranteed] %3(%4) : $@convention(thin) (MyInt, @guaranteed { var Proto }) -> MyInt
  %10 = integer_literal $Builtin.Int64, 5
  %11 = struct $MyInt (%10 : $Builtin.Int64)
  %12 = apply %7(%11) : $@callee_guaranteed (MyInt) -> MyInt
  destroy_value %7 : $@callee_guaranteed (MyInt) -> MyInt
  destroy_addr %0 : $*Proto
  dealloc_stack %0 : $*Proto
  return %12 : $MyInt
} // end sil function 'mixed_existentialcapture_trivialarg_ossa'

// Mixed arguments.  Mixed partial apply arguments.  No arguments.  OSSA.
// CHECK-LABEL: sil [ossa] @mixed_mixedcapture_noargs_ossa : $@convention(thin) () -> MyInt {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @myint_from_proto_and_myint
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply [[FUNCTION_REF]]({{.*}})
// CHECK: return [[RESULT]]
// CHECK: } // end sil function 'mixed_mixedcapture_noargs_ossa'
sil [ossa] @mixed_mixedcapture_noargs_ossa : $@convention(thin) () -> MyInt {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %3 = alloc_stack $Proto, let, name "y"
  %4 = function_ref @get_proto : $@convention(thin) () -> @out Proto
  %5 = apply %4(%3) : $@convention(thin) () -> @out Proto
  %6 = function_ref @myint_from_proto_and_myint : $@convention(thin) (@guaranteed { var Proto }, MyInt) -> MyInt
  %7 = alloc_box ${ var Proto }
  %8 = project_box %7 : ${ var Proto }, 0
  copy_addr %3 to [init] %8 : $*Proto
  %10 = partial_apply [callee_guaranteed] %6(%7, %1) : $@convention(thin) (@guaranteed { var Proto }, MyInt) -> MyInt
  %13 = apply %10() : $@callee_guaranteed () -> MyInt
  destroy_value %10 : $@callee_guaranteed () -> MyInt
  destroy_addr %3 : $*Proto
  dealloc_stack %3 : $*Proto
  return %13 : $MyInt
} // end sil function 'mixed_mixedcapture_noargs_ossa'

// Mixed arguments.  No partial apply arguments.  Mixed arguments.  OSSA.
// CHECK-LABEL: sil [ossa] @mixed_nocapture_mixedargs_ossa : $@convention(thin) () -> MyInt {
// CHECK: [[FUNCTION_REF:%.*]] = function_ref @myint_from_proto_and_myint
// CHECK-NOT: partial_apply
// CHECK: [[RESULT:%.*]] = apply [[FUNCTION_REF]]({{%.*}}, {{%.*}})
// CHECK: return [[RESULT]]
// CHECK: } // end sil function 'mixed_nocapture_mixedargs_ossa'
sil [ossa] @mixed_nocapture_mixedargs_ossa : $@convention(thin) () -> MyInt {
bb0:
  %0 = integer_literal $Builtin.Int64, 5
  %1 = struct $MyInt (%0 : $Builtin.Int64)
  %3 = alloc_stack $Proto, let, name "y"
  %4 = function_ref @get_proto : $@convention(thin) () -> @out Proto
  %5 = apply %4(%3) : $@convention(thin) () -> @out Proto
  %6 = function_ref @myint_from_proto_and_myint : $@convention(thin) (@guaranteed { var Proto }, MyInt) -> MyInt
  %7 = alloc_box ${ var Proto }
  %8 = project_box %7 : ${ var Proto }, 0
  copy_addr %3 to [init] %8 : $*Proto
  %10 = partial_apply [callee_guaranteed] %6() : $@convention(thin) (@guaranteed { var Proto }, MyInt) -> MyInt
  %13 = apply %10(%7, %1) : $@callee_guaranteed (@guaranteed { var Proto }, MyInt) -> MyInt
  destroy_value %10 : $@callee_guaranteed (@guaranteed { var Proto }, MyInt) -> MyInt
  destroy_value %7  : ${ var Proto }
  destroy_addr %3 : $*Proto
  dealloc_stack %3 : $*Proto
  return %13 : $MyInt
} // end sil function 'mixed_nocapture_mixedargs_ossa'


// CHECK-LABEL: sil [ossa] @dont_remove_polymorphic_builtin
// CHECK: builtin "generic_add"
// CHECK-LABEL: end sil function 'dont_remove_polymorphic_builtin'
sil [ossa] @dont_remove_polymorphic_builtin : $@convention(thin) (@guaranteed Klass, @guaranteed Klass, @guaranteed Klass) -> () {
bb0(%0 : @guaranteed $Klass, %1 : @guaranteed $Klass, %2 : @guaranteed $Klass):
  %3 = alloc_stack $Klass
  %4 = copy_value %0 : $Klass
  store %4 to [init] %3 : $*Klass

  %6 = alloc_stack $Klass
  %7 = copy_value %0 : $Klass
  store %7 to [init] %6 : $*Klass

  %9 = alloc_stack $Klass
  %10 = copy_value %0 : $Klass
  store %10 to [init] %9 : $*Klass

  // builtin "add" is maked read none so it could be removed below. However,
  // builtin "generic_add" does modify memory so, it cannot be removed.
  // Make sure we don't remove it.
  %12 = builtin "generic_add"<Klass>(%3 : $*Klass, %6 : $*Klass, %9 : $*Klass) : $()

  dealloc_stack %9 : $*Klass
  dealloc_stack %6 : $*Klass
  dealloc_stack %3 : $*Klass

  %9999 = tuple ()
  return %9999 : $()
}