File: functionsigopts_sroa.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 (991 lines) | stat: -rw-r--r-- 51,979 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
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
// RUN: %target-sil-opt -enable-objc-interop -enable-sil-verify-all -enable-expand-all -inline -function-signature-opts %s | %FileCheck %s

import Builtin

/////////////////////
// Data Structures //
/////////////////////

struct S0 {
  var f : Builtin.Int16
}

struct S1 {
  var f1 : Builtin.Int16
  var f2 : Builtin.Int32
}

sil @i16_user : $@convention(thin) (Builtin.Int16) -> ()
sil @i32_user : $@convention(thin) (Builtin.Int32) -> ()

sil @s1_user : $@convention(thin) (S1) -> ()
sil @s1_ptr_user : $@convention(thin) (@in S1) -> ()

struct S2 {
  var f1 : S1
  var f2 : Builtin.Int64
}

struct S3 {
  var f1 : S2
  var f2 : S1
}

sil @s2_user : $@convention(thin) (S2) -> ()

class C1 {
  var f1 : Builtin.Int32

  init()
  deinit
}

sil @c1_user : $@convention(thin) (C1) -> ()

class C2 {
  var f1 : S3
  var f2 : C1

  init()
  deinit
}

struct S4 {
  var f1 : Builtin.NativeObject
}

sil @s4_user : $@convention(thin) (S4) -> ()
sil @s4_pointer_user : $@convention(thin) (@in S4) -> ()
sil @s4_user_twice : $@convention(thin) (S4, S4) -> ()

struct S4Pair {
  var f1 : S4
  var f2 : S4
}

struct S4Triple {
  var f1 : S4
  var f2 : S4
  var f3 : S4
}

struct S4Octet {
  var f1 : S4
  var f2 : S4
  var f3 : S4
  var f4 : S4
  var f5 : S4
  var f6 : S4
  var f7 : S4
  var f8 : S4
}

struct S4Fourtytet {
  var f1 : S4Octet
  var f2 : S4Octet
  var f3 : S4Octet
  var f4 : S4Octet
  var f5 : S4Octet
}

struct S5 {
  var f1 : S4
  var f2 : S1
}

sil @s5_user : $@convention(thin) (S5) -> ()

struct S6 {
  var f1 : S1
  var f2 : S1
  var f3 : (Builtin.Int32, Builtin.Int16, S1)
}

struct FakeStaticString {
  var f1 : Builtin.RawPointer
  var f2 : Builtin.Word
  var f3 : Builtin.Word
}

sil @fakestaticstring_user : $@convention(thin) (FakeStaticString) -> ()

@objc protocol FakeAnyObject {}
struct FakeOpaquePointer {
  var rawValue : Builtin.RawPointer
}
enum FakeOptional<T> {
  case none
  case some(T)
}
struct FakeUWord {
  var value: Builtin.Word
}

struct FakeStringCore {
  var baseAddress : FakeOpaquePointer
  var countAndFlags : FakeUWord
  var owner : FakeOptional<FakeAnyObject>
}

struct FakeString {
  var core : FakeStringCore
}
sil @fakestring_user : $@convention(thin) (FakeString) -> ()

sil @tuple_user : $@convention(thin) ((Builtin.Int32, Builtin.Int16, S1)) ->  ()

struct EightFieldStruct {
  var a1 : Builtin.Int32
  var a2 : Builtin.Int32
  var a3 : Builtin.Int32
  var a4 : Builtin.Int32
  var a5 : Builtin.Int32
  var a6 : Builtin.Int32
  var a7 : Builtin.Int32
  var a8 : Builtin.Int32
}

struct ThirtySixFieldStruct {
  var b1 : EightFieldStruct
  var b2 : EightFieldStruct
  var b3 : EightFieldStruct
  var b4 : EightFieldStruct
  var b5 : EightFieldStruct
}

struct SingleFieldLvl1 {
  var s2: SingleFieldLvl2
}
struct SingleFieldLvl2 {
  var s3: SingleFieldLvl3
}
struct SingleFieldLvl3 {
  var s4: Builtin.Int16
}


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

/// Verify that an argument is not exploded if it is entirely trivial even if it
/// is partly dead.
// CHECK-LABEL: sil [serialized] @single_level_dead_root_callee : $@convention(thin) (S1) -> Builtin.Int32 {
// CHECK: bb0([[INPUT:%[0-9]+]] : $S1):
// CHECK: [[RESULT:%.*]] = struct_extract [[INPUT]] : $S1, #S1.f2
// CHECK: return [[RESULT]] : $Builtin.Int32
sil [serialized] @single_level_dead_root_callee : $@convention(thin) (S1) -> Builtin.Int32 {
bb0(%0 : $S1):
  // make it a non-trivial function
  %c1 = builtin "assert_configuration"() : $Builtin.Int32
  %c2 = builtin "assert_configuration"() : $Builtin.Int32
  %c3 = builtin "assert_configuration"() : $Builtin.Int32
  %c4 = builtin "assert_configuration"() : $Builtin.Int32
  %c5 = builtin "assert_configuration"() : $Builtin.Int32
  %c6 = builtin "assert_configuration"() : $Builtin.Int32
  %c7 = builtin "assert_configuration"() : $Builtin.Int32
  %c8 = builtin "assert_configuration"() : $Builtin.Int32
  %c9 = builtin "assert_configuration"() : $Builtin.Int32
  %c10 = builtin "assert_configuration"() : $Builtin.Int32
  %c11 = builtin "assert_configuration"() : $Builtin.Int32
  %c12 = builtin "assert_configuration"() : $Builtin.Int32
  %c13 = builtin "assert_configuration"() : $Builtin.Int32
  %c14 = builtin "assert_configuration"() : $Builtin.Int32
  %c15 = builtin "assert_configuration"() : $Builtin.Int32
  %c16 = builtin "assert_configuration"() : $Builtin.Int32
  %c17 = builtin "assert_configuration"() : $Builtin.Int32
  %c18 = builtin "assert_configuration"() : $Builtin.Int32
  %c19 = builtin "assert_configuration"() : $Builtin.Int32
  %c20 = builtin "assert_configuration"() : $Builtin.Int32
  %c21 = builtin "assert_configuration"() : $Builtin.Int32
  %c22 = builtin "assert_configuration"() : $Builtin.Int32

  %1 = struct_extract %0 : $S1, #S1.f2
  return %1 : $Builtin.Int32
}

// CHECK-LABEL: sil [serialized] @single_level_dead_root_caller : $@convention(thin) (S1) -> () {
// CHECK: bb0([[INPUT:%[0-9]+]] : $S1):
// CHECK: [[FN:%[0-9]+]] = function_ref @single_level_dead_root_callee
// CHECK: apply [[FN]]([[INPUT]])
// CHECK-LABEL: } // end sil function 'single_level_dead_root_caller'
sil [serialized] @single_level_dead_root_caller : $@convention(thin) (S1) -> () {
bb0(%0 : $S1):
  %1 = function_ref @single_level_dead_root_callee : $@convention(thin) (S1) -> Builtin.Int32
  %2 = apply %1(%0) : $@convention(thin) (S1) -> Builtin.Int32
  %9999 = tuple()
  return %9999 : $()
}

/// Verify that fully live trivial arguments are not exploded.
// CHECK-LABEL: sil [serialized] @single_level_live_root_callee : $@convention(thin) (S1) -> Builtin.Int32 {
// CHECK: bb0([[INPUT:%[0-9]+]] : $S1):
// CHECK: [[RESULT:%.*]] = struct_extract [[INPUT]] : $S1, #S1.f2
// CHECK: [[FN:%.*]] = function_ref @s1_user : $@convention(thin) (S1) -> ()
// CHECK: apply [[FN]]([[INPUT]])
// CHECK: return [[RESULT]]
// CHECK-LABEL: } // end sil function 'single_level_live_root_callee'
sil [serialized] @single_level_live_root_callee : $@convention(thin) (S1) -> Builtin.Int32 {
bb0(%0 : $S1):
  // make it a non-trivial function
  %c1 = builtin "assert_configuration"() : $Builtin.Int32
  %c2 = builtin "assert_configuration"() : $Builtin.Int32
  %c3 = builtin "assert_configuration"() : $Builtin.Int32
  %c4 = builtin "assert_configuration"() : $Builtin.Int32
  %c5 = builtin "assert_configuration"() : $Builtin.Int32
  %c6 = builtin "assert_configuration"() : $Builtin.Int32
  %c7 = builtin "assert_configuration"() : $Builtin.Int32
  %c8 = builtin "assert_configuration"() : $Builtin.Int32
  %c9 = builtin "assert_configuration"() : $Builtin.Int32
  %c10 = builtin "assert_configuration"() : $Builtin.Int32
  %c11 = builtin "assert_configuration"() : $Builtin.Int32
  %c12 = builtin "assert_configuration"() : $Builtin.Int32
  %c13 = builtin "assert_configuration"() : $Builtin.Int32
  %c14 = builtin "assert_configuration"() : $Builtin.Int32
  %c15 = builtin "assert_configuration"() : $Builtin.Int32
  %c16 = builtin "assert_configuration"() : $Builtin.Int32
  %c17 = builtin "assert_configuration"() : $Builtin.Int32
  %c18 = builtin "assert_configuration"() : $Builtin.Int32
  %c19 = builtin "assert_configuration"() : $Builtin.Int32
  %c20 = builtin "assert_configuration"() : $Builtin.Int32
  %c21 = builtin "assert_configuration"() : $Builtin.Int32
  %c22 = builtin "assert_configuration"() : $Builtin.Int32

  %1 = struct_extract %0 : $S1, #S1.f2
  %2 = function_ref @s1_user : $@convention(thin) (S1) -> ()
  apply %2(%0) : $@convention(thin) (S1) -> ()
  return %1 : $Builtin.Int32
}

