|
11 | 11 | (type $desc (describes $struct (struct)))
|
12 | 12 | )
|
13 | 13 |
|
14 |
| - ;; CHECK: (func $trap-null-desc (type $2) (result (ref (exact $struct))) |
| 14 | + (rec |
| 15 | + ;; CHECK: (rec |
| 16 | + ;; CHECK-NEXT: (type $struct-i32 (descriptor $struct-i32.desc (struct (field i32)))) |
| 17 | + (type $struct-i32 (descriptor $struct-i32.desc (struct (field i32)))) |
| 18 | + ;; CHECK: (type $struct-i32.desc (describes $struct-i32 (struct))) |
| 19 | + (type $struct-i32.desc (describes $struct-i32 (struct))) |
| 20 | + ) |
| 21 | + |
| 22 | + ;; CHECK: (import "" "" (func $effect (type $5))) |
| 23 | + (import "" "" (func $effect)) |
| 24 | + |
| 25 | + ;; CHECK: (func $trap-null-desc (type $4) (result (ref (exact $struct))) |
15 | 26 | ;; CHECK-NEXT: (unreachable)
|
16 | 27 | ;; CHECK-NEXT: )
|
17 | 28 | (func $trap-null-desc (result (ref (exact $struct)))
|
|
20 | 31 | )
|
21 | 32 | )
|
22 | 33 |
|
23 |
| - ;; CHECK: (func $trap-null-desc-fallthrough (type $2) (result (ref (exact $struct))) |
| 34 | + ;; CHECK: (func $trap-null-desc-fallthrough (type $4) (result (ref (exact $struct))) |
24 | 35 | ;; CHECK-NEXT: (local $desc (ref null (exact $desc)))
|
25 | 36 | ;; CHECK-NEXT: (drop
|
26 | 37 | ;; CHECK-NEXT: (local.tee $desc
|
|
38 | 49 | )
|
39 | 50 | )
|
40 | 51 |
|
41 |
| - ;; CHECK: (func $nonnull-cast-desc (type $3) (param $desc (ref null (exact $desc))) (result (ref (exact $struct))) |
| 52 | + ;; CHECK: (func $nonnull-cast-desc (type $6) (param $desc (ref null (exact $desc))) (result (ref (exact $struct))) |
42 | 53 | ;; CHECK-NEXT: (struct.new_default $struct
|
43 | 54 | ;; CHECK-NEXT: (local.get $desc)
|
44 | 55 | ;; CHECK-NEXT: )
|
|
50 | 61 | )
|
51 | 62 | )
|
52 | 63 | )
|
| 64 | + |
| 65 | + ;; Test that when we optimize a struct.new to a struct.new_default, we drop |
| 66 | + ;; the field operands but keep the descriptor. |
| 67 | + ;; CHECK: (func $new-default-keep-desc (type $7) (result anyref) |
| 68 | + ;; CHECK-NEXT: (struct.new_default $struct-i32 |
| 69 | + ;; CHECK-NEXT: (block (result (ref (exact $struct-i32.desc))) |
| 70 | + ;; CHECK-NEXT: (call $effect) |
| 71 | + ;; CHECK-NEXT: (struct.new_default $struct-i32.desc) |
| 72 | + ;; CHECK-NEXT: ) |
| 73 | + ;; CHECK-NEXT: ) |
| 74 | + ;; CHECK-NEXT: ) |
| 75 | + (func $new-default-keep-desc (result anyref) |
| 76 | + (struct.new $struct-i32 |
| 77 | + (i32.const 0) |
| 78 | + (block (result (ref (exact $struct-i32.desc))) |
| 79 | + ;; This would cause the descriptor to be dropped if it were dropped with |
| 80 | + ;; the other children. |
| 81 | + (call $effect) |
| 82 | + (struct.new_default $struct-i32.desc) |
| 83 | + ) |
| 84 | + ) |
| 85 | + ) |
53 | 86 | )
|
0 commit comments