blob: b860fb144a5adb7b5a822891df43ae24c22146ac [file] [edit]
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; We need to disable reference-types to reuse the existing table as the
;; dispatch table
;; RUN: wasm-split %s --disable-reference-types --split-funcs=split -g -o1 %t.1.wasm -o2 %t.2.wasm
;; RUN: wasm-dis %t.1.wasm | filecheck %s --check-prefix PRIMARY
;; RUN: wasm-dis %t.2.wasm | filecheck %s --check-prefix SECONDARY
;; This tests the case when an existing table is used as the dispatch table, and
;; the dispatch table and its base global already has existing uses in the
;; secondary module.
(module
;; PRIMARY: (type $0 (func))
;; SECONDARY: (type $0 (func))
(type $0 (func))
(global $base (import "env" "base") i32)
;; PRIMARY: (import "env" "base" (global $base i32))
;; PRIMARY: (import "placeholder.deferred" "1" (func $placeholder_1))
;; PRIMARY: (table $table 2 2 funcref)
(table $table 1 1 funcref)
(elem (global.get $base) $keep)
;; PRIMARY: (elem $0 (global.get $base) $keep $placeholder_1)
;; PRIMARY: (export "table" (table $table))
;; PRIMARY: (export "global" (global $base))
;; PRIMARY: (export "keep" (func $keep))
;; PRIMARY: (func $keep
;; PRIMARY-NEXT: (call_indirect (type $0)
;; PRIMARY-NEXT: (i32.add
;; PRIMARY-NEXT: (global.get $base)
;; PRIMARY-NEXT: (i32.const 1)
;; PRIMARY-NEXT: )
;; PRIMARY-NEXT: )
;; PRIMARY-NEXT: )
(func $keep
(call $split)
)
;; SECONDARY: (import "primary" "table" (table $table 2 2 funcref))
;; SECONDARY: (import "primary" "global" (global $base i32))
;; SECONDARY: (import "primary" "keep" (func $keep))
;; SECONDARY: (elem $0 (global.get $base) $keep $split)
;; SECONDARY: (func $split
;; SECONDARY-NEXT: (drop
;; SECONDARY-NEXT: (global.get $base)
;; SECONDARY-NEXT: )
;; SECONDARY-NEXT: (call_indirect (type $0)
;; SECONDARY-NEXT: (i32.const 0)
;; SECONDARY-NEXT: )
;; SECONDARY-NEXT: )
(func $split
(drop (global.get $base))
(call_indirect (type $0) (i32.const 0))
)
)