// CHECK-LABEL: sil [serialized] @single_level_live_root_caller : $@convention(thin) (S1) -> () {
// CHECK: bb0([[INPUT:%[0-9]+]] : $S1):
// CHECK: [[FN:%[0-9]+]] = function_ref @single_level_live_root_callee
// CHECK: apply [[FN]]([[INPUT]])
// CHECK-LABEL: } // end sil function 'single_level_live_root_caller'
sil [serialized] @single_level_live_root_caller : $@convention(thin) (S1) -> () {
bb0(%0 : $S1):
  %1 = function_ref @single_level_live_root_callee : $@convention(thin) (S1) -> Builtin.Int32
  %2 = apply %1(%0) : $@convention(thin) (S1) -> Builtin.Int32
  %9999 = tuple()
  return %9999 : $()
}

/// Verify that a two-level aggregate argument which is entirely trivial, whose 
/// root is dead but all of whose leaves are live will not be exploded.
// CHECK-LABEL: sil [serialized] @multiple_level_all_root_fields_used_callee : $@convention(thin) (S2) -> (Builtin.Int16, Builtin.Int64) {
// CHECK: bb0([[INPUT:%.*]] : $S2):
// CHECK: [[INPUTF1:%.*]] = struct_extract [[INPUT]] : $S2, #S2.f1
// CHECK: [[INPUTF1F1:%.*]] = struct_extract [[INPUTF1]] : $S1, #S1.f1
// CHECK: [[INPUTF2:%.*]] = struct_extract [[INPUT]] : $S2, #S2.f2
// CHECK: [[OUT:%.*]] = tuple ([[INPUTF1F1]] : $Builtin.Int16, [[INPUTF2]] : $Builtin.Int64)
// CHECK: return [[OUT]]
// CHECK-LABEL: } // end sil function 'multiple_level_all_root_fields_used_callee'
sil [serialized] @multiple_level_all_root_fields_used_callee : $@convention(thin) (S2) -> (Builtin.Int16, Builtin.Int64) {
bb0(%0 : $S2):
  // make it a non-trivial function
  %c1 = builtin "assert_configuration"() : $Builtin.Int32
  %c2 = builtin "assert_configuration"() : $Builtin.Int32
  %c3 = builtin "assert_configuration"() : $Builtin.Int32
  %c4 = builtin "assert_configuration"() : $Builtin.Int32
  %c5 = builtin "assert_configuration"() : $Builtin.Int32
  %c6 = builtin "assert_configuration"() : $Builtin.Int32
  %c7 = builtin "assert_configuration"() : $Builtin.Int32
  %c8 = builtin "assert_configuration"() : $Builtin.Int32
  %c9 = builtin "assert_configuration"() : $Builtin.Int32
  %c10 = builtin "assert_configuration"() : $Builtin.Int32
  %c11 = builtin "assert_configuration"() : $Builtin.Int32
  %c12 = builtin "assert_configuration"() : $Builtin.Int32
  %c13 = builtin "assert_configuration"() : $Builtin.Int32
  %c14 = builtin "assert_configuration"() : $Builtin.Int32
  %c15 = builtin "assert_configuration"() : $Builtin.Int32
  %c16 = builtin "assert_configuration"() : $Builtin.Int32
  %c17 = builtin "assert_configuration"() : $Builtin.Int32
  %c18 = builtin "assert_configuration"() : $Builtin.Int32
  %c19 = builtin "assert_configuration"() : $Builtin.Int32
  %c20 = builtin "assert_configuration"() : $Builtin.Int32
  %c21 = builtin "assert_configuration"() : $Builtin.Int32
  %c22 = builtin "assert_configuration"() : $Builtin.Int32

  debug_value %0 : $S2 // debug_value should not prevent function signature optimization
  %1 = struct_extract %0 : $S2, #S2.f1
  debug_value %1 : $S1 // debug_value should not prevent function signature optimization
  %2 = struct_extract %1 : $S1, #S1.f1
  %3 = struct_extract %0 : $S2, #S2.f2
  %4 = tuple(%2 : $Builtin.Int16, %3 : $Builtin.Int64)
  return %4 : $(Builtin.Int16, Builtin.Int64)
}

// CHECK-LABEL: sil [serialized] @multiple_level_all_root_fields_used_caller : $@convention(thin) (S2) -> () {
// CHECK: bb0([[INPUT:%.*]] : $S2):
// CHECK: [[FN:%.*]] = function_ref @multiple_level_all_root_fields_used_callee : $@convention(thin) (S2) -> (Builtin.Int16, Builtin.Int64)
// CHECK: apply [[FN]]([[INPUT]])
// CHECK-LABEL: } // end sil function 'multiple_level_all_root_fields_used_caller'
sil [serialized] @multiple_level_all_root_fields_used_caller : $@convention(thin) (S2) -> () {
bb0(%0 : $S2):
  %1 = function_ref @multiple_level_all_root_fields_used_callee : $@convention(thin) (S2) -> (Builtin.Int16, Builtin.Int64)
  %2 = apply %1(%0) : $@convention(thin) (S2) -> (Builtin.Int16, Builtin.Int64)
  %9999 = tuple()
  return %9999 : $()
}

/// Verify that a three-level aggregate argument which is entirely trivial, 
/// whose first level nodes are dead but some of whose leaves are live will not
/// be exploded.
// CHECK-LABEL: sil [serialized] @multiple_level_no_root_fields_have_direct_uses_callee : $@convention(thin) (S3) -> (Builtin.Int16, Builtin.Int64) {
// CHECK: bb0([[INPUT:%.*]] : $S3):
// CHECK: [[INPUTF1:%.*]] = struct_extract [[INPUT]] : $S3, #S3.f1
// CHECK: [[INPUTF1F1:%.*]] = struct_extract [[INPUTF1]] : $S2, #S2.f1
// CHECK: [[INPUTF1F1F1:%.*]] = struct_extract [[INPUTF1F1]] : $S1, #S1.f1
// CHECK: [[INPUTF1F2:%.*]] = struct_extract [[INPUTF1]] : $S2, #S2.f2
// CHECK: [[RESULT:%.*]] = tuple ([[INPUTF1F1F1]] : $Builtin.Int16, [[INPUTF1F2]] : $Builtin.Int64)
// CHECK-LABEL: } // end sil function 'multiple_level_no_root_fields_have_direct_uses_callee'
sil [serialized] @multiple_level_no_root_fields_have_direct_uses_callee : $@convention(thin) (S3) -> (Builtin.Int16, Builtin.Int64) {
bb0(%0 : $S3):
  // make it a non-trivial function
  %c1 = builtin "assert_configuration"() : $Builtin.Int32
  %c2 = builtin "assert_configuration"() : $Builtin.Int32
  %c3 = builtin "assert_configuration"() : $Builtin.Int32
  %c4 = builtin "assert_configuration"() : $Builtin.Int32
  %c5 = builtin "assert_configuration"() : $Builtin.Int32
  %c6 = builtin "assert_configuration"() : $Builtin.Int32
  %c7 = builtin "assert_configuration"() : $Builtin.Int32
  %c8 = builtin "assert_configuration"() : $Builtin.Int32
  %c9 = builtin "assert_configuration"() : $Builtin.Int32
  %c10 = builtin "assert_configuration"() : $Builtin.Int32
  %c11 = builtin "assert_configuration"() : $Builtin.Int32
  %c12 = builtin "assert_configuration"() : $Builtin.Int32
  %c13 = builtin "assert_configuration"() : $Builtin.Int32
  %c14 = builtin "assert_configuration"() : $Builtin.Int32
  %c15 = builtin "assert_configuration"() : $Builtin.Int32
  %c16 = builtin "assert_configuration"() : $Builtin.Int32
  %c17 = builtin "assert_configuration"() : $Builtin.Int32
  %c18 = builtin "assert_configuration"() : $Builtin.Int32
  %c19 = builtin "assert_configuration"() : $Builtin.Int32
  %c20 = builtin "assert_configuration"() : $Builtin.Int32
  %c21 = builtin "assert_configuration"() : $Builtin.Int32
  %c22 = builtin "assert_configuration"() : $Builtin.Int32

  debug_value %0 : $S3
  %1 = struct_extract %0 : $S3, #S3.f1
  %2 = struct_extract %1 : $S2, #S2.f1
  %3 = struct_extract %2 : $S1, #S1.f1
  %4 = struct_extract %1 : $S2, #S2.f2
  %5 = tuple(%3 : $Builtin.Int16, %4 : $Builtin.Int64)
  return %5 : $(Builtin.Int16, Builtin.Int64)
}

