blob: 53c88fe0a3dda5ac2ab77a72b9df0e0ce166e130 [file]
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: foreach %s %t wasm-opt --all-features --reorder-functions -S -o - | filecheck %s
;; Check that ref.func references count towards a function's usage, both in
;; function bodies and in module code (global initializers and element
;; segments). The expected order is $c, then $a, then $b.
(module
;; CHECK: (type $0 (func (result i32)))
;; CHECK: (global $g funcref (ref.func $a))
;; CHECK: (elem declare func $a $c)
;; CHECK: (func $c (type $0) (result i32)
;; CHECK-NEXT: (i32.const 3)
;; CHECK-NEXT: )
;; CHECK: (func $a (type $0) (result i32)
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: )
(func $a (result i32)
(i32.const 1)
)
;; CHECK: (func $b (type $0) (result i32)
;; CHECK-NEXT: (i32.const 2)
;; CHECK-NEXT: )
(func $b (result i32)
(i32.const 2)
)
(func $c (result i32)
(i32.const 3)
)
(global $g funcref
(ref.func $a)
)
;; CHECK: (func $use (type $0) (result i32)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (ref.func $a)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (ref.func $c)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (ref.func $c)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (call $c)
;; CHECK-NEXT: )
;; CHECK-NEXT: (call $b)
;; CHECK-NEXT: )
(func $use (result i32)
(drop (ref.func $a))
(drop (ref.func $c))
(drop (ref.func $c))
(drop (call $c))
(call $b)
)
)