1
1
// Round-trip parsing/printing test.
2
2
3
- // RUN: %target-sil-opt %s | %target-sil-opt | %FileCheck --check-prefix=ROUNDTRIP %s
3
+ // RUN: %target-sil-opt %s | %target-sil-opt -emit-sorted-sil | %FileCheck --check-prefix=ROUNDTRIP %s
4
4
5
5
// Round-trip serialization-deserialization test.
6
6
7
7
// RUN: %empty-directory(%t)
8
8
// RUN: %target-sil-opt %s -emit-sib -o %t/tmp.sib -module-name main
9
9
// RUN: %target-sil-opt %t/tmp.sib -o %t/tmp.2.sib -module-name main
10
- // RUN: %target-sil-opt %t/tmp.2.sib -module-name main | %FileCheck --check-prefix=ROUNDTRIP %s
10
+ // RUN: %target-sil-opt %t/tmp.2.sib -module-name main -emit-sorted-sil | %FileCheck --check-prefix=ROUNDTRIP %s
11
11
12
12
// IRGen test.
13
13
@@ -19,6 +19,71 @@ import Builtin
19
19
import Swift
20
20
import SwiftShims
21
21
22
+ // Test SIL differentiability witness for bodiless original function, with defined jvp/vjp.
23
+
24
+ sil @externalFn1 : $@convention(thin) (Float) -> Float
25
+
26
+ sil @AD__externalFn1__jvp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float) {
27
+ bb0(%0 : $Float):
28
+ return undef : $(Float, @callee_guaranteed (Float) -> Float)
29
+ }
30
+
31
+ sil @AD__externalFn1__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float) {
32
+ bb0(%0 : $Float):
33
+ return undef : $(Float, @callee_guaranteed (Float) -> Float)
34
+ }
35
+
36
+ sil_differentiability_witness [parameters 0] [results 0] @externalFn1 : $@convention(thin) (Float) -> Float {
37
+ jvp: @AD__externalFn1__jvp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
38
+ vjp: @AD__externalFn1__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
39
+ }
40
+
41
+ // ROUNDTRIP-LABEL: // differentiability witness for externalFn1
42
+ // ROUNDTRIP: sil_differentiability_witness [parameters 0] [results 0] @externalFn1 : $@convention(thin) (Float) -> Float {
43
+ // ROUNDTRIP: jvp: @AD__externalFn1__jvp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
44
+ // ROUNDTRIP: vjp: @AD__externalFn1__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
45
+ // ROUNDTRIP: }
46
+
47
+ // IRGEN-LABEL: @AD__externalFn1_PSRS ={{( protected)?}} global { i8*, i8* } {
48
+ // IRGEN-SAME: @AD__externalFn1__jvp_src_0_wrt_0
49
+ // IRGEN-SAME: @AD__externalFn1__vjp_src_0_wrt_0
50
+ // IRGEN-SAME: }
51
+
52
+ // Test SIL differentiability witness for bodiless original function, with bodiless jvp/vjp.
53
+
54
+ sil @externalFn2 : $@convention(thin) (Float) -> Float
55
+
56
+ sil @AD__externalFn2__jvp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
57
+
58
+ sil @AD__externalFn2__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
59
+
60
+ sil_differentiability_witness [parameters 0] [results 0] @externalFn2 : $@convention(thin) (Float) -> Float {
61
+ jvp: @AD__externalFn2__jvp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
62
+ vjp: @AD__externalFn2__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
63
+ }
64
+
65
+ // ROUNDTRIP-LABEL: // differentiability witness for externalFn2
66
+ // ROUNDTRIP: sil_differentiability_witness [parameters 0] [results 0] @externalFn2 : $@convention(thin) (Float) -> Float {
67
+ // ROUNDTRIP: jvp: @AD__externalFn2__jvp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
68
+ // ROUNDTRIP: vjp: @AD__externalFn2__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
69
+ // ROUNDTRIP: }
70
+
71
+ // IRGEN-LABEL: @AD__externalFn2_PSRS ={{( protected)?}} global { i8*, i8* } {
72
+ // IRGEN-SAME: @AD__externalFn2__jvp_src_0_wrt_0
73
+ // IRGEN-SAME: @AD__externalFn2__vjp_src_0_wrt_0
74
+ // IRGEN-SAME: }
75
+
76
+ // Test SIL differentiability witness declaration.
77
+
78
+ sil @externalFn3 : $@convention(thin) (Float) -> Float
79
+
80
+ sil_differentiability_witness [parameters 0] [results 0] @externalFn3 : $@convention(thin) (Float) -> Float
81
+
82
+ // ROUNDTRIP-LABEL: // differentiability witness for externalFn3
83
+ // ROUNDTRIP: sil_differentiability_witness [parameters 0] [results 0] @externalFn3 : $@convention(thin) (Float) -> Float{{[^{]*$}}
84
+
85
+ // IRGEN-NOT: @AD__externalFn3{{.*}}={{.*}}{ i8*, i8* }
86
+
22
87
// Test public non-generic function.
23
88
// SIL differentiability witness:
24
89
// - Has public linkage (implicit).
@@ -92,68 +157,3 @@ sil_differentiability_witness hidden [parameters 0 1] [results 0] <τ_0_0 where
92
157
// IRGEN-SAME: @AD__generic__jvp_src_0_wrt_0_1
93
158
// IRGEN-SAME: @AD__generic__vjp_src_0_wrt_0_1
94
159
// IRGEN-SAME: }
95
-
96
- // Test SIL differentiability witness for bodiless original function, with defined jvp/vjp.
97
-
98
- sil @externalFn1 : $@convention(thin) (Float) -> Float
99
-
100
- sil @AD__externalFn1__jvp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float) {
101
- bb0(%0 : $Float):
102
- return undef : $(Float, @callee_guaranteed (Float) -> Float)
103
- }
104
-
105
- sil @AD__externalFn1__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float) {
106
- bb0(%0 : $Float):
107
- return undef : $(Float, @callee_guaranteed (Float) -> Float)
108
- }
109
-
110
- sil_differentiability_witness [parameters 0] [results 0] @externalFn1 : $@convention(thin) (Float) -> Float {
111
- jvp: @AD__externalFn1__jvp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
112
- vjp: @AD__externalFn1__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
113
- }
114
-
115
- // ROUNDTRIP-LABEL: // differentiability witness for externalFn1
116
- // ROUNDTRIP: sil_differentiability_witness [parameters 0] [results 0] @externalFn1 : $@convention(thin) (Float) -> Float {
117
- // ROUNDTRIP: jvp: @AD__externalFn1__jvp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
118
- // ROUNDTRIP: vjp: @AD__externalFn1__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
119
- // ROUNDTRIP: }
120
-
121
- // IRGEN-LABEL: @AD__externalFn1_PSRS ={{( protected)?}} global { i8*, i8* } {
122
- // IRGEN-SAME: @AD__externalFn1__jvp_src_0_wrt_0
123
- // IRGEN-SAME: @AD__externalFn1__vjp_src_0_wrt_0
124
- // IRGEN-SAME: }
125
-
126
- // Test SIL differentiability witness for bodiless original function, with bodiless jvp/vjp.
127
-
128
- sil @externalFn2 : $@convention(thin) (Float) -> Float
129
-
130
- sil @AD__externalFn2__jvp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
131
-
132
- sil @AD__externalFn2__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
133
-
134
- sil_differentiability_witness [parameters 0] [results 0] @externalFn2 : $@convention(thin) (Float) -> Float {
135
- jvp: @AD__externalFn2__jvp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
136
- vjp: @AD__externalFn2__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
137
- }
138
-
139
- // ROUNDTRIP-LABEL: // differentiability witness for externalFn2
140
- // ROUNDTRIP: sil_differentiability_witness [parameters 0] [results 0] @externalFn2 : $@convention(thin) (Float) -> Float {
141
- // ROUNDTRIP: jvp: @AD__externalFn2__jvp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
142
- // ROUNDTRIP: vjp: @AD__externalFn2__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
143
- // ROUNDTRIP: }
144
-
145
- // IRGEN-LABEL: @AD__externalFn2_PSRS ={{( protected)?}} global { i8*, i8* } {
146
- // IRGEN-SAME: @AD__externalFn2__jvp_src_0_wrt_0
147
- // IRGEN-SAME: @AD__externalFn2__vjp_src_0_wrt_0
148
- // IRGEN-SAME: }
149
-
150
- // Test SIL differentiability witness declaration.
151
-
152
- sil @externalFn3 : $@convention(thin) (Float) -> Float
153
-
154
- sil_differentiability_witness [parameters 0] [results 0] @externalFn3 : $@convention(thin) (Float) -> Float
155
-
156
- // ROUNDTRIP-LABEL: // differentiability witness for externalFn3
157
- // ROUNDTRIP: sil_differentiability_witness [parameters 0] [results 0] @externalFn3 : $@convention(thin) (Float) -> Float{{[^{]*$}}
158
-
159
- // IRGEN-NOT: @AD__externalFn3{{.*}}={{.*}}{ i8*, i8* }
0 commit comments