blob: 362f433c29c3c2d4e1720841cec7bbcee6f8dcea [file] [edit]
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: foreach %s %t wasm-opt --signature-refining --closed-world -all -S -o - | filecheck %s
;; Test that configureAll is respected: referred functions are not refined. In
;; open-world, no function types would be refined because configureAll makes
;; `func`, and therefore all function types, public.
(module
;; CHECK: (rec
;; CHECK-NEXT: (type $func-2 (func (param (ref (exact $struct))) (result (ref (exact $struct)))))
;; CHECK: (type $func-1 (func (param anyref) (result (ref (exact $struct)))))
;; CHECK: (type $2 (func (result i32)))
;; CHECK: (type $struct (struct))
;; CHECK: (type $4 (func))
;; CHECK: (type $externs (array (mut externref)))
(type $externs (array (mut externref)))
;; CHECK: (type $funcs (array (mut funcref)))
(type $funcs (array (mut funcref)))
;; CHECK: (type $bytes (array (mut i8)))
(type $bytes (array (mut i8)))
;; CHECK: (type $configureAll (func (param (ref null $externs) (ref null $funcs) (ref null $bytes) externref)))
(type $configureAll (func (param (ref null $externs)) (param (ref null $funcs)) (param (ref null $bytes)) (param externref)))
(type $struct (struct))
(rec
(type $func-1 (func (param anyref) (result anyref)))
;; use brands to allow $func-1/2 to be optimized separately.
(type $brand1 (struct))
)
(rec
(type $func-2 (func (param anyref) (result anyref)))
(type $brand2 (struct))
(type $brand3 (struct))
)
;; CHECK: (import "wasm:js-prototypes" "configureAll" (func $configureAll (type $configureAll) (param (ref null $externs) (ref null $funcs) (ref null $bytes) externref)))
(import "wasm:js-prototypes" "configureAll" (func $configureAll (type $configureAll)))
;; CHECK: (data $bytes "12345678")
;; CHECK: (elem $externs externref (item (ref.null noextern)))
(elem $externs externref
(ref.null extern)
)
;; CHECK: (elem $funcs func $foo $bar)
(elem $funcs funcref
(ref.func $foo)
(ref.func $bar)
)
(data $bytes "12345678")
;; CHECK: (start $start)
(start $start)
;; CHECK: (func $start (type $4)
;; CHECK-NEXT: (call $configureAll
;; CHECK-NEXT: (array.new_elem $externs $externs
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: )
;; CHECK-NEXT: (array.new_elem $funcs $funcs
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (i32.const 2)
;; CHECK-NEXT: )
;; CHECK-NEXT: (array.new_data $bytes $bytes
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (i32.const 8)
;; CHECK-NEXT: )
;; CHECK-NEXT: (ref.null noextern)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $start
(call $configureAll
(array.new_elem $externs $externs
(i32.const 0) (i32.const 1))
(array.new_elem $funcs $funcs
(i32.const 0) (i32.const 2))
(array.new_data $bytes $bytes
(i32.const 0) (i32.const 8))
(ref.null extern)
)
)
;; CHECK: (func $calls (type $4)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (call $bar
;; CHECK-NEXT: (struct.new_default $struct)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (call $unconfigured
;; CHECK-NEXT: (struct.new_default $struct)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $calls
(drop
(call $bar
(struct.new $struct)
)
)
(drop
(call $unconfigured
(struct.new $struct)
)
)
)
;; CHECK: (func $foo (type $2) (result i32)
;; CHECK-NEXT: (i32.const 42)
;; CHECK-NEXT: )
(func $foo (result i32)
;; Nothing to do here anyhow, but do not error.
(i32.const 42)
)
;; CHECK: (func $bar (type $func-1) (param $x anyref) (result (ref (exact $struct)))
;; CHECK-NEXT: (struct.new_default $struct)
;; CHECK-NEXT: )
(func $bar (type $func-1) (param $x anyref) (result anyref)
;; The params will not be refined due to configureAll, but the result will.
(struct.new $struct)
)
;; CHECK: (func $unconfigured (type $func-2) (param $x (ref (exact $struct))) (result (ref (exact $struct)))
;; CHECK-NEXT: (struct.new_default $struct)
;; CHECK-NEXT: )
(func $unconfigured (type $func-2) (param $x anyref) (result anyref)
;; This is not referred to by configureAll, and can be refined in both
;; params and result.
(struct.new $struct)
)
)