summaryrefslogtreecommitdiff
path: root/test/lit/subtype-chain.wast
blob: ef6eacd66f41ab81acd0970bacd5ada12d828259 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
;; RUN: wasm-opt %s -all -S -o - | filecheck %s
;; RUN: wasm-opt %s -all --roundtrip -S -o - | filecheck %s

;; Check that intermediate types in subtype chains are also included in the
;; output module, even if there are no other references to those intermediate
;; types.

(module
  ;; CHECK:      (type $root (sub (struct)))
  (type $root (sub (struct)))

  ;; CHECK:      (type $trunk (sub $root (struct (field i32))))
  (type $trunk (sub $root (struct i32)))

  ;; CHECK:      (type $branch (sub $trunk (struct (field i32) (field i64))))
  (type $branch (sub $trunk (struct i32 i64)))

  ;; CHECK:      (type $twig (sub $branch (struct (field i32) (field i64) (field f32))))
  (type $twig (sub $branch (struct i32 i64 f32)))

  ;; CHECK:      (type $leaf (sub $twig (struct (field i32) (field i64) (field f32) (field f64))))
  (type $leaf (sub $twig (struct i32 i64 f32 f64)))

  ;; CHECK:      (func $make-root (type $5) (param $leaf (ref $leaf)) (result (ref null $root))
  ;; CHECK-NEXT:  (local.get $leaf)
  ;; CHECK-NEXT: )
  (func $make-root (param $leaf (ref $leaf)) (result (ref null $root))
    (local.get $leaf)
  )
)