|
2 | 2 |
|
3 | 3 | ;; Check that exact casts are only added when custom descriptors are enabled.
|
4 | 4 |
|
5 |
| -;; RUN: wasm-opt %s -all --gufa-cast-all -S -o - | filecheck %s |
6 |
| -;; RUN: wasm-opt %s -all --disable-custom-descriptors --gufa-cast-all -S -o - | filecheck %s --check-prefix=NO_CD |
| 5 | +;; RUN: foreach %s %t wasm-opt -all --gufa-cast-all -S -o - \ |
| 6 | +;; RUN: | filecheck %s |
| 7 | + |
| 8 | +;; RUN: foreach %s %t wasm-opt -all --disable-custom-descriptors --gufa-cast-all -S -o - \ |
| 9 | +;; RUN: | filecheck %s --check-prefix=NO_CD |
7 | 10 |
|
8 | 11 | (module
|
9 | 12 | ;; CHECK: (type $foo (struct))
|
|
52 | 55 | )
|
53 | 56 | )
|
54 | 57 | )
|
| 58 | + |
| 59 | +(module |
| 60 | + ;; CHECK: (type $foo (struct)) |
| 61 | + ;; NO_CD: (type $foo (struct)) |
| 62 | + (type $foo (struct)) |
| 63 | + |
| 64 | + ;; CHECK: (import "" "a" (global $exact-a (ref (exact $foo)))) |
| 65 | + ;; NO_CD: (import "" "a" (global $exact-a (ref (exact $foo)))) |
| 66 | + (import "" "a" (global $exact-a (ref (exact $foo)))) |
| 67 | + ;; CHECK: (import "" "b" (global $exact-b (ref (exact $foo)))) |
| 68 | + ;; NO_CD: (import "" "b" (global $exact-b (ref (exact $foo)))) |
| 69 | + (import "" "b" (global $exact-b (ref (exact $foo)))) |
| 70 | + |
| 71 | + ;; CHECK: (global $g (mut (ref $foo)) (global.get $exact-a)) |
| 72 | + ;; NO_CD: (global $g (mut (ref $foo)) (global.get $exact-a)) |
| 73 | + (global $g (mut (ref $foo)) (global.get $exact-a)) |
| 74 | + |
| 75 | + ;; CHECK: (func $set (type $1) |
| 76 | + ;; CHECK-NEXT: (global.set $g |
| 77 | + ;; CHECK-NEXT: (global.get $exact-b) |
| 78 | + ;; CHECK-NEXT: ) |
| 79 | + ;; CHECK-NEXT: ) |
| 80 | + ;; NO_CD: (func $set (type $1) |
| 81 | + ;; NO_CD-NEXT: (global.set $g |
| 82 | + ;; NO_CD-NEXT: (global.get $exact-b) |
| 83 | + ;; NO_CD-NEXT: ) |
| 84 | + ;; NO_CD-NEXT: ) |
| 85 | + (func $set |
| 86 | + ;; $g can now hold two different exact $foo references. |
| 87 | + (global.set $g |
| 88 | + (global.get $exact-b) |
| 89 | + ) |
| 90 | + ) |
| 91 | + |
| 92 | + ;; CHECK: (func $get (type $2) (result (ref $foo)) |
| 93 | + ;; CHECK-NEXT: (ref.cast (ref (exact $foo)) |
| 94 | + ;; CHECK-NEXT: (ref.cast (ref (exact $foo)) |
| 95 | + ;; CHECK-NEXT: (global.get $g) |
| 96 | + ;; CHECK-NEXT: ) |
| 97 | + ;; CHECK-NEXT: ) |
| 98 | + ;; CHECK-NEXT: ) |
| 99 | + ;; NO_CD: (func $get (type $2) (result (ref $foo)) |
| 100 | + ;; NO_CD-NEXT: (ref.cast (ref $foo) |
| 101 | + ;; NO_CD-NEXT: (global.get $g) |
| 102 | + ;; NO_CD-NEXT: ) |
| 103 | + ;; NO_CD-NEXT: ) |
| 104 | + (func $get (result (ref $foo)) |
| 105 | + ;; We can only refine this cast target to be exact if custom descriptors are |
| 106 | + ;; allowed. |
| 107 | + (ref.cast (ref $foo) |
| 108 | + (global.get $g) |
| 109 | + ) |
| 110 | + ) |
| 111 | +) |
0 commit comments