|
12 | 12 | ;; CHECK: (func $throw-caught-all (type $0) |
13 | 13 | ;; CHECK-NEXT: (block $catch |
14 | 14 | ;; CHECK-NEXT: (try_table (catch_all $catch) |
15 | | - ;; CHECK-NEXT: (br $catch) |
| 15 | + ;; CHECK-NEXT: (nop) |
16 | 16 | ;; CHECK-NEXT: ) |
17 | 17 | ;; CHECK-NEXT: ) |
18 | 18 | ;; CHECK-NEXT: ) |
19 | 19 | (func $throw-caught-all |
20 | 20 | (block $catch |
21 | 21 | (try_table (catch_all $catch) |
22 | | - ;; This throw can be a br. |
| 22 | + ;; This throw can be a br. After that, it can also be removed, as we |
| 23 | + ;; flow to that block anyhow. |
| 24 | + (throw $e) |
| 25 | + ) |
| 26 | + ) |
| 27 | + ) |
| 28 | + |
| 29 | + ;; CHECK: (func $throw-caught-all-no-flow (type $0) |
| 30 | + ;; CHECK-NEXT: (block $catch |
| 31 | + ;; CHECK-NEXT: (try_table (catch_all $catch) |
| 32 | + ;; CHECK-NEXT: (br $catch) |
| 33 | + ;; CHECK-NEXT: ) |
| 34 | + ;; CHECK-NEXT: (unreachable) |
| 35 | + ;; CHECK-NEXT: ) |
| 36 | + ;; CHECK-NEXT: ) |
| 37 | + (func $throw-caught-all-no-flow |
| 38 | + (block $catch |
| 39 | + (try_table (catch_all $catch) |
23 | 40 | (throw $e) |
24 | 41 | ) |
| 42 | + ;; Block the flow, so that after the throw is optimized to a br, the br |
| 43 | + ;; remains. |
| 44 | + (unreachable) |
25 | 45 | ) |
26 | 46 | ) |
27 | 47 |
|
|
52 | 72 | ;; CHECK: (func $throw-caught-precise (type $0) |
53 | 73 | ;; CHECK-NEXT: (block $catch |
54 | 74 | ;; CHECK-NEXT: (try_table (catch $e $catch) |
55 | | - ;; CHECK-NEXT: (br $catch) |
| 75 | + ;; CHECK-NEXT: (nop) |
56 | 76 | ;; CHECK-NEXT: ) |
57 | 77 | ;; CHECK-NEXT: ) |
58 | 78 | ;; CHECK-NEXT: ) |
|
70 | 90 | ;; CHECK-NEXT: (block $fail |
71 | 91 | ;; CHECK-NEXT: (block $catch |
72 | 92 | ;; CHECK-NEXT: (try_table (catch $f $fail) (catch $e $catch) |
73 | | - ;; CHECK-NEXT: (br $catch) |
| 93 | + ;; CHECK-NEXT: (nop) |
74 | 94 | ;; CHECK-NEXT: ) |
75 | 95 | ;; CHECK-NEXT: ) |
76 | 96 | ;; CHECK-NEXT: (call $throw-caught-precise-later) |
|
94 | 114 | ;; CHECK-NEXT: (block $fail |
95 | 115 | ;; CHECK-NEXT: (block $catch |
96 | 116 | ;; CHECK-NEXT: (try_table (catch $f $fail) (catch_all $catch) |
97 | | - ;; CHECK-NEXT: (br $catch) |
| 117 | + ;; CHECK-NEXT: (nop) |
98 | 118 | ;; CHECK-NEXT: ) |
99 | 119 | ;; CHECK-NEXT: ) |
100 | 120 | ;; CHECK-NEXT: (call $throw-caught-precise-later) |
|
138 | 158 | ;; CHECK-NEXT: (br $catch) |
139 | 159 | ;; CHECK-NEXT: ) |
140 | 160 | ;; CHECK-NEXT: ) |
| 161 | + ;; CHECK-NEXT: (unreachable) |
141 | 162 | ;; CHECK-NEXT: ) |
142 | 163 | ;; CHECK-NEXT: (call $throw-caught-precise-later) |
143 | 164 | ;; CHECK-NEXT: ) |
|
151 | 172 | (throw $e) |
152 | 173 | ) |
153 | 174 | ) |
| 175 | + ;; Block the flow, so that the br above remains. |
| 176 | + (unreachable) |
154 | 177 | ) |
155 | 178 | ;; Add an effect here, so the two blocks are not mergeable. |
156 | 179 | (call $throw-caught-precise-later) |
|
195 | 218 | ;; CHECK-NEXT: (try_table (catch_ref $e $outer) (catch_all $catch) |
196 | 219 | ;; CHECK-NEXT: (throw $e) |
197 | 220 | ;; CHECK-NEXT: ) |
| 221 | + ;; CHECK-NEXT: (unreachable) |
198 | 222 | ;; CHECK-NEXT: ) |
199 | 223 | ;; CHECK-NEXT: (unreachable) |
200 | 224 | ;; CHECK-NEXT: ) |
|
207 | 231 | ;; not optimize. |
208 | 232 | (throw $e) |
209 | 233 | ) |
| 234 | + (unreachable) |
210 | 235 | ) |
211 | 236 | (unreachable) |
212 | 237 | ) |
|
220 | 245 | ;; CHECK-NEXT: (br $outer) |
221 | 246 | ;; CHECK-NEXT: (br $middle) |
222 | 247 | ;; CHECK-NEXT: (br $inner) |
| 248 | + ;; CHECK-NEXT: (unreachable) |
223 | 249 | ;; CHECK-NEXT: ) |
224 | 250 | ;; CHECK-NEXT: ) |
225 | 251 | ;; CHECK-NEXT: (call $throw-caught-precise-later) |
|
236 | 262 | (throw $e) |
237 | 263 | (throw $f) |
238 | 264 | (throw $g) |
| 265 | + ;; Prevent the br we optimize to at the end from getting optimized |
| 266 | + ;; out. |
| 267 | + (unreachable) |
239 | 268 | ) |
240 | 269 | ) |
241 | 270 | ;; Add an effect here, so the two blocks are not mergeable. |
|
338 | 367 | ) |
339 | 368 |
|
340 | 369 | (module |
341 | | - ;; CHECK: (import "a" "b" (func $effect (type $1) (result i32))) |
| 370 | + ;; CHECK: (import "a" "b" (func $effect (type $2) (result i32))) |
342 | 371 | (import "a" "b" (func $effect (result i32))) |
343 | 372 |
|
344 | 373 | ;; CHECK: (tag $e (param i32)) |
|
347 | 376 | ;; CHECK: (tag $multi (param i32 f64)) |
348 | 377 | (tag $multi (param i32 f64)) |
349 | 378 |
|
350 | | - ;; CHECK: (func $throw-caught-all (type $0) (param $x i32) |
| 379 | + ;; CHECK: (func $throw-caught-all (type $1) (param $x i32) |
351 | 380 | ;; CHECK-NEXT: (block $catch |
352 | 381 | ;; CHECK-NEXT: (try_table (catch_all $catch) |
353 | 382 | ;; CHECK-NEXT: (drop |
|
368 | 397 | ) |
369 | 398 | ) |
370 | 399 |
|
371 | | - ;; CHECK: (func $throw-br-contents (type $1) (result i32) |
| 400 | + ;; CHECK: (func $throw-br-contents (type $2) (result i32) |
372 | 401 | ;; CHECK-NEXT: (block $catch (result i32) |
373 | | - ;; CHECK-NEXT: (try_table (catch $e $catch) |
374 | | - ;; CHECK-NEXT: (br $catch |
375 | | - ;; CHECK-NEXT: (i32.const 42) |
376 | | - ;; CHECK-NEXT: ) |
| 402 | + ;; CHECK-NEXT: (try_table (result i32) (catch $e $catch) |
| 403 | + ;; CHECK-NEXT: (i32.const 42) |
377 | 404 | ;; CHECK-NEXT: ) |
378 | 405 | ;; CHECK-NEXT: ) |
379 | 406 | ;; CHECK-NEXT: ) |
380 | 407 | (func $throw-br-contents (result i32) |
381 | 408 | (block $catch (result i32) |
382 | 409 | (try_table (catch $e $catch) |
383 | 410 | ;; This throw is not caught by catch_all as above, so the value must be |
384 | | - ;; sent as a value on the br we optimize it to. |
| 411 | + ;; sent as a value on the br we optimize it to. That br can also be |
| 412 | + ;; optimized away by letting the value flow out. |
385 | 413 | (throw $e |
386 | 414 | (i32.const 42) |
387 | 415 | ) |
388 | 416 | ) |
389 | 417 | ) |
390 | 418 | ) |
391 | 419 |
|
392 | | - ;; CHECK: (func $throw-br-contents-multi (type $2) (result i32 f64) |
393 | | - ;; CHECK-NEXT: (block $catch (type $2) (result i32 f64) |
394 | | - ;; CHECK-NEXT: (try_table (catch $multi $catch) |
395 | | - ;; CHECK-NEXT: (br $catch |
396 | | - ;; CHECK-NEXT: (tuple.make 2 |
397 | | - ;; CHECK-NEXT: (i32.const 42) |
398 | | - ;; CHECK-NEXT: (f64.const 3.14159) |
399 | | - ;; CHECK-NEXT: ) |
| 420 | + ;; CHECK: (func $throw-br-contents-multi (type $0) (result i32 f64) |
| 421 | + ;; CHECK-NEXT: (block $catch (type $0) (result i32 f64) |
| 422 | + ;; CHECK-NEXT: (try_table (type $0) (result i32 f64) (catch $multi $catch) |
| 423 | + ;; CHECK-NEXT: (tuple.make 2 |
| 424 | + ;; CHECK-NEXT: (i32.const 42) |
| 425 | + ;; CHECK-NEXT: (f64.const 3.14159) |
400 | 426 | ;; CHECK-NEXT: ) |
401 | 427 | ;; CHECK-NEXT: ) |
402 | 428 | ;; CHECK-NEXT: ) |
|
0 commit comments