// CHECK-LABEL: sil [serialized] @multiple_level_no_root_fields_have_direct_uses_caller : $@convention(thin) (S3) -> () {
// CHECK: bb0([[INPUT:%.*]] : $S3):
// CHECK: [[FUNCTION:%.*]] = function_ref @multiple_level_no_root_fields_have_direct_uses_callee : $@convention(thin) (S3) -> (Builtin.Int16, Builtin.Int64)
// CHECK: apply [[FUNCTION]]([[INPUT]])
// CHECK-LABEL: } // end sil function 'multiple_level_no_root_fields_have_direct_uses_caller'
sil [serialized] @multiple_level_no_root_fields_have_direct_uses_caller : $@convention(thin) (S3) -> () {
bb0(%0 : $S3):
  %1 = function_ref @multiple_level_no_root_fields_have_direct_uses_callee : $@convention(thin) (S3) -> (Builtin.Int16, Builtin.Int64)
  %2 = apply %1(%0) : $@convention(thin) (S3) -> (Builtin.Int16, Builtin.Int64)
  %9999 = tuple()
  return %9999 : $()
}

/// Verify that a two-level aggregate argument which is entirely trivial, some
/// of whose leaves are live and which itself is live will not be exploded.
// CHECK-LABEL: sil [serialized] @multiple_level_root_must_be_reformed_callee : $@convention(thin) (S2) -> (Builtin.Int16, Builtin.Int64) {
// CHECK: bb0([[INPUT:%.*]] : $S2):
// CHECK: [[INPUTF1:%.*]] = struct_extract [[INPUT]] : $S2, #S2.f1
// CHECK: [[INPUTF1F1:%.*]] = struct_extract [[INPUTF1]] : $S1, #S1.f1
// CHECK: [[INPUTF2:%.*]] = struct_extract [[INPUT]] : $S2, #S2.f2
// CHECK: [[OUT:%.*]] = tuple ([[INPUTF1F1]] : $Builtin.Int16, [[INPUTF2]] : $Builtin.Int64)
// CHECK: [[FN:%.*]] = function_ref @s2_user : $@convention(thin) (S2) -> ()
// CHECK: apply [[FN]]([[INPUT]]) : $@convention(thin) (S2) -> ()
// CHECK-LABEL: } // end sil function 'multiple_level_root_must_be_reformed_callee'
sil [serialized] @multiple_level_root_must_be_reformed_callee : $@convention(thin) (S2) -> (Builtin.Int16, Builtin.Int64) {
bb0(%0 : $S2):
  // make it a non-trivial function
  %c1 = builtin "assert_configuration"() : $Builtin.Int32
  %c2 = builtin "assert_configuration"() : $Builtin.Int32
  %c3 = builtin "assert_configuration"() : $Builtin.Int32
  %c4 = builtin "assert_configuration"() : $Builtin.Int32
  %c5 = builtin "assert_configuration"() : $Builtin.Int32
  %c6 = builtin "assert_configuration"() : $Builtin.Int32
  %c7 = builtin "assert_configuration"() : $Builtin.Int32
  %c8 = builtin "assert_configuration"() : $Builtin.Int32
  %c9 = builtin "assert_configuration"() : $Builtin.Int32
  %c10 = builtin "assert_configuration"() : $Builtin.Int32
  %c11 = builtin "assert_configuration"() : $Builtin.Int32
  %c12 = builtin "assert_configuration"() : $Builtin.Int32
  %c13 = builtin "assert_configuration"() : $Builtin.Int32
  %c14 = builtin "assert_configuration"() : $Builtin.Int32
  %c15 = builtin "assert_configuration"() : $Builtin.Int32
  %c16 = builtin "assert_configuration"() : $Builtin.Int32
  %c17 = builtin "assert_configuration"() : $Builtin.Int32
  %c18 = builtin "assert_configuration"() : $Builtin.Int32
  %c19 = builtin "assert_configuration"() : $Builtin.Int32
  %c20 = builtin "assert_configuration"() : $Builtin.Int32
  %c21 = builtin "assert_configuration"() : $Builtin.Int32
  %c22 = builtin "assert_configuration"() : $Builtin.Int32

  %2 = struct_extract %0 : $S2, #S2.f1
  %3 = struct_extract %2 : $S1, #S1.f1
  %4 = struct_extract %0 : $S2, #S2.f2
  %5 = tuple(%3 : $Builtin.Int16, %4 : $Builtin.Int64)
  %6 = function_ref @s2_user : $@convention(thin) (S2) -> ()
  apply %6(%0) : $@convention(thin) (S2) -> ()
  return %5 : $(Builtin.Int16, Builtin.Int64)
}

// CHECK-LABEL: sil [serialized] @multiple_level_root_must_be_reformed_caller : $@convention(thin) (S2) -> () {
// CHECK: bb0([[INPUT:%.*]] : $S2):
// CHECK: [[FUNCTION:%.*]] = function_ref @multiple_level_root_must_be_reformed_callee : $@convention(thin) (S2) -> (Builtin.Int16, Builtin.Int64)
// CHECK: apply [[FUNCTION]]([[INPUT]])
// CHECK-LABEL: } // end sil function 'multiple_level_root_must_be_reformed_caller'
sil [serialized] @multiple_level_root_must_be_reformed_caller : $@convention(thin) (S2) -> () {
bb0(%0 : $S2):
  // make it a non-trivial function
  %c1 = builtin "assert_configuration"() : $Builtin.Int32
  %c2 = builtin "assert_configuration"() : $Builtin.Int32
  %c3 = builtin "assert_configuration"() : $Builtin.Int32
  %c4 = builtin "assert_configuration"() : $Builtin.Int32
  %c5 = builtin "assert_configuration"() : $Builtin.Int32
  %c6 = builtin "assert_configuration"() : $Builtin.Int32
  %c7 = builtin "assert_configuration"() : $Builtin.Int32
  %c8 = builtin "assert_configuration"() : $Builtin.Int32
  %c9 = builtin "assert_configuration"() : $Builtin.Int32
  %c10 = builtin "assert_configuration"() : $Builtin.Int32
  %c11 = builtin "assert_configuration"() : $Builtin.Int32
  %c12 = builtin "assert_configuration"() : $Builtin.Int32
  %c13 = builtin "assert_configuration"() : $Builtin.Int32
  %c14 = builtin "assert_configuration"() : $Builtin.Int32
  %c15 = builtin "assert_configuration"() : $Builtin.Int32
  %c16 = builtin "assert_configuration"() : $Builtin.Int32
  %c17 = builtin "assert_configuration"() : $Builtin.Int32
  %c18 = builtin "assert_configuration"() : $Builtin.Int32
  %c19 = builtin "assert_configuration"() : $Builtin.Int32
  %c20 = builtin "assert_configuration"() : $Builtin.Int32
  %c21 = builtin "assert_configuration"() : $Builtin.Int32
  %c22 = builtin "assert_configuration"() : $Builtin.Int32

  %1 = function_ref @multiple_level_root_must_be_reformed_callee : $@convention(thin) (S2) -> (Builtin.Int16, Builtin.Int64)
  %2 = apply %1(%0) : $@convention(thin) (S2) -> (Builtin.Int16, Builtin.Int64)
  %9999 = tuple()
  return %9999 : $()
}

