|
| 1 | +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. |
| 2 | +;; RUN: foreach %s %t wasm-opt -all --closed-world --preserve-type-order \ |
| 3 | +;; RUN: --unsubtyping --remove-unused-types -all -S -o - | filecheck %s |
| 4 | + |
| 5 | +(module |
| 6 | + (rec |
| 7 | + ;; CHECK: (rec |
| 8 | + ;; CHECK-NEXT: (type $A (sub (descriptor $A.desc (struct)))) |
| 9 | + (type $A (sub (descriptor $A.desc (struct)))) |
| 10 | + ;; CHECK: (type $A.desc (sub (describes $A (struct)))) |
| 11 | + (type $A.desc (sub (describes $A (struct)))) |
| 12 | + ;; CHECK: (type $B (sub (descriptor $B.desc (struct)))) |
| 13 | + (type $B (sub $A (descriptor $B.desc (struct)))) |
| 14 | + ;; CHECK: (type $B.desc (sub (describes $B (struct)))) |
| 15 | + (type $B.desc (sub $A.desc (describes $B (struct)))) |
| 16 | + ) |
| 17 | + |
| 18 | + ;; There is nothing requiring the subtype relationship, so we should optimize. |
| 19 | + ;; CHECK: (global $A (ref null $A) (ref.null none)) |
| 20 | + (global $A (ref null $A) (ref.null none)) |
| 21 | + ;; CHECK: (global $B (ref null $B) (ref.null none)) |
| 22 | + (global $B (ref null $B) (ref.null none)) |
| 23 | +) |
| 24 | + |
| 25 | +(module |
| 26 | + (rec |
| 27 | + ;; CHECK: (rec |
| 28 | + ;; CHECK-NEXT: (type $A (sub (descriptor $A.desc (struct)))) |
| 29 | + (type $A (sub (descriptor $A.desc (struct)))) |
| 30 | + ;; CHECK: (type $A.desc (sub (describes $A (struct)))) |
| 31 | + (type $A.desc (sub (describes $A (struct)))) |
| 32 | + ;; CHECK: (type $B (sub $A (descriptor $B.desc (struct)))) |
| 33 | + (type $B (sub $A (descriptor $B.desc (struct)))) |
| 34 | + ;; CHECK: (type $B.desc (sub $A.desc (describes $B (struct)))) |
| 35 | + (type $B.desc (sub $A.desc (describes $B (struct)))) |
| 36 | + ) |
| 37 | + |
| 38 | + ;; Now we require B <: A, which implies B.desc <: A.desc. |
| 39 | + ;; CHECK: (global $B (ref null $B) (ref.null none)) |
| 40 | + (global $B (ref null $B) (ref.null none)) |
| 41 | + ;; CHECK: (global $A (ref null $A) (global.get $B)) |
| 42 | + (global $A (ref null $A) (global.get $B)) |
| 43 | +) |
| 44 | + |
| 45 | +(module |
| 46 | + (rec |
| 47 | + ;; CHECK: (rec |
| 48 | + ;; CHECK-NEXT: (type $A (sub (descriptor $A.desc (struct)))) |
| 49 | + (type $A (sub (descriptor $A.desc (struct)))) |
| 50 | + ;; CHECK: (type $A.desc (sub (describes $A (struct)))) |
| 51 | + (type $A.desc (sub (describes $A (struct)))) |
| 52 | + ;; CHECK: (type $B (sub (descriptor $B.desc (struct)))) |
| 53 | + (type $B (sub $A (descriptor $B.desc (struct)))) |
| 54 | + ;; CHECK: (type $B.desc (sub $A.desc (describes $B (struct)))) |
| 55 | + (type $B.desc (sub $A.desc (describes $B (struct)))) |
| 56 | + ) |
| 57 | + |
| 58 | + ;; Now we directly require B.desc <: A.desc. This does *not* imply B <: A, so |
| 59 | + ;; we can optimize $B (but not $B.desc). |
| 60 | + ;; CHECK: (global $B.desc (ref null $B.desc) (ref.null none)) |
| 61 | + (global $B.desc (ref null $B.desc) (ref.null none)) |
| 62 | + ;; CHECK: (global $A.desc (ref null $A.desc) (global.get $B.desc)) |
| 63 | + (global $A.desc (ref null $A.desc) (global.get $B.desc)) |
| 64 | +) |
0 commit comments