Skip to content

Commit 208fe0c

Browse files
committed
Add test case
1 parent 72d13a3 commit 208fe0c

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// RUN: %target-swift-frontend -enable-type-layout %s -emit-ir -sil-verify-all | %FileCheck %s
2+
// RUN: %target-swift-frontend -disable-type-layout %s -emit-ir -sil-verify-all | %FileCheck %s --check-prefix=NOTYPELAYOUT
3+
4+
sil_stage canonical
5+
import Builtin
6+
7+
public struct B<T> {
8+
var x: T
9+
var y: T
10+
}
11+
12+
public struct A<T> {
13+
var a : B<T>
14+
var b: B<T>
15+
}
16+
17+
public class C {}
18+
19+
// CHECK-LABEL: define{{.*}} void @testDestroyValueTrival(
20+
// CHECK-NEXT: entry:
21+
// CHECK-NEXT: ret void
22+
// CHECK-NEXT: }
23+
24+
sil @testDestroyValueTrival : $@convention(thin) (@in A<Builtin.Int32>) -> () {
25+
entry(%arg : $*A<Builtin.Int32>):
26+
destroy_addr %arg : $*A<Builtin.Int32>
27+
%ret = tuple ()
28+
return %ret : $()
29+
}
30+
31+
// CHECK-LABEL: define{{.*}} void @testValue(
32+
// CHECK: call %T32typelayout_based_value_operation1AVyAA1CCG* @"$s32typelayout_based_value_operation1AVyAA1CCGWOc"(
33+
// CHECK: call %T32typelayout_based_value_operation1AVyAA1CCG* @"$s32typelayout_based_value_operation1AVyAA1CCGWOh"(
34+
// CHECK: call %T32typelayout_based_value_operation1AVyAA1CCG* @"$s32typelayout_based_value_operation1AVyAA1CCGWOh"(
35+
// CHECK: }
36+
37+
// CHECK-LABEL: define{{.*}} %T32typelayout_based_value_operation1AVyAA1CCG* @"$s32typelayout_based_value_operation1AVyAA1CCGWOc"(
38+
// CHECK: call %swift.type* @__swift_instantiateConcreteTypeFromMangledName
39+
// CHECK: load
40+
// CHECK: call %swift.opaque* %{{.*}}(%swift.opaque* noalias {{.*}}, %swift.type* {{.*}})
41+
// CHECK: }
42+
43+
// CHECK-LABEL: define{{.*}} %T32typelayout_based_value_operation1AVyAA1CCG* @"$s32typelayout_based_value_operation1AVyAA1CCGWOh"(
44+
// CHECK: call %swift.type* @__swift_instantiateConcreteTypeFromMangledName
45+
// CHECK: load
46+
// CHECK: call void %{{.*}}(%swift.opaque* noalias {{.*}}, %swift.type* {{.*}})
47+
// CHECK: }
48+
49+
// NOTYPELAYOUT-LABEL: define{{.*}} %T32typelayout_based_value_operation1AVyAA1CCG* @"$s32typelayout_based_value_operation1AVyAA1CCGWOc"(
50+
// NOTYPELAYOUT: swift_retain
51+
// NOTYPELAYOUT: swift_retain
52+
// NOTYPELAYOUT: swift_retain
53+
// NOTYPELAYOUT: swift_retain
54+
// CHECK: }
55+
56+
// NOTYPELAYOUT-LABEL: define{{.*}} %T32typelayout_based_value_operation1AVyAA1CCG* @"$s32typelayout_based_value_operation1AVyAA1CCGWOh"(
57+
// NOTYPELAYOUT: swift_release
58+
// NOTYPELAYOUT: swift_release
59+
// NOTYPELAYOUT: swift_release
60+
// NOTYPELAYOUT: swift_release
61+
// CHECK: }
62+
63+
sil @testValue : $@convention(thin) (@in A<C>) -> () {
64+
entry(%arg : $*A<C>):
65+
%loc = alloc_stack $A<C>
66+
copy_addr %arg to [initialization] %loc : $*A<C>
67+
destroy_addr %arg : $*A<C>
68+
destroy_addr %loc : $*A<C>
69+
dealloc_stack %loc: $*A<C>
70+
%ret = tuple ()
71+
return %ret : $()
72+
}
73+
74+
sil_vtable C {}

0 commit comments

Comments
 (0)