/// Verify that an aggregate argument containing a single non-trivial live leaf
/// is not exploded.
// CHECK-LABEL: sil [serialized] [signature_optimized_thunk] [always_inline] @owned_struct_1_callee : $@convention(thin) (@owned S5, @owned S5) -> (Builtin.Int16, Builtin.Int32, Builtin.Int16, Builtin.Int32) {
// CHECK: bb0({{%.*}} : $S5, [[INPUT:%.*]] : $S5):
// CHECK: [[FUNCTION:%.*]] = function_ref @$s21owned_struct_1_calleeTfq4dg_n : $@convention(thin) (@guaranteed S5) -> (Builtin.Int16, Builtin.Int32, Builtin.Int16, Builtin.Int32)
// CHECK: [[RESULT:%.*]] = apply [[FUNCTION]]([[INPUT]])
// CHECK: release_value [[INPUT]] : $S5
// CHECK: release_value {{%.*}} : $S5
// CHECK: return [[RESULT]]
// CHECK-LABEL: } // end sil function 'owned_struct_1_callee'
sil [serialized] @owned_struct_1_callee : $@convention(thin) (@owned S5, @owned S5) -> (Builtin.Int16, Builtin.Int32, Builtin.Int16, Builtin.Int32) {
bb0(%0 : $S5, %1 : $S5):
  // make it a non-trivial function
  %c1 = builtin "assert_configuration"() : $Builtin.Int32
  %c2 = builtin "assert_configuration"() : $Builtin.Int32
  %c3 = builtin "assert_configuration"() : $Builtin.Int32
  %c4 = builtin "assert_configuration"() : $Builtin.Int32
  %c5 = builtin "assert_configuration"() : $Builtin.Int32
  %c6 = builtin "assert_configuration"() : $Builtin.Int32
  %c7 = builtin "assert_configuration"() : $Builtin.Int32
  %c8 = builtin "assert_configuration"() : $Builtin.Int32
  %c9 = builtin "assert_configuration"() : $Builtin.Int32
  %c10 = builtin "assert_configuration"() : $Builtin.Int32
  %c11 = builtin "assert_configuration"() : $Builtin.Int32
  %c12 = builtin "assert_configuration"() : $Builtin.Int32
  %c13 = builtin "assert_configuration"() : $Builtin.Int32
  %c14 = builtin "assert_configuration"() : $Builtin.Int32
  %c15 = builtin "assert_configuration"() : $Builtin.Int32
  %c16 = builtin "assert_configuration"() : $Builtin.Int32
  %c17 = builtin "assert_configuration"() : $Builtin.Int32
  %c18 = builtin "assert_configuration"() : $Builtin.Int32
  %c19 = builtin "assert_configuration"() : $Builtin.Int32
  %c20 = builtin "assert_configuration"() : $Builtin.Int32
  %c21 = builtin "assert_configuration"() : $Builtin.Int32
  %c22 = builtin "assert_configuration"() : $Builtin.Int32

  %2 = struct_extract %0 : $S5, #S5.f2
  %3 = struct_extract %2 : $S1, #S1.f1
  %4 = struct_extract %2 : $S1, #S1.f2
  %5 = struct_extract %1 : $S5, #S5.f2
  %6 = struct_extract %5 : $S1, #S1.f1
  %7 = struct_extract %5 : $S1, #S1.f2
  release_value %1 : $S5
  release_value %0 : $S5
  release_value %1 : $S5
  %8 = tuple(%6 : $Builtin.Int16, %7 : $Builtin.Int32, %6 : $Builtin.Int16, %7 : $Builtin.Int32)
  return %8 : $(Builtin.Int16, Builtin.Int32, Builtin.Int16, Builtin.Int32)
}

// CHECK-LABEL: sil [serialized] @owned_struct_1_caller : $@convention(thin) (S5) -> () {
// CHECK: bb0([[INPUT:%.*]] : $S5):
// CHECK: [[INPUTF2:%.*]] = struct_extract [[INPUT]] : $S5, #S5.f2
// CHECK: [[INPUTF2F1:%.*]] = struct_extract [[INPUTF2]] : $S1, #S1.f1
// CHECK: [[INPUTF2F2:%.*]] = struct_extract [[INPUTF2]] : $S1, #S1.f2
// CHECK: [[OUT:%.*]] = tuple ([[INPUTF2F1]] : $Builtin.Int16, [[INPUTF2F2]] : $Builtin.Int32, [[INPUTF2F1]] : $Builtin.Int16, [[INPUTF2F2]] : $Builtin.Int32)
// CHECK-LABEL: } // end sil function 'owned_struct_1_caller'
sil [serialized] @owned_struct_1_caller : $@convention(thin) (S5) -> () {
bb0(%0 : $S5):
  %1 = function_ref @owned_struct_1_callee : $@convention(thin) (@owned S5, @owned S5) -> (Builtin.Int16, Builtin.Int32, Builtin.Int16, Builtin.Int32)
  %2 = apply %1(%0, %0) : $@convention(thin) (@owned S5, @owned S5) -> (Builtin.Int16, Builtin.Int32, Builtin.Int16, Builtin.Int32)
  %9999 = tuple()
  return %9999 : $()
}

/// Verify that argument explosion that increases argument count before and
/// after dead argument elimination behaves properly.
// CHECK-LABEL: sil [serialized] [signature_optimized_thunk] [always_inline] @owned_struct_2_callee : $@convention(thin) (Builtin.Int256, Builtin.Int256, @owned S4Triple, Builtin.Int128, Builtin.Int128) -> (Builtin.Int256, Builtin.Int256, Builtin.Int128, Builtin.Int128) {
// CHECK: bb0([[IN1:%.*]] : $Builtin.Int256, [[IN2:%.*]] : $Builtin.Int256, [[TRIPLE:%.*]] : $S4Triple, [[IN4:%.*]] : $Builtin.Int128, [[IN5:%.*]] : $Builtin.Int128):
// CHECK: [[FN:%.*]] = function_ref @$s21owned_struct_2_calleeTfq4ndgXdn_n : $@convention(thin) (Builtin.Int256, @guaranteed S4, @guaranteed S4, Builtin.Int128) -> (Builtin.Int256, Builtin.Int256, Builtin.Int128, Builtin.Int128)
// CHECK: [[TRIPLEF3:%.*]] = struct_extract [[TRIPLE]] : $S4Triple, #S4Triple.f3
// CHECK: [[TRIPLEF2:%.*]] = struct_extract [[TRIPLE]] : $S4Triple, #S4Triple.f2
// CHECK: [[RESULT:%.*]] = apply [[FN]]([[IN1]], [[TRIPLEF2]], [[TRIPLEF3]], [[IN5]]) : $@convention(thin) (Builtin.Int256, @guaranteed S4, @guaranteed S4, Builtin.Int128) -> (Builtin.Int256, Builtin.Int256, Builtin.Int128, Builtin.Int128)
// CHECK: release_value [[TRIPLE]] : $S4Triple
// CHECK: return [[RESULT]]
// CHECK-LABEL: } // end sil function 'owned_struct_2_callee'
sil [serialized] @owned_struct_2_callee : $@convention(thin) (Builtin.Int256, Builtin.Int256, @owned S4Triple, Builtin.Int128, Builtin.Int128) -> (Builtin.Int256, Builtin.Int256, Builtin.Int128, Builtin.Int128) {
bb0(%0 : $Builtin.Int256, %1 : $Builtin.Int256, %triple : $S4Triple, %3 : $Builtin.Int128, %4 : $Builtin.Int128):
  // make it a non-trivial function
  %c1 = builtin "assert_configuration"() : $Builtin.Int32
  %c2 = builtin "assert_configuration"() : $Builtin.Int32
  %c3 = builtin "assert_configuration"() : $Builtin.Int32
  %c4 = builtin "assert_configuration"() : $Builtin.Int32
  %c5 = builtin "assert_configuration"() : $Builtin.Int32
  %c6 = builtin "assert_configuration"() : $Builtin.Int32
  %c7 = builtin "assert_configuration"() : $Builtin.Int32
  %c8 = builtin "assert_configuration"() : $Builtin.Int32
  %c9 = builtin "assert_configuration"() : $Builtin.Int32
  %c10 = builtin "assert_configuration"() : $Builtin.Int32
  %c11 = builtin "assert_configuration"() : $Builtin.Int32
  %c12 = builtin "assert_configuration"() : $Builtin.Int32
  %c13 = builtin "assert_configuration"() : $Builtin.Int32
  %c14 = builtin "assert_configuration"() : $Builtin.Int32
  %c15 = builtin "assert_configuration"() : $Builtin.Int32
  %c16 = builtin "assert_configuration"() : $Builtin.Int32
  %c17 = builtin "assert_configuration"() : $Builtin.Int32
  %c18 = builtin "assert_configuration"() : $Builtin.Int32
  %c19 = builtin "assert_configuration"() : $Builtin.Int32
  %c20 = builtin "assert_configuration"() : $Builtin.Int32
  %c21 = builtin "assert_configuration"() : $Builtin.Int32
  %c22 = builtin "assert_configuration"() : $Builtin.Int32

  %triple_field2 = struct_extract %triple : $S4Triple, #S4Triple.f2
  %triple_field3 = struct_extract %triple : $S4Triple, #S4Triple.f3
  %func = function_ref @s4_user_twice : $@convention(thin) (S4, S4) -> ()
  %_ = apply %func(%triple_field2, %triple_field3) : $@convention(thin) (S4, S4) -> ()
  release_value %triple : $S4Triple
  %result = tuple (%0 : $Builtin.Int256, %0 : $Builtin.Int256, %4 : $Builtin.Int128, %4 : $Builtin.Int128)
  return %result : $(Builtin.Int256, Builtin.Int256, Builtin.Int128, Builtin.Int128)
}


