blob: 1eab7b6af52a43cea2ff7626dcb7ecfc9271d323 (
plain)
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
|
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: foreach %s %t wasm-opt --signature-refining -all -S -o - | filecheck %s
(module
;; The signature should be refined to a single self-referential type.
;; CHECK: (type $refined (func (param (ref $refined)) (result (ref $refined))))
(type $refined (func (param (ref $refined)) (result (ref $refined))))
;; CHECK: (elem declare func $foo)
;; CHECK: (func $foo (type $refined) (param $0 (ref $refined)) (result (ref $refined))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (call $foo
;; CHECK-NEXT: (ref.func $foo)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (ref.func $foo)
;; CHECK-NEXT: )
(func $foo (param funcref) (result funcref)
(drop
(call $foo
(ref.func $foo)
)
)
(ref.func $foo)
)
)
(module
;; The signatures should be refined to a pair of mutually self-referential types.
;; CHECK: (rec
;; CHECK-NEXT: (type $1 (func (param f32 (ref $1)) (result (ref $0))))
;; CHECK: (type $0 (func (param i32 (ref $0)) (result (ref $1))))
(type $0 (func (param i32 funcref) (result funcref)))
(type $1 (func (param f32 funcref) (result funcref)))
;; CHECK: (elem declare func $bar $foo)
;; CHECK: (func $foo (type $0) (param $0 i32) (param $1 (ref $0)) (result (ref $1))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (call $foo
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (ref.func $foo)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (ref.func $bar)
;; CHECK-NEXT: )
(func $foo (type $0) (param i32 funcref) (result funcref)
(drop
(call $foo
(i32.const 0)
(ref.func $foo)
)
)
(ref.func $bar)
)
;; CHECK: (func $bar (type $1) (param $0 f32) (param $1 (ref $1)) (result (ref $0))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (call $bar
;; CHECK-NEXT: (f32.const 0)
;; CHECK-NEXT: (ref.func $bar)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (ref.func $foo)
;; CHECK-NEXT: )
(func $bar (type $1) (param f32 funcref) (result funcref)
(drop
(call $bar
(f32.const 0)
(ref.func $bar)
)
)
(ref.func $foo)
)
)
(module
;; The signatures start out as separate types, so they must remain separate
;; even though they are refined to the same structure.
(rec
;; CHECK: (rec
;; CHECK-NEXT: (type $1 (func (param (ref $0))))
;; CHECK: (type $0 (func (param (ref $0))))
(type $0 (func (param funcref)))
(type $1 (func (param funcref)))
)
;; CHECK: (elem declare func $foo)
;; CHECK: (func $foo (type $0) (param $0 (ref $0))
;; CHECK-NEXT: (call $foo
;; CHECK-NEXT: (ref.func $foo)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $foo (type $0) (param funcref)
(call $foo
(ref.func $foo)
)
)
;; CHECK: (func $bar (type $1) (param $0 (ref $0))
;; CHECK-NEXT: (call $bar
;; CHECK-NEXT: (ref.func $foo)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $bar (type $1) (param funcref)
(call $bar
(ref.func $foo)
)
)
)
(module
;; The signatures should be refined to a pair of mutually recursive types and
;; another type that refers to them.
;; CHECK: (rec
;; CHECK-NEXT: (type $2 (func (param (ref $0)) (result (ref $1))))
;; CHECK: (type $1 (func (param f32 (ref $1)) (result (ref $0))))
;; CHECK: (type $0 (func (param i32 (ref $0)) (result (ref $1))))
(type $0 (func (param i32 funcref) (result funcref)))
(type $1 (func (param f32 funcref) (result funcref)))
(type $2 (func (param funcref) (result funcref)))
;; CHECK: (elem declare func $bar $foo)
;; CHECK: (func $foo (type $0) (param $0 i32) (param $1 (ref $0)) (result (ref $1))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (call $foo
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (ref.func $foo)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (ref.func $bar)
;; CHECK-NEXT: )
(func $foo (param i32 funcref) (result funcref)
(drop
(call $foo
(i32.const 0)
(ref.func $foo)
)
)
(ref.func $bar)
)
;; CHECK: (func $baz (type $2) (param $0 (ref $0)) (result (ref $1))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (call $quux
;; CHECK-NEXT: (ref.func $foo)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (ref.func $bar)
;; CHECK-NEXT: )
(func $baz (param funcref) (result funcref)
(drop
(call $quux
(ref.func $foo)
)
)
(ref.func $bar)
)
;; CHECK: (func $bar (type $1) (param $0 f32) (param $1 (ref $1)) (result (ref $0))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (call $bar
;; CHECK-NEXT: (f32.const 0)
;; CHECK-NEXT: (ref.func $bar)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (ref.func $foo)
;; CHECK-NEXT: )
(func $bar (param f32 funcref) (result funcref)
(drop
(call $bar
(f32.const 0)
(ref.func $bar)
)
)
(ref.func $foo)
)
;; CHECK: (func $quux (type $2) (param $0 (ref $0)) (result (ref $1))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (call $baz
;; CHECK-NEXT: (ref.func $foo)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (ref.func $bar)
;; CHECK-NEXT: )
(func $quux (param funcref) (result funcref)
(drop
(call $baz
(ref.func $foo)
)
)
(ref.func $bar)
)
)
|