;; 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 -g -S -o - | filecheck %s --check-prefix=RTRIP
(module
(rec
;; CHECK: (rec
;; CHECK-NEXT: (type $f1 (func (result (ref $f1) (ref $f2))))
;; RTRIP: (rec
;; RTRIP-NEXT: (type $f1 (func (result (ref $f1) (ref $f2))))
(type $f1 (func (result (ref $f1) (ref $f2))))
;; CHECK: (type $f2 (func (result (ref $f2) (ref $f1))))
;; RTRIP: (type $f2 (func (result (ref $f2) (ref $f1))))
(type $f2 (func (result (ref $f2) (ref $f1))))
)
;; These types will be optimized out.
(type $block1 (func (result (ref $f1) (ref $f2))))
(type $block2 (func (result (ref $f2) (ref $f1))))
;; CHECK: (func $f1 (type $f1) (result (ref $f1) (ref $f2))
;; CHECK-NEXT: (loop $l (type $f1) (result (ref $f1) (ref $f2))
;; CHECK-NEXT: (call $f1)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; RTRIP: (func $f1 (type $f1) (result (ref $f1) (ref $f2))
;; RTRIP-NEXT: (loop $l (type $f1) (result (ref $f1) (ref $f2))
;; RTRIP-NEXT: (call $f1)
;; RTRIP-NEXT: )
;; RTRIP-NEXT: )
(func $f1 (type $f1) (result (ref $f1) (ref $f2))
;; This block will be emitted with type $f1
(loop $l (type $block1) (result (ref $f1) (ref $f2))
(call $f1)
)
)
;; CHECK: (func $f2 (type $f2) (result (ref $f2) (ref $f1))
;; CHECK-NEXT: (loop $block (type $f2) (result (ref $f2) (ref $f1))
;; CHECK-NEXT: (br $block)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; RTRIP: (func $f2 (type $f2) (result (ref $f2) (ref $f1))
;; RTRIP-NEXT: (loop $block (type $f2) (result (ref $f2) (ref $f1))
;; RTRIP-NEXT: (br $block)
;; RTRIP-NEXT: )
;; RTRIP-NEXT: )
(func $f2 (type $f2) (result (ref $f2) (ref $f1))
;; This block will be emitted with type $f2
(loop $block (type $block2) (result (ref $f2) (ref $f1))
(br $block)
)
)
;; CHECK: (func $f3 (type $2) (result i32)
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; RTRIP: (func $f3 (type $2) (result i32)
;; RTRIP-NEXT: (i32.const 0)
;; RTRIP-NEXT: )
(func $f3 (result i32)
;; Type index 4 is the implicit (func (result i32)) from $f3's signature,
;; unless $block in $f2 was parsed as a block keyword and created a
;; spurious () -> () implicit type at index 4.
(block (type 4) (result i32)
(i32.const 0)
)
)
)