// CHECK-LABEL: sil [serialized] @owned_struct_2_caller : $@convention(thin) (Builtin.Int256, S4Triple, Builtin.Int128) -> () {
// CHECK: bb0([[IN1:%.*]] : $Builtin.Int256, [[TRIPLE:%.*]] : $S4Triple, [[IN3:%.*]] : $Builtin.Int128):
// CHECK: [[FN:%.*]] = function_ref @$s21owned_struct_2_calleeTfq4ndgXdn_n : $@convention(thin) (Builtin.Int256, @guaranteed S4, @guaranteed S4, Builtin.Int128) -> (Builtin.Int256, Builtin.Int256, Builtin.Int128, Builtin.Int128)
// CHECK: [[TRIPLEF3:%.*]] = struct_extract [[TRIPLE]] : $S4Triple, #S4Triple.f3
// CHECK: [[TRIPLEF2:%.*]] = struct_extract [[TRIPLE]] : $S4Triple, #S4Triple.f2
// CHECK: apply [[FN]]([[IN1]], [[TRIPLEF2]], [[TRIPLEF3]], [[IN3]]) : $@convention(thin) (Builtin.Int256, @guaranteed S4, @guaranteed S4, Builtin.Int128) -> (Builtin.Int256, Builtin.Int256, Builtin.Int128, Builtin.Int128)
// CHECK-LABEL: } // end sil function 'owned_struct_2_caller'
sil [serialized] @owned_struct_2_caller : $@convention(thin) (Builtin.Int256, S4Triple, Builtin.Int128) -> () {
bb0(%0 : $Builtin.Int256, %1 : $S4Triple, %2 : $Builtin.Int128):
  %3 = function_ref @owned_struct_2_callee : $@convention(thin) (Builtin.Int256, Builtin.Int256, @owned S4Triple, Builtin.Int128, Builtin.Int128) -> (Builtin.Int256, Builtin.Int256, Builtin.Int128, Builtin.Int128)
  %4 = apply %3(%0, %0, %1, %2, %2) : $@convention(thin) (Builtin.Int256, Builtin.Int256, @owned S4Triple, Builtin.Int128, Builtin.Int128) -> (Builtin.Int256, Builtin.Int256, Builtin.Int128, Builtin.Int128)
  %9999 = tuple()
  return %9999 : $()
}

/// Verify that pointer arguments are ignored for now.
// CHECK-LABEL: sil [serialized] [signature_optimized_thunk] [always_inline] @ignore_ptrs_callee : $@convention(thin) (@in S4Pair, S4Pair, S4Pair) -> (S4, S4) {
// CHECK: bb0([[POINTER:%.*]] : $*S4Pair, [[PAIR1:%.*]] : $S4Pair, [[PAIR2:%.*]] : $S4Pair):
// CHECK: [[FN:%.*]] = function_ref @$s18ignore_ptrs_calleeTfq4nxx_n : $@convention(thin) (@in S4Pair, S4, S4) -> (S4, S4)
// CHECK: [[VALUE1:%.*]] = struct_extract [[PAIR1]] : $S4Pair, #S4Pair.f1
// CHECK: [[VALUE2:%.*]] = struct_extract [[PAIR2]] : $S4Pair, #S4Pair.f1
// CHECK: [[RESULT:%.*]] = apply [[FN]]([[POINTER]], [[VALUE1]], [[VALUE2]]) : $@convention(thin) (@in S4Pair, S4, S4) -> (S4, S4)
// CHECK: return [[RESULT]]
// CHECK-LABEL: } // end sil function 'ignore_ptrs_callee'
sil [serialized] @ignore_ptrs_callee : $@convention(thin) (@in S4Pair, S4Pair, S4Pair) -> (S4, S4) {
bb0(%pointer : $*S4Pair, %pair1 : $S4Pair, %pair2 : $S4Pair):
  // make it a non-trivial function
  %c1 = builtin "assert_configuration"() : $Builtin.Int32
  %c2 = builtin "assert_configuration"() : $Builtin.Int32
  %c3 = builtin "assert_configuration"() : $Builtin.Int32
  %c4 = builtin "assert_configuration"() : $Builtin.Int32
  %c5 = builtin "assert_configuration"() : $Builtin.Int32
  %c6 = builtin "assert_configuration"() : $Builtin.Int32
  %c7 = builtin "assert_configuration"() : $Builtin.Int32
  %c8 = builtin "assert_configuration"() : $Builtin.Int32
  %c9 = builtin "assert_configuration"() : $Builtin.Int32
  %c10 = builtin "assert_configuration"() : $Builtin.Int32
  %c11 = builtin "assert_configuration"() : $Builtin.Int32
  %c12 = builtin "assert_configuration"() : $Builtin.Int32
  %c13 = builtin "assert_configuration"() : $Builtin.Int32
  %c14 = builtin "assert_configuration"() : $Builtin.Int32
  %c15 = builtin "assert_configuration"() : $Builtin.Int32
  %c16 = builtin "assert_configuration"() : $Builtin.Int32
  %c17 = builtin "assert_configuration"() : $Builtin.Int32
  %c18 = builtin "assert_configuration"() : $Builtin.Int32
  %c19 = builtin "assert_configuration"() : $Builtin.Int32
  %c20 = builtin "assert_configuration"() : $Builtin.Int32
  %c21 = builtin "assert_configuration"() : $Builtin.Int32
  %c22 = builtin "assert_configuration"() : $Builtin.Int32

  %func = function_ref @s4_user : $@convention(thin) (S4) -> ()
  %pointee = load %pointer : $*S4Pair
  %first_pointee = struct_extract %pointee : $S4Pair, #S4Pair.f1
  %_ = apply %func(%first_pointee) : $@convention(thin) (S4) -> ()
  %first1 = struct_extract %pair1 : $S4Pair, #S4Pair.f1
  %first2 = struct_extract %pair2 : $S4Pair, #S4Pair.f1
  %result = tuple (%first1 : $S4, %first2 : $S4)
  return %result : $(S4, S4)
}

// CHECK-LABEL: sil [serialized] @ignore_ptrs_caller : $@convention(thin) (@in S4Pair, S4Pair, S4Pair) -> () {
// CHECK: bb0([[POINTER:%.*]] : $*S4Pair, [[PAIR1:%.*]] : $S4Pair, [[PAIR2:%.*]] : $S4Pair):
// CHECK: [[FN:%.*]] = function_ref @$s18ignore_ptrs_calleeTfq4nxx_n : $@convention(thin) (@in S4Pair, S4, S4) -> (S4, S4)
// CHECK: [[VALUE1:%.*]] = struct_extract [[PAIR1]] : $S4Pair, #S4Pair.f1
// CHECK: [[VALUE2:%.*]] = struct_extract [[PAIR2]] : $S4Pair, #S4Pair.f1
// CHECK: apply [[FN]]([[POINTER]], [[VALUE1]], [[VALUE2]]) : $@convention(thin) (@in S4Pair, S4, S4) -> (S4, S4)
// CHECK-LABEL: } // end sil function 'ignore_ptrs_caller'
sil [serialized] @ignore_ptrs_caller : $@convention(thin) (@in S4Pair, S4Pair, S4Pair) -> () {
bb0(%0 : $*S4Pair, %1 : $S4Pair, %2 : $S4Pair):
  %3 = function_ref @ignore_ptrs_callee : $@convention(thin) (@in S4Pair, S4Pair, S4Pair) -> (S4, S4)
  %4 = apply %3(%0, %1, %2) : $@convention(thin) (@in S4Pair, S4Pair, S4Pair) -> (S4, S4)
  %9999 = tuple()
  return %9999 : $()
}

// This test makes sure that we can handle multiple SROA arguments.
// CHECK-LABEL: sil [serialized] @multiple_sroa_callee : $@convention(thin) (FakeStaticString, @owned FakeString, FakeStaticString) -> () {
// CHECK: bb0([[IN1:%.*]] : $FakeStaticString, [[IN2:%.*]] : $FakeString, [[IN3:%.*]] : $FakeStaticString):
// CHECK: [[FN:%.*]] = function_ref @fakestaticstring_user : $@convention(thin) (FakeStaticString) -> ()
// CHECK: apply [[FN]]([[IN1]]) : $@convention(thin) (FakeStaticString) -> ()
// CHECK-LABEL: } // end sil function 'multiple_sroa_callee'
sil [serialized] @multiple_sroa_callee : $@convention(thin) (FakeStaticString, @owned FakeString, FakeStaticString) -> () {
bb0(%0 : $FakeStaticString, %1 : $FakeString, %2 : $FakeStaticString):
  // make it a non-trivial function
  %c1 = builtin "assert_configuration"() : $Builtin.Int32
  %c2 = builtin "assert_configuration"() : $Builtin.Int32
  %c3 = builtin "assert_configuration"() : $Builtin.Int32
  %c4 = builtin "assert_configuration"() : $Builtin.Int32
  %c5 = builtin "assert_configuration"() : $Builtin.Int32
  %c6 = builtin "assert_configuration"() : $Builtin.Int32
  %c7 = builtin "assert_configuration"() : $Builtin.Int32
  %c8 = builtin "assert_configuration"() : $Builtin.Int32
  %c9 = builtin "assert_configuration"() : $Builtin.Int32
  %c10 = builtin "assert_configuration"() : $Builtin.Int32
  %c11 = builtin "assert_configuration"() : $Builtin.Int32
  %c12 = builtin "assert_configuration"() : $Builtin.Int32
  %c13 = builtin "assert_configuration"() : $Builtin.Int32
  %c14 = builtin "assert_configuration"() : $Builtin.Int32
  %c15 = builtin "assert_configuration"() : $Builtin.Int32
  %c16 = builtin "assert_configuration"() : $Builtin.Int32
  %c17 = builtin "assert_configuration"() : $Builtin.Int32
  %c18 = builtin "assert_configuration"() : $Builtin.Int32
  %c19 = builtin "assert_configuration"() : $Builtin.Int32
  %c20 = builtin "assert_configuration"() : $Builtin.Int32
  %c21 = builtin "assert_configuration"() : $Builtin.Int32
  %c22 = builtin "assert_configuration"() : $Builtin.Int32

  %3 = function_ref @fakestaticstring_user : $@convention(thin) (FakeStaticString) -> ()
  %4 = function_ref @fakestring_user : $@convention(thin) (FakeString) -> ()
  apply %3(%0) : $@convention(thin) (FakeStaticString) -> ()
  apply %4(%1) : $@convention(thin) (FakeString) -> ()
  apply %3(%2) : $@convention(thin) (FakeStaticString) -> ()
  %9999 = tuple()
  return %9999 : $()
}

// CHECK-LABEL: sil [serialized] @multiple_sroa_caller : $@convention(thin) (FakeStaticString, @owned FakeString, FakeStaticString) -> () {
// CHECK: bb0([[IN1:%.*]] : $FakeStaticString, [[IN2:%.*]] : $FakeString, [[IN3:%.*]] : $FakeStaticString):
// CHECK: [[FN:%.*]] = function_ref @multiple_sroa_callee : $@convention(thin) (FakeStaticString, @owned FakeString, FakeStaticString) -> ()
// CHECK-LABEL: } // end sil function 'multiple_sroa_caller'
sil [serialized] @multiple_sroa_caller : $@convention(thin) (FakeStaticString, @owned FakeString, FakeStaticString) -> () {
bb0(%0 : $FakeStaticString, %1 : $FakeString, %2 : $FakeStaticString):
  %3 = function_ref @multiple_sroa_callee : $@convention(thin) (FakeStaticString, @owned FakeString, FakeStaticString) -> ()
  %4 = apply %3(%0, %1, %2) : $@convention(thin) (FakeStaticString, @owned FakeString, FakeStaticString) -> ()
  %9999 = tuple()
  return %9999 : $()
}

/// Verify that in the face of an exploded argument the ordering of arguments is
/// based on ordering of fields in the original argument rather than ordering of
/// usage in the function being specialized.
// CHECK-LABEL: sil [serialized] [signature_optimized_thunk] [always_inline] @check_out_of_order_uses_callee : $@convention(thin) (S4Triple) -> () {
// CHECK: bb0([[TRIPLE:%.*]] : $S4Triple):
// CHECK: [[FUNCTION:%.*]] = function_ref @$s30check_out_of_order_uses_calleeTfq4x_n : $@convention(thin) (S4, S4) -> ()
// CHECK: [[INPUT1F2:%.*]] = struct_extract [[TRIPLE]] : $S4Triple, #S4Triple.f2
// CHECK: [[INPUT1F1:%.*]] = struct_extract [[TRIPLE]] : $S4Triple, #S4Triple.f1
// CHECK: apply [[FUNCTION]]([[INPUT1F1]], [[INPUT1F2]]) : $@convention(thin) (S4, S4) -> ()
// CHECK-LABEL: } // end sil function 'check_out_of_order_uses_callee'
sil [serialized] @check_out_of_order_uses_callee : $@convention(thin) (S4Triple) -> () {
only(%triple : $S4Triple):
  // make it a non-trivial function
  %c1 = builtin "assert_configuration"() : $Builtin.Int32
  %c2 = builtin "assert_configuration"() : $Builtin.Int32
  %c3 = builtin "assert_configuration"() : $Builtin.Int32
  %c4 = builtin "assert_configuration"() : $Builtin.Int32
  %c5 = builtin "assert_configuration"() : $Builtin.Int32
  %c6 = builtin "assert_configuration"() : $Builtin.Int32
  %c7 = builtin "assert_configuration"() : $Builtin.Int32
  %c8 = builtin "assert_configuration"() : $Builtin.Int32
  %c9 = builtin "assert_configuration"() : $Builtin.Int32
  %c10 = builtin "assert_configuration"() : $Builtin.Int32
  %c11 = builtin "assert_configuration"() : $Builtin.Int32
  %c12 = builtin "assert_configuration"() : $Builtin.Int32
  %c13 = builtin "assert_configuration"() : $Builtin.Int32
  %c14 = builtin "assert_configuration"() : $Builtin.Int32
  %c15 = builtin "assert_configuration"() : $Builtin.Int32
  %c16 = builtin "assert_configuration"() : $Builtin.Int32
  %c17 = builtin "assert_configuration"() : $Builtin.Int32
  %c18 = builtin "assert_configuration"() : $Builtin.Int32
  %c19 = builtin "assert_configuration"() : $Builtin.Int32
  %c20 = builtin "assert_configuration"() : $Builtin.Int32
  %c21 = builtin "assert_configuration"() : $Builtin.Int32
  %c22 = builtin "assert_configuration"() : $Builtin.Int32

  %second = struct_extract %triple : $S4Triple, #S4Triple.f2
  %func = function_ref @s4_user : $@convention(thin) (S4) -> ()
  apply %func(%second) : $@convention(thin) (S4) -> ()
  %first = struct_extract %triple : $S4Triple, #S4Triple.f1
  apply %func(%first) : $@convention(thin) (S4) -> ()
  %result = tuple()
  return %result : $()
}

// CHECK-LABEL: sil [serialized] @check_out_of_order_uses_caller : $@convention(thin) (S4Triple) -> () {
// CHECK: bb0([[TRIPLE:%.*]] : $S4Triple):
// CHECK: [[FUNCTION:%.*]] = function_ref @$s30check_out_of_order_uses_calleeTfq4x_n : $@convention(thin) (S4, S4) -> ()
// CHECK: [[TRIPLEF2:%.*]] = struct_extract [[TRIPLE]] : $S4Triple, #S4Triple.f2
// CHECK: [[TRIPLEF1:%.*]] = struct_extract [[TRIPLE]] : $S4Triple, #S4Triple.f1
// CHECK: [[RESULT:%.*]] = apply [[FUNCTION]]([[TRIPLEF1]], [[TRIPLEF2]]) : $@convention(thin) (S4, S4) -> ()
// CHECK: return [[RESULT]] : $()
// CHECK-LABEL: } // end sil function 'check_out_of_order_uses_caller'
sil [serialized] @check_out_of_order_uses_caller : $@convention(thin) (S4Triple) -> () {
bb0(%0 : $S4Triple):
  %1 = function_ref @check_out_of_order_uses_callee : $@convention(thin) (S4Triple) -> ()
  %result = apply %1(%0) : $@convention(thin) (S4Triple) -> ()
  return %result : $()
}

// Make sure that we do not SROA classes.
// CHECK-LABEL: sil [serialized] [signature_optimized_thunk] [always_inline] @class_callee_1 : $@convention(thin) (@owned C1, Builtin.Int32) -> Builtin.Int32 {
// CHECK: bb0([[IN1:%.*]] : $C1, [[IN2:%.*]] : $Builtin.Int32):
// CHECK: [[FN:%.*]] = function_ref @$s14class_callee_1Tfq4gn_n : $@convention(thin) (@guaranteed C1, Builtin.Int32) -> Builtin.Int32
// CHECK: apply [[FN]]([[IN1]], [[IN2]]) : $@convention(thin) (@guaranteed C1, Builtin.Int32) -> Builtin.Int32
// CHECK: release_value [[IN1]]
sil [serialized] @class_callee_1 : $@convention(thin) (@owned C1, Builtin.Int32) -> Builtin.Int32 {
bb0(%0 : $C1, %1 : $Builtin.Int32):
  // make it a non-trivial function
  %c1 = builtin "assert_configuration"() : $Builtin.Int32
  %c2 = builtin "assert_configuration"() : $Builtin.Int32
  %c3 = builtin "assert_configuration"() : $Builtin.Int32
  %c4 = builtin "assert_configuration"() : $Builtin.Int32
  %c5 = builtin "assert_configuration"() : $Builtin.Int32
  %c6 = builtin "assert_configuration"() : $Builtin.Int32
  %c7 = builtin "assert_configuration"() : $Builtin.Int32
  %c8 = builtin "assert_configuration"() : $Builtin.Int32
  %c9 = builtin "assert_configuration"() : $Builtin.Int32
  %c10 = builtin "assert_configuration"() : $Builtin.Int32
  %c11 = builtin "assert_configuration"() : $Builtin.Int32
  %c12 = builtin "assert_configuration"() : $Builtin.Int32
  %c13 = builtin "assert_configuration"() : $Builtin.Int32
  %c14 = builtin "assert_configuration"() : $Builtin.Int32
  %c15 = builtin "assert_configuration"() : $Builtin.Int32
  %c16 = builtin "assert_configuration"() : $Builtin.Int32
  %c17 = builtin "assert_configuration"() : $Builtin.Int32
  %c18 = builtin "assert_configuration"() : $Builtin.Int32
  %c19 = builtin "assert_configuration"() : $Builtin.Int32
  %c20 = builtin "assert_configuration"() : $Builtin.Int32
  %c21 = builtin "assert_configuration"() : $Builtin.Int32
  %c22 = builtin "assert_configuration"() : $Builtin.Int32

  // This use is needed so that we do not perform dead arg + owned -> guaranteed.
  strong_retain %0 : $C1
  %2 = function_ref @c1_user : $@convention(thin) (C1) -> ()
  apply %2(%0) : $@convention(thin) (C1) -> ()
  strong_release %0 : $C1
  return %1 : $Builtin.Int32
}

// CHECK-LABEL: sil [serialized] [signature_optimized_thunk] [always_inline] @class_caller_1 : $@convention(thin) (@owned C1, Builtin.Int32) -> Builtin.Int32 {
// CHECK: bb0([[IN1:%.*]] : $C1, [[IN2:%.*]] : $Builtin.Int32):
// CHECK: [[FN:%.*]] = function_ref @$s14class_callee_1Tfq4gn_n : $@convention(thin) (@guaranteed C1, Builtin.Int32) -> Builtin.Int32
// CHECK: apply [[FN]]([[IN1]], [[IN2]]) : $@convention(thin) (@guaranteed C1, Builtin.Int32) -> Builtin.Int32
// CHECK: release_value [[IN1]]
sil [serialized] @class_caller_1 : $@convention(thin) (@owned C1, Builtin.Int32) -> Builtin.Int32 {
bb0(%0 : $C1, %1 : $Builtin.Int32):
  %2 = function_ref @class_callee_1 : $@convention(thin) (@owned C1, Builtin.Int32) -> Builtin.Int32
  %3 = apply %2(%0, %1) : $@convention(thin) (@owned C1, Builtin.Int32) -> Builtin.Int32
  return %3 : $Builtin.Int32
}

// Make sure we don't clone this despite the projection tree able to
// explode S0 if it was a loadable value.
// CHECK-LABEL: sil [serialized] @inarg_callee : $@convention(thin) (@in S1) -> () {
// CHECK: bb0([[IN:%.*]] : $*S1):
// CHECK: function_ref s1_ptr_user
// CHECK: [[FN:%.*]] = function_ref @s1_ptr_user : $@convention(thin) (@in S1) -> ()
// CHECK: apply [[FN]]
// CHECK: tuple
// CHECK: return
sil [serialized] @inarg_callee : $@convention(thin) (@in S1) -> () {
bb0(%0 : $*S1):
  // make it a non-trivial function
  %c1 = builtin "assert_configuration"() : $Builtin.Int32
  %c2 = builtin "assert_configuration"() : $Builtin.Int32
  %c3 = builtin "assert_configuration"() : $Builtin.Int32
  %c4 = builtin "assert_configuration"() : $Builtin.Int32
  %c5 = builtin "assert_configuration"() : $Builtin.Int32
  %c6 = builtin "assert_configuration"() : $Builtin.Int32
  %c7 = builtin "assert_configuration"() : $Builtin.Int32
  %c8 = builtin "assert_configuration"() : $Builtin.Int32
  %c9 = builtin "assert_configuration"() : $Builtin.Int32
  %c10 = builtin "assert_configuration"() : $Builtin.Int32
  %c11 = builtin "assert_configuration"() : $Builtin.Int32
  %c12 = builtin "assert_configuration"() : $Builtin.Int32
  %c13 = builtin "assert_configuration"() : $Builtin.Int32
  %c14 = builtin "assert_configuration"() : $Builtin.Int32
  %c15 = builtin "assert_configuration"() : $Builtin.Int32
  %c16 = builtin "assert_configuration"() : $Builtin.Int32
  %c17 = builtin "assert_configuration"() : $Builtin.Int32
  %c18 = builtin "assert_configuration"() : $Builtin.Int32
  %c19 = builtin "assert_configuration"() : $Builtin.Int32
  %c20 = builtin "assert_configuration"() : $Builtin.Int32
  %c21 = builtin "assert_configuration"() : $Builtin.Int32
  %c22 = builtin "assert_configuration"() : $Builtin.Int32

  %1 = function_ref @s1_ptr_user : $@convention(thin) (@in S1) -> ()
	%2 = apply %1(%0) : $@convention(thin) (@in S1) -> ()
	%9999 = tuple()
	return %9999 : $()
}

// CHECK-LABEL: sil [serialized] @inarg_caller : $@convention(thin) (@in S1) -> () {
// CHECK: bb0([[IN:%.*]] : $*S1):
// CHECK-NEXT: function_ref inarg_callee
// CHECK-NEXT: [[FN:%.*]] = function_ref @inarg_callee : $@convention(thin) (@in S1) -> ()
// CHECK-NEXT: apply [[FN]]
// CHECK-NEXT: tuple
// CHECK-NEXT: return
// CHECK-LABEL: } // end sil function 'inarg_caller'
sil [serialized] @inarg_caller : $@convention(thin) (@in S1) -> () {
bb0(%0 : $*S1):
  %1 = function_ref @inarg_callee : $@convention(thin) (@in S1) -> ()
	%2 = apply %1(%0) : $@convention(thin) (@in S1) -> ()
	%9999 = tuple()
	return %9999 : $()
}

// This test makes sure we can handle functions with more than 32 fields
// (including each subtype's field in that count). This fixes a bug where we
// were not handling the possibility of an std::vector resize invalidated
// references. This cause the this pointer to become invalidated and other
// shenanigans. So just make sure we don't crash
// CHECK-LABEL: sil [serialized] @more_than_32_type_sized_caller : $@convention(thin) (S4Fourtytet) -> S4 {
// CHECK-LABEL: } // end sil function 'more_than_32_type_sized_caller'
sil [serialized] @more_than_32_type_sized_caller : $@convention(thin) (S4Fourtytet) -> S4 {
only(%tet : $S4Fourtytet):
  %func = function_ref @more_than_32_type_sized_callee : $@convention(thin) (S4Fourtytet) -> S4
  %result = apply %func(%tet) : $@convention(thin) (S4Fourtytet) -> S4
  return %result : $S4
}

// CHECK-LABEL: sil [serialized] [signature_optimized_thunk] [always_inline] @more_than_32_type_sized_callee : $@convention(thin) (S4Fourtytet) -> S4 {
// CHECK-LABEL: } // end sil function 'more_than_32_type_sized_callee'
sil [serialized] @more_than_32_type_sized_callee : $@convention(thin) (S4Fourtytet) -> S4 {
bb0(%tet : $S4Fourtytet):
  // make it a non-trivial function
  %c1 = builtin "assert_configuration"() : $Builtin.Int32
  %c2 = builtin "assert_configuration"() : $Builtin.Int32
  %c3 = builtin "assert_configuration"() : $Builtin.Int32
  %c4 = builtin "assert_configuration"() : $Builtin.Int32
  %c5 = builtin "assert_configuration"() : $Builtin.Int32
  %c6 = builtin "assert_configuration"() : $Builtin.Int32
  %c7 = builtin "assert_configuration"() : $Builtin.Int32
  %c8 = builtin "assert_configuration"() : $Builtin.Int32
  %c9 = builtin "assert_configuration"() : $Builtin.Int32
  %c10 = builtin "assert_configuration"() : $Builtin.Int32
  %c11 = builtin "assert_configuration"() : $Builtin.Int32
  %c12 = builtin "assert_configuration"() : $Builtin.Int32
  %c13 = builtin "assert_configuration"() : $Builtin.Int32
  %c14 = builtin "assert_configuration"() : $Builtin.Int32
  %c15 = builtin "assert_configuration"() : $Builtin.Int32
  %c16 = builtin "assert_configuration"() : $Builtin.Int32
  %c17 = builtin "assert_configuration"() : $Builtin.Int32
  %c18 = builtin "assert_configuration"() : $Builtin.Int32
  %c19 = builtin "assert_configuration"() : $Builtin.Int32
  %c20 = builtin "assert_configuration"() : $Builtin.Int32
  %c21 = builtin "assert_configuration"() : $Builtin.Int32
  %c22 = builtin "assert_configuration"() : $Builtin.Int32

  %octet = struct_extract %tet : $S4Fourtytet, #S4Fourtytet.f1
  %result = struct_extract %octet : $S4Octet, #S4Octet.f1
  return %result : $S4
}

// We should not specialize this since SingleFieldLvl1 is a struct that is layout compatible with its only leaf node, %0.s2.s3.s4
// CHECK-LABEL: sil [serialized] @multiple_level_all_single_field_struct_callee : $@convention(thin) (SingleFieldLvl1) -> Builtin.Int16 {
sil [serialized] @multiple_level_all_single_field_struct_callee : $@convention(thin) (SingleFieldLvl1) -> Builtin.Int16 {
bb0(%0 : $SingleFieldLvl1):
  %1 = struct_extract %0 : $SingleFieldLvl1, #SingleFieldLvl1.s2
  %2 = struct_extract %1 : $SingleFieldLvl2, #SingleFieldLvl2.s3
  %3 = struct_extract %2 : $SingleFieldLvl3, #SingleFieldLvl3.s4
  return %3 : $Builtin.Int16
}

// CHECK-LABEL: sil [serialized] @multiple_level_all_single_field_struct_caller : $@convention(thin) (SingleFieldLvl1) -> Builtin.Int16 {
sil [serialized] @multiple_level_all_single_field_struct_caller : $@convention(thin) (SingleFieldLvl1) -> Builtin.Int16 {
bb0(%0 : $SingleFieldLvl1):
  %1 = function_ref @multiple_level_all_single_field_struct_callee : $@convention(thin) (SingleFieldLvl1) -> Builtin.Int16
  %2 = apply %1(%0) : $@convention(thin) (SingleFieldLvl1) -> Builtin.Int16
  return %2 : $Builtin.Int16
}

// Check Statements for generated code.



// CHECK-LABEL: sil shared [serialized] @$s21owned_struct_1_calleeTfq4dg_n : $@convention(thin) (@guaranteed S5) -> (Builtin.Int16, Builtin.Int32, Builtin.Int16, Builtin.Int32) {
// CHECK: bb0([[INPUT:%.*]] : $S5):
// CHECK: [[INPUTF2:%.*]] = struct_extract [[INPUT]] : $S5, #S5.f2
// CHECK: [[INPUTF2F1:%.*]] = struct_extract [[INPUTF2]] : $S1, #S1.f1
// CHECK: [[INPUTF2F2:%.*]] = struct_extract [[INPUTF2]] : $S1, #S1.f2
// CHECK: [[OUT:%.*]] = tuple ([[INPUTF2F1]] : $Builtin.Int16, [[INPUTF2F2]] : $Builtin.Int32, [[INPUTF2F1]] : $Builtin.Int16, [[INPUTF2F2]] : $Builtin.Int32)
// CHECK: return [[OUT]] : $(Builtin.Int16, Builtin.Int32, Builtin.Int16, Builtin.Int32)
// CHECK-LABEL: } // end sil function '$s21owned_struct_1_calleeTfq4dg_n'

// CHECK-LABEL: sil shared [serialized] @$s21owned_struct_2_calleeTfq4ndgXdn_n : $@convention(thin) (Builtin.Int256, @guaranteed S4, @guaranteed S4, Builtin.Int128) -> (Builtin.Int256, Builtin.Int256, Builtin.Int128, Builtin.Int128) {
// CHECK: bb0([[O1:%.*]] : $Builtin.Int256, [[INPUT1:%.*]] : $S4, [[INPUT2:%.*]] : $S4, [[O4:%.*]] : $Builtin.Int128):
// CHECK: [[FUNCTION:%.*]] = function_ref @s4_user_twice : $@convention(thin) (S4, S4) -> ()
// CHECK: apply [[FUNCTION]]([[INPUT1]], [[INPUT2]]) : $@convention(thin) (S4, S4) -> ()
// CHECK: [[RESULT:%.*]] = tuple ([[O1]] : $Builtin.Int256, [[O1]] : $Builtin.Int256, [[O4]] : $Builtin.Int128, [[O4]] : $Builtin.Int128)
// CHECK: return [[RESULT]] : $(Builtin.Int256, Builtin.Int256, Builtin.Int128, Builtin.Int128)
// CHECK-LABEL: } // end sil function '$s21owned_struct_2_calleeTfq4ndgXdn_n'


// CHECK-LABEL: sil shared [serialized] @$s18ignore_ptrs_calleeTfq4nxx_n : $@convention(thin) (@in S4Pair, S4, S4) -> (S4, S4) {
// CHECK: bb0([[POINTER:%.*]] : $*S4Pair, [[VALUE1:%.*]] : $S4, [[VALUE2:%.*]] : $S4):
// CHECK: [[FUNCTION:%.*]] = function_ref @s4_user : $@convention(thin) (S4) -> ()
// CHECK: [[POINTEE:%.*]] = load [[POINTER]] : $*S4Pair
// CHECK: [[VALUE:%.*]] = struct_extract [[POINTEE]] : $S4Pair, #S4Pair.f1
// CHECK: apply [[FUNCTION]]([[VALUE]]) : $@convention(thin) (S4) -> ()
// CHECK: [[OUT:%.*]] = tuple ([[VALUE1]] : $S4, [[VALUE2]] : $S4)
// CHECK: return [[OUT]] : $(S4, S4)
// CHECK-LABEL: } // end sil function '$s18ignore_ptrs_calleeTfq4nxx_n'

// CHECK-LABEL: sil shared [serialized] @$s30check_out_of_order_uses_calleeTfq4x_n : $@convention(thin) (S4, S4) -> () {
// CHECK: bb{{[0-9]+}}([[FIRST:%.*]] : $S4, [[SECOND:%.*]] : $S4):
// CHECK: [[TRIPLE:%.*]] = struct $S4Triple ([[FIRST]] : $S4, [[SECOND]] : $S4, undef : $S4)
// CHECK: [[UNUSED_SECOND:%.*]] = struct_extract [[TRIPLE]] : $S4Triple, #S4Triple.f2
// CHECK: [[FUNCTION:%.*]] = function_ref @s4_user : $@convention(thin) (S4) -> ()
// CHECK: apply [[FUNCTION]]([[IN2]]) : $@convention(thin) (S4) -> ()
// CHECK: [[UNUSED_FIRST:%.*]] = struct_extract [[TRIPLE]] : $S4Triple, #S4Triple.f1
// CHECK: apply [[FUNCTION]]([[IN1]]) : $@convention(thin) (S4) -> ()
// CHECK-LABEL: } // end sil function '$s30check_out_of_order_uses_calleeTfq4x_n'


// CHECK-LABEL: sil shared [serialized] @$s14class_callee_1Tfq4gn_n : $@convention(thin) (@guaranteed C1, Builtin.Int32) -> Builtin.Int32 {
// CHECK: bb0({{%.*}} : $C1, [[IN:%.*]] : $Builtin.Int32):
// CHECK: return [[IN]] : $Builtin.Int32