|
6 | 6 | (rec
|
7 | 7 | ;; CHECK: (rec
|
8 | 8 | ;; CHECK-NEXT: (type $struct (descriptor $desc (struct (field (mut i32)))))
|
9 |
| - (type $struct (sub final (descriptor $desc (struct (field (mut i32)))))) |
10 |
| - ;; CHECK: (type $desc (sub (describes $struct (struct)))) |
11 |
| - (type $desc (sub (describes $struct (struct)))) |
| 9 | + (type $struct (descriptor $desc (struct (field (mut i32))))) |
| 10 | + ;; CHECK: (type $desc (describes $struct (descriptor $meta (struct)))) |
| 11 | + (type $desc (describes $struct (descriptor $meta (struct)))) |
| 12 | + ;; CHECK: (type $meta (describes $desc (struct))) |
| 13 | + (type $meta (describes $desc (struct))) |
12 | 14 | )
|
13 | 15 |
|
14 |
| - ;; CHECK: (import "" "" (func $effect (type $2))) |
| 16 | + ;; CHECK: (import "" "" (func $effect (type $3))) |
15 | 17 | (import "" "" (func $effect))
|
16 | 18 |
|
17 |
| - ;; CHECK: (func $no-reorder (type $2) |
| 19 | + ;; CHECK: (func $no-reorder (type $3) |
18 | 20 | ;; CHECK-NEXT: (local $struct (ref $struct))
|
19 | 21 | ;; CHECK-NEXT: (local.set $struct
|
20 | 22 | ;; CHECK-NEXT: (struct.new_default $struct
|
|
47 | 49 | )
|
48 | 50 | )
|
49 | 51 |
|
50 |
| - ;; CHECK: (func $yes-reorder (type $2) |
| 52 | + ;; CHECK: (func $no-reorder-nested (type $3) |
| 53 | + ;; CHECK-NEXT: (local $struct (ref $struct)) |
| 54 | + ;; CHECK-NEXT: (local.set $struct |
| 55 | + ;; CHECK-NEXT: (struct.new_default $struct |
| 56 | + ;; CHECK-NEXT: (struct.new_default $desc |
| 57 | + ;; CHECK-NEXT: (ref.null none) |
| 58 | + ;; CHECK-NEXT: ) |
| 59 | + ;; CHECK-NEXT: ) |
| 60 | + ;; CHECK-NEXT: ) |
| 61 | + ;; CHECK-NEXT: (struct.set $struct 0 |
| 62 | + ;; CHECK-NEXT: (local.get $struct) |
| 63 | + ;; CHECK-NEXT: (block $block (result i32) |
| 64 | + ;; CHECK-NEXT: (call $effect) |
| 65 | + ;; CHECK-NEXT: (i32.const 0) |
| 66 | + ;; CHECK-NEXT: ) |
| 67 | + ;; CHECK-NEXT: ) |
| 68 | + ;; CHECK-NEXT: ) |
| 69 | + (func $no-reorder-nested |
| 70 | + (local $struct (ref $struct)) |
| 71 | + ;; As above, but now it is not the top-level allocation that traps, but |
| 72 | + ;; rather its descriptor operand. We still cannot optimize. |
| 73 | + (local.set $struct |
| 74 | + (struct.new_default $struct |
| 75 | + (struct.new $desc |
| 76 | + (ref.null none) |
| 77 | + ) |
| 78 | + ) |
| 79 | + ) |
| 80 | + (struct.set $struct 0 |
| 81 | + (local.get $struct) |
| 82 | + (block $block (result i32) |
| 83 | + (call $effect) |
| 84 | + (i32.const 0) |
| 85 | + ) |
| 86 | + ) |
| 87 | + ) |
| 88 | + |
| 89 | + ;; CHECK: (func $yes-reorder (type $3) |
51 | 90 | ;; CHECK-NEXT: (local $struct (ref $struct))
|
52 | 91 | ;; CHECK-NEXT: (local.set $struct
|
53 | 92 | ;; CHECK-NEXT: (struct.new $struct
|
54 | 93 | ;; CHECK-NEXT: (block $block (result i32)
|
55 | 94 | ;; CHECK-NEXT: (call $effect)
|
56 | 95 | ;; CHECK-NEXT: (i32.const 0)
|
57 | 96 | ;; CHECK-NEXT: )
|
58 |
| - ;; CHECK-NEXT: (struct.new_default $desc) |
| 97 | + ;; CHECK-NEXT: (struct.new_default $desc |
| 98 | + ;; CHECK-NEXT: (struct.new_default $meta) |
| 99 | + ;; CHECK-NEXT: ) |
59 | 100 | ;; CHECK-NEXT: )
|
60 | 101 | ;; CHECK-NEXT: )
|
61 | 102 | ;; CHECK-NEXT: (nop)
|
62 | 103 | ;; CHECK-NEXT: )
|
63 | 104 | (func $yes-reorder
|
64 | 105 | (local $struct (ref $struct))
|
65 |
| - ;; As above, but now the descriptor does not trap, so we optimize. |
| 106 | + ;; Nothing traps, so we can reorder. |
66 | 107 | (local.set $struct
|
67 | 108 | (struct.new_default $struct
|
68 |
| - (struct.new $desc) |
| 109 | + (struct.new $desc |
| 110 | + (struct.new $meta) |
| 111 | + ) |
69 | 112 | )
|
70 | 113 | )
|
71 | 114 | (struct.set $struct 0
|
|
0 commit comments