|
1 | 1 | ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. |
2 | | -;; RUN: wasm-opt %s --all-features --closed-world --generate-global-effects --vacuum --type-merging --remove-unused-types -S -o - | filecheck %s --check-prefix VACUUM_FIRST |
3 | | -;; RUN: wasm-opt %s --all-features --closed-world --generate-global-effects --type-merging --remove-unused-types --vacuum -S -o - | filecheck %s --check-prefix MERGE_FIRST |
| 2 | +;; RUN: foreach %s %t wasm-opt --all-features --closed-world --generate-global-effects --vacuum --type-merging --remove-unused-types -S -o - | filecheck %s --check-prefix VACUUM_FIRST |
| 3 | +;; RUN: foreach %s %t wasm-opt --all-features --closed-world --generate-global-effects --type-merging --remove-unused-types --vacuum -S -o - | filecheck %s --check-prefix MERGE_FIRST |
4 | 4 |
|
5 | 5 | ;; Test that indirect call effects are preserved when types are rewritten |
6 | 6 | ;; globally. When we rewrite $effectful and $not-effectful into the same type, |
|
37 | 37 | (i32.const 0) |
38 | 38 | ) |
39 | 39 |
|
40 | | - ;; VACUUM_FIRST: (func $f (type $1) |
41 | | - ;; VACUUM_FIRST-NEXT: (nop) |
42 | | - ;; VACUUM_FIRST-NEXT: ) |
43 | | - ;; MERGE_FIRST: (func $f (type $1) |
44 | | - ;; MERGE_FIRST-NEXT: (nop) |
45 | | - ;; MERGE_FIRST-NEXT: ) |
46 | | - (func $f |
| 40 | + (func |
47 | 41 | ;; Reference the functions in a ref.func so that it's possible that they're |
48 | 42 | ;; the target of indirect calls. |
49 | 43 | (drop (ref.func $unreachable)) |
|
82 | 76 | ) |
83 | 77 | ) |
84 | 78 | ) |
| 79 | + |
| 80 | +(module |
| 81 | + (rec |
| 82 | + ;; VACUUM_FIRST: (type $nop-type (func)) |
| 83 | + ;; MERGE_FIRST: (type $nop-type (func)) |
| 84 | + (type $nop-type (func)) |
| 85 | + |
| 86 | + (type $effectful-type (func)) |
| 87 | + ) |
| 88 | + |
| 89 | + ;; VACUUM_FIRST: (type $import-type (func)) |
| 90 | + ;; MERGE_FIRST: (type $import-type (func)) |
| 91 | + (type $import-type (func)) |
| 92 | + |
| 93 | + ;; VACUUM_FIRST: (import "" "" (func $import (type $import-type))) |
| 94 | + ;; MERGE_FIRST: (import "" "" (func $import (type $import-type))) |
| 95 | + (import "" "" (func $import (type $import-type))) |
| 96 | + |
| 97 | + ;; VACUUM_FIRST: (func $nop (type $nop-type) |
| 98 | + ;; VACUUM_FIRST-NEXT: (nop) |
| 99 | + ;; VACUUM_FIRST-NEXT: ) |
| 100 | + ;; MERGE_FIRST: (func $nop (type $nop-type) |
| 101 | + ;; MERGE_FIRST-NEXT: (nop) |
| 102 | + ;; MERGE_FIRST-NEXT: ) |
| 103 | + (func $nop (type $nop-type) |
| 104 | + (nop) |
| 105 | + ) |
| 106 | + |
| 107 | + ;; VACUUM_FIRST: (func $effectful (type $nop-type) |
| 108 | + ;; VACUUM_FIRST-NEXT: (call $import) |
| 109 | + ;; VACUUM_FIRST-NEXT: ) |
| 110 | + ;; MERGE_FIRST: (func $effectful (type $nop-type) |
| 111 | + ;; MERGE_FIRST-NEXT: (call $import) |
| 112 | + ;; MERGE_FIRST-NEXT: ) |
| 113 | + (func $effectful (type $effectful-type) |
| 114 | + ;; We need an extra indirection here for the test. |
| 115 | + ;; If we give $import the type $effectful-type directly, the type will be |
| 116 | + ;; public and --type-merging won't optimize it. |
| 117 | + (call $import) |
| 118 | + ) |
| 119 | + |
| 120 | + (func |
| 121 | + (drop (ref.func $nop)) |
| 122 | + (drop (ref.func $effectful)) |
| 123 | + ) |
| 124 | + |
| 125 | + ;; VACUUM_FIRST: (func $calls-effectful-type (type $0) (param $ref (ref $nop-type)) |
| 126 | + ;; VACUUM_FIRST-NEXT: (call_ref $nop-type |
| 127 | + ;; VACUUM_FIRST-NEXT: (local.get $ref) |
| 128 | + ;; VACUUM_FIRST-NEXT: ) |
| 129 | + ;; VACUUM_FIRST-NEXT: ) |
| 130 | + ;; MERGE_FIRST: (func $calls-effectful-type (type $0) (param $ref (ref $nop-type)) |
| 131 | + ;; MERGE_FIRST-NEXT: (call_ref $nop-type |
| 132 | + ;; MERGE_FIRST-NEXT: (local.get $ref) |
| 133 | + ;; MERGE_FIRST-NEXT: ) |
| 134 | + ;; MERGE_FIRST-NEXT: ) |
| 135 | + (func $calls-effectful-type (param $ref (ref $effectful-type)) |
| 136 | + ;; See #8831. Test that effects are preserved after type merging even for |
| 137 | + ;; 'unknown' effects that are represented with a missing entry in the |
| 138 | + ;; `indirectCallEffects` map. |
| 139 | + (call_ref $effectful-type |
| 140 | + (local.get $ref) |
| 141 | + ) |
| 142 | + ) |
| 143 | +) |
0 commit comments