@@ -579,3 +579,97 @@ bb0:
579
579
%2 = tuple()
580
580
return %2 : $()
581
581
}
582
+
583
+ struct TwoInts {
584
+ var a: Int
585
+ var b: Int
586
+ }
587
+
588
+ struct StructWithOptional {
589
+ var i: Optional<TwoInts>
590
+ }
591
+
592
+ // CHECK-LABEL: @init_enum_data_addr
593
+ // CHECK: PAIR #3.
594
+ // CHECK-NEXT: %0 = argument of bb0 : $*StructWithOptional
595
+ // CHECK-NEXT: %3 = init_enum_data_addr %2 : $*Optional<TwoInts>, #Optional.some!enumelt
596
+ // CHECK-NEXT: NoAlias
597
+ // CHECK: PAIR #4.
598
+ // CHECK-NEXT: %0 = argument of bb0 : $*StructWithOptional
599
+ // CHECK-NEXT: %4 = struct_element_addr %3 : $*TwoInts, #TwoInts.a
600
+ // CHECK-NEXT: NoAlias
601
+ // CHECK: PAIR #5.
602
+ // CHECK-NEXT: %0 = argument of bb0 : $*StructWithOptional
603
+ // CHECK-NEXT: %5 = struct_element_addr %3 : $*TwoInts, #TwoInts.b
604
+ // CHECK-NEXT: NoAlias
605
+ // CHECK: PAIR #14.
606
+ // CHECK-NEXT: %2 = struct_element_addr %1 : $*StructWithOptional, #StructWithOptional.i
607
+ // CHECK-NEXT: %3 = init_enum_data_addr %2 : $*Optional<TwoInts>, #Optional.some!enumelt
608
+ // CHECK-NEXT: MayAlias
609
+ // CHECK: PAIR #15.
610
+ // CHECK-NEXT: %2 = struct_element_addr %1 : $*StructWithOptional, #StructWithOptional.i
611
+ // CHECK-NEXT: %4 = struct_element_addr %3 : $*TwoInts, #TwoInts.a
612
+ // CHECK-NEXT: MayAlias
613
+ // CHECK: PAIR #16.
614
+ // CHECK-NEXT: %2 = struct_element_addr %1 : $*StructWithOptional, #StructWithOptional.i
615
+ // CHECK-NEXT: %5 = struct_element_addr %3 : $*TwoInts, #TwoInts.b
616
+ // CHECK-NEXT: MayAlias
617
+ // CHECK: PAIR #19.
618
+ // CHECK-NEXT: %3 = init_enum_data_addr %2 : $*Optional<TwoInts>, #Optional.some!enumelt
619
+ // CHECK-NEXT: %4 = struct_element_addr %3 : $*TwoInts, #TwoInts.a
620
+ // CHECK-NEXT: PartialAlias
621
+ // CHECK: PAIR #20.
622
+ // CHECK-NEXT: %3 = init_enum_data_addr %2 : $*Optional<TwoInts>, #Optional.some!enumelt
623
+ // CHECK-NEXT: %5 = struct_element_addr %3 : $*TwoInts, #TwoInts.b
624
+ // CHECK-NEXT: PartialAlias
625
+ // CHECK: PAIR #23.
626
+ // CHECK-NEXT: %4 = struct_element_addr %3 : $*TwoInts, #TwoInts.a
627
+ // CHECK-NEXT: %5 = struct_element_addr %3 : $*TwoInts, #TwoInts.b
628
+ // CHECK-NEXT: NoAlias
629
+ sil @init_enum_data_addr : $@convention(thin) (@in_guaranteed StructWithOptional) -> () {
630
+ bb0(%0 : $*StructWithOptional):
631
+ %1 = alloc_stack $StructWithOptional
632
+ %2 = struct_element_addr %1 : $*StructWithOptional, #StructWithOptional.i
633
+ %3 = init_enum_data_addr %2 : $*Optional<TwoInts>, #Optional.some!enumelt
634
+ %4 = struct_element_addr %3 : $*TwoInts, #TwoInts.a
635
+ %5 = struct_element_addr %3 : $*TwoInts, #TwoInts.b
636
+ dealloc_stack %1 : $*StructWithOptional
637
+ %6 = tuple ()
638
+ return %6 : $()
639
+ }
640
+
641
+ protocol P {}
642
+
643
+ struct S : P {
644
+ var i: Int
645
+ }
646
+
647
+ // CHECK-LABEL: @init_existential_addr
648
+ // CHECK: PAIR #3.
649
+ // CHECK-NEXT: %0 = argument of bb0 : $P
650
+ // CHECK-NEXT: %3 = init_existential_addr %2 : $*P, $S
651
+ // CHECK-NEXT: NoAlias
652
+ // CHECK: PAIR #12.
653
+ // CHECK-NEXT: %2 = alloc_stack $P
654
+ // CHECK-NEXT: %3 = init_existential_addr %2 : $*P, $S
655
+ // CHECK-NEXT: MayAlias
656
+ // CHECK: PAIR #13.
657
+ // CHECK-NEXT: %2 = alloc_stack $P
658
+ // CHECK-NEXT: %4 = struct_element_addr %3 : $*S, #S.i
659
+ // CHECK-NEXT: MayAlias
660
+ // CHECK: PAIR #16.
661
+ // CHECK-NEXT: %3 = init_existential_addr %2 : $*P, $S
662
+ // CHECK-NEXT: %4 = struct_element_addr %3 : $*S, #S.i
663
+ // CHECK-NEXT: PartialAlias
664
+ sil @init_existential_addr : $@convention(thin) (P) -> () {
665
+ bb0(%0 : $P):
666
+ %1 = alloc_stack $S
667
+ %2 = alloc_stack $P
668
+ %3 = init_existential_addr %2 : $*P, $S
669
+ %4 = struct_element_addr %3 : $*S, #S.i
670
+ dealloc_stack %2 : $*P
671
+ dealloc_stack %1 : $*S
672
+ %6 = tuple ()
673
+ return %6 : $()
674
+ }
675
+
0 